From: Sebastian Bergmann Date: Fri, 28 Oct 2005 20:08:25 +0000 (+0000) Subject: Add an additional field $frame['object'] to the result array of debug_backtrace(... X-Git-Tag: RELEASE_2_0_1~130 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=805cc1d6591b4085751ff48a59faa6984aaad32d;p=php 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. Patch has been reviewed by Andi, Zeev, and Marcus. I will coordinate with Ilia on merging it to the PHP_5_1 branch after PHP 5.1.0 has been released. --- diff --git a/NEWS b/NEWS index d207eeae88..73da6691ee 100644 --- a/NEWS +++ b/NEWS @@ -22,4 +22,7 @@ PHP NEWS the part of haystack before or after first occurence of needle. (Johannes) - Added possibility to check in which extension an internal function was defined using reflection API. (Johannes) +- Added 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. (Sebastian) - Fixed bug #34286 (__toString() behavior is inconsistent). (Marcus) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 5967cfc5f2..4027bdc2a2 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -2005,6 +2005,9 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last TSRML dup = zend_get_object_classname(ptr->object, &class_name, &class_name_len TSRMLS_CC); add_assoc_text_ex(stack_frame, "class", sizeof("class"), class_name, dup); } + add_assoc_zval_ex(stack_frame, "object", sizeof("object"), ptr->object); + ptr->object->refcount++; + add_assoc_ascii_string_ex(stack_frame, "type", sizeof("type"), "->", 1); } else if (ptr->function_state.function->common.scope) { add_assoc_textl_ex(stack_frame, "class", sizeof("class"), ptr->function_state.function->common.scope->name, ptr->function_state.function->common.scope->name_length, 1);