From f5117c81b39059c83bed8cb387ad9b7a77efe4c4 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 24 Nov 2005 05:07:28 +0000 Subject: MFH: Add an additional field $frame['object'] to the result array of debug_backtrace() that contains a reference to the respective object when the frame was called from an object. --- Zend/zend_builtin_functions.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Zend/zend_builtin_functions.c') diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 6b0d3d07c6..61caabc5ed 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1813,7 +1813,7 @@ ZEND_FUNCTION(debug_print_backtrace) /* }}} */ -ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last TSRMLS_DC) +ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int provide_object TSRMLS_DC) { zend_execute_data *ptr, *skip; int lineno; @@ -1913,6 +1913,11 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last TSRML add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, dup); } + if (provide_object) { + add_assoc_zval_ex(stack_frame, "object", sizeof("object"), ptr->object); + ptr->object->refcount++; + } + add_assoc_string_ex(stack_frame, "type", sizeof("type"), "->", 1); } else if (ptr->function_state.function->common.scope) { add_assoc_string_ex(stack_frame, "class", sizeof("class"), ptr->function_state.function->common.scope->name, 1); @@ -1994,7 +1999,7 @@ ZEND_FUNCTION(debug_backtrace) ZEND_WRONG_PARAM_COUNT(); } - zend_fetch_debug_backtrace(return_value, 1 TSRMLS_CC); + zend_fetch_debug_backtrace(return_value, 1, 1 TSRMLS_CC); } /* }}} */ -- cgit v1.2.1