summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Bergmann <sebastian@php.net>2005-11-24 05:07:28 +0000
committerSebastian Bergmann <sebastian@php.net>2005-11-24 05:07:28 +0000
commitf5117c81b39059c83bed8cb387ad9b7a77efe4c4 (patch)
tree3234d73b6222ef1ed00090dc5379b720e3e54dfa
parenta420b562df557068713a179f40d994f897e3fe4f (diff)
downloadphp-git-f5117c81b39059c83bed8cb387ad9b7a77efe4c4.tar.gz
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.
-rw-r--r--NEWS4
-rw-r--r--Zend/zend_builtin_functions.c9
-rw-r--r--Zend/zend_builtin_functions.h2
-rw-r--r--Zend/zend_exceptions.c2
4 files changed, 12 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index c1fe13fbc2..fca4bb6640 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,9 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2006, PHP 5.1.1
-
+- 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)
24 Nov 2005, PHP 5.1
- Added support for class constants and static members for internal classes.
(Dmitry, Michael Wallner)
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);
}
/* }}} */
diff --git a/Zend/zend_builtin_functions.h b/Zend/zend_builtin_functions.h
index e5304360c1..d8f06c61f6 100644
--- a/Zend/zend_builtin_functions.h
+++ b/Zend/zend_builtin_functions.h
@@ -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 */
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 222240df61..a6d2a5a147 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -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_string(default_exception_ce, &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC);
zend_update_property_long(default_exception_ce, &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);