]> granicus.if.org Git - php/commitdiff
Add an additional field $frame['object'] to the result array of debug_backtrace(...
authorSebastian Bergmann <sebastian@php.net>
Tue, 1 Nov 2005 13:18:34 +0000 (13:18 +0000)
committerSebastian Bergmann <sebastian@php.net>
Tue, 1 Nov 2005 13:18:34 +0000 (13:18 +0000)
Zend/zend_builtin_functions.c
Zend/zend_builtin_functions.h
Zend/zend_exceptions.c

index 5967cfc5f2118862bdddaa15b8261e216369efaf..de9358625b70817014058863ab1e92d527f6f3a6 100644 (file)
@@ -1906,7 +1906,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;
@@ -2005,6 +2005,11 @@ 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);
                                }
+                               if (provide_object) {
+                                       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);
@@ -2086,7 +2091,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);
 }
 /* }}} */
 
index e5304360c17369313a27e0140999a8c4f2f87742..d8f06c61f679ad3e4467e39cc22e2977b2030a23 100644 (file)
@@ -25,7 +25,7 @@
 int zend_startup_builtin_functions(TSRMLS_D);
 
 BEGIN_EXTERN_C()
-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);
 END_EXTERN_C()
 
 #endif /* ZEND_BUILTIN_FUNCTIONS_H */
index 2659687db99614bce55d76a4ff11069537395b2f..1c7a32761ed5a9913b3aa900a5f7f288cc7a8d71 100644 (file)
@@ -92,7 +92,7 @@ static zend_object_value zend_default_exception_new_ex(zend_class_entry *class_t
        ALLOC_ZVAL(trace);
        trace->is_ref = 0;
        trace->refcount = 0;
-       zend_fetch_debug_backtrace(trace, skip_top_traces TSRMLS_CC);
+       zend_fetch_debug_backtrace(trace, skip_top_traces, 0 TSRMLS_CC);
 
        zend_update_property_rt_string(U_CLASS_ENTRY(default_exception_ce), &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC);
        zend_update_property_long(U_CLASS_ENTRY(default_exception_ce), &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);