diff options
author | Thies C. Arntzen <thies@php.net> | 2002-08-23 14:22:25 +0000 |
---|---|---|
committer | Thies C. Arntzen <thies@php.net> | 2002-08-23 14:22:25 +0000 |
commit | 280809189bb45d53a788c4a4ee421f0172a633c1 (patch) | |
tree | 9193e61bcf35aff907f59bee0a891dd726bfc279 /Zend | |
parent | 0c386174dbc137d5450dc5bec1a23b006bde8e76 (diff) | |
download | php-git-280809189bb45d53a788c4a4ee421f0172a633c1.tar.gz |
- debug_backtrace now also returns an array containing the arguments of the
called function.
zeev, andi - is knowing the structure of the stack considered a bad thing in
zend_builtin_function? if yes i would have to create a new function in
zend_ptr_stack.c (but i think we are save this way)
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/zend_builtin_functions.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 424078d3d0..97ec52b06f 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1247,6 +1247,27 @@ ZEND_FUNCTION(get_defined_constants) /* }}} */ +static zval *debug_backtrace_get_args(void ***curpos, int andjustonly TSRMLS_DC) { + void **p = *curpos - 2; + zval *arg_array, **arg; + int arg_count = (ulong) *p; + + *curpos -= (arg_count+2); + + if (! andjustonly) { + MAKE_STD_ZVAL(arg_array); + array_init(arg_array); + p -= arg_count; + while (--arg_count>=0) { + arg = (zval **) p++; + (*arg)->is_ref = 1; + (*arg)->refcount++; + add_next_index_zval(arg_array, *arg); + } + return arg_array; + } +} + /* {{{ proto void debug_backtrace(void) Prints out a backtrace */ ZEND_FUNCTION(debug_backtrace) @@ -1257,11 +1278,13 @@ ZEND_FUNCTION(debug_backtrace) char *filename; char *class_name; zval *stack_frame; + void **cur_arg_pos = EG(argument_stack).top_element; ptr = EG(current_execute_data); /* Skip debug_backtrace() itself */ ptr = ptr->prev_execute_data; + debug_backtrace_get_args(&cur_arg_pos, 1 TSRMLS_CC); array_init(return_value); @@ -1295,6 +1318,8 @@ ZEND_FUNCTION(debug_backtrace) add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 1); } + add_assoc_zval_ex(stack_frame, "args", sizeof("args"), debug_backtrace_get_args(&cur_arg_pos, 0 TSRMLS_CC)); + add_next_index_zval(return_value, stack_frame); ptr = ptr->prev_execute_data; |