diff options
| author | Andi Gutmans <andi@php.net> | 2002-07-26 10:38:25 +0000 |
|---|---|---|
| committer | Andi Gutmans <andi@php.net> | 2002-07-26 10:38:25 +0000 |
| commit | 41e3f4f0c395d512efc71e437864dbedac901a23 (patch) | |
| tree | 7da48b668e21c1046c4e81af070ccec84556b910 /Zend/zend_builtin_functions.c | |
| parent | 8d73650be25b89d593fb1bfcb254867dfee2c9ef (diff) | |
| download | php-git-41e3f4f0c395d512efc71e437864dbedac901a23.tar.gz | |
- Fix problem with debug_backtrace() reported by Stig. We weren't reporting
- global function information because it wasn't available. We have to do
- an additional assignment per-function call so that it'll be available.
- Also don't define the global scope as function name _main_ but leave it
- empty so that frameworks like Pear can decide what they want to do.
Diffstat (limited to 'Zend/zend_builtin_functions.c')
| -rw-r--r-- | Zend/zend_builtin_functions.c | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 946bf008f2..b826c54991 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1201,10 +1201,11 @@ ZEND_FUNCTION(debug_backtrace) char *class_name; zend_uint class_name_length; zval *stack_frame; - zend_bool first_time = 1; ptr = EG(current_execute_data); - lineno = ptr->opline->lineno; + + /* Skip debug_backtrace() itself */ + ptr = ptr->prev_execute_data; array_init(return_value); @@ -1222,35 +1223,22 @@ ZEND_FUNCTION(debug_backtrace) class_name = ptr->function_state.function->common.scope->name; } function_name = ptr->function_state.function->common.function_name; - if (!function_name) { - function_name = "_main_"; - } - - ptr = ptr->prev_execute_data; - if (!ptr) { - zval_ptr_dtor(&stack_frame); - break; - } - - filename = ptr->function_state.function->op_array.filename; + + filename = ptr->op_array->filename; + lineno = ptr->opline->lineno; - if (!first_time) { /* Skip the first context which is debug_backtrace() itself */ + if (function_name) { add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1); - if (class_name) { - add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 1); - } - add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1); - add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno); - /* add_assoc_stringl_ex(stack_frame, "class", sizeof("class")-1, class_name, class_name_length, 1); */ - - add_next_index_zval(return_value, stack_frame); - } else { - first_time = 0; } - - if (ptr->opline) { - lineno = ptr->opline->lineno; + if (class_name) { + add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 1); } + add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1); + add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno); + /* add_assoc_stringl_ex(stack_frame, "class", sizeof("class")-1, class_name, class_name_length, 1); */ + add_next_index_zval(return_value, stack_frame); + + ptr = ptr->prev_execute_data; } } /* }}} */ |
