summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_builtin_functions.c21
-rw-r--r--Zend/zend_builtin_functions.h1
-rw-r--r--Zend/zend_default_classes.c9
-rw-r--r--Zend/zend_exceptions.c9
4 files changed, 33 insertions, 7 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index c0786f8ff3..3c4bce4e76 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1537,9 +1537,8 @@ ZEND_FUNCTION(debug_print_backtrace)
}
/* }}} */
-/* {{{ proto void debug_backtrace(void)
- Prints out a backtrace */
-ZEND_FUNCTION(debug_backtrace)
+
+ZEND_API void zend_fetch_debug_backtrace(zval *return_value TSRMLS_DC)
{
zend_execute_data *ptr;
int lineno;
@@ -1554,10 +1553,6 @@ ZEND_FUNCTION(debug_backtrace)
int arg_stack_consistent = 0;
int frames_on_stack = 0;
- if (ZEND_NUM_ARGS()) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
while (--args >= EG(argument_stack).elements) {
if (*args--) {
break;
@@ -1680,6 +1675,18 @@ ZEND_FUNCTION(debug_backtrace)
/* }}} */
+/* {{{ proto array debug_backtrace(void)
+ Return backtrace as array */
+ZEND_FUNCTION(debug_backtrace)
+{
+ if (ZEND_NUM_ARGS()) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+
+ zend_fetch_debug_backtrace(return_value TSRMLS_CC);
+}
+/* }}} */
+
/* {{{ proto bool extension_loaded(string extension_name)
Returns true if the named extension is loaded */
ZEND_FUNCTION(extension_loaded)
diff --git a/Zend/zend_builtin_functions.h b/Zend/zend_builtin_functions.h
index 07588aeee7..3367ff3e66 100644
--- a/Zend/zend_builtin_functions.h
+++ b/Zend/zend_builtin_functions.h
@@ -23,6 +23,7 @@
#define ZEND_BUILTIN_FUNCTIONS_H
int zend_startup_builtin_functions(TSRMLS_D);
+ZEND_API void zend_fetch_debug_backtrace(zval *return_value TSRMLS_DC);
#endif /* ZEND_BUILTIN_FUNCTIONS_H */
diff --git a/Zend/zend_default_classes.c b/Zend/zend_default_classes.c
index db0363e939..e99e6d3287 100644
--- a/Zend/zend_default_classes.c
+++ b/Zend/zend_default_classes.c
@@ -22,6 +22,7 @@
#include "zend.h"
#include "zend_API.h"
#include "zend_reflection_api.h"
+#include "zend_builtin_functions.h"
zend_class_entry *default_exception_ptr;
@@ -29,6 +30,7 @@ static zend_object_value zend_default_exception_new(zend_class_entry *class_type
{
zval tmp, obj;
zend_object *object;
+ zval *trace;
obj.value.obj = zend_objects_new(&object, class_type TSRMLS_CC);
@@ -36,8 +38,14 @@ static zend_object_value zend_default_exception_new(zend_class_entry *class_type
zend_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+ ALLOC_ZVAL(trace);
+ trace->is_ref = 0;
+ trace->refcount = 0;
+ zend_fetch_debug_backtrace(trace TSRMLS_CC);
+
zend_update_property_string(class_type, &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC);
zend_update_property_long(class_type, &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
+ zend_update_property(class_type, &obj, "trace", sizeof("trace")-1, trace TSRMLS_CC);
return obj.value.obj;
}
@@ -128,6 +136,7 @@ static void zend_register_default_exception(TSRMLS_D)
zend_declare_property_long(default_exception_ptr, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED);
zend_declare_property_null(default_exception_ptr, "file", sizeof("file")-1, ZEND_ACC_PROTECTED);
zend_declare_property_null(default_exception_ptr, "line", sizeof("line")-1, ZEND_ACC_PROTECTED);
+ zend_declare_property_null(default_exception_ptr, "trace", sizeof("trace")-1, ZEND_ACC_PROTECTED);
}
ZEND_API zend_class_entry *zend_exception_get_default(void)
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index db0363e939..e99e6d3287 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -22,6 +22,7 @@
#include "zend.h"
#include "zend_API.h"
#include "zend_reflection_api.h"
+#include "zend_builtin_functions.h"
zend_class_entry *default_exception_ptr;
@@ -29,6 +30,7 @@ static zend_object_value zend_default_exception_new(zend_class_entry *class_type
{
zval tmp, obj;
zend_object *object;
+ zval *trace;
obj.value.obj = zend_objects_new(&object, class_type TSRMLS_CC);
@@ -36,8 +38,14 @@ static zend_object_value zend_default_exception_new(zend_class_entry *class_type
zend_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+ ALLOC_ZVAL(trace);
+ trace->is_ref = 0;
+ trace->refcount = 0;
+ zend_fetch_debug_backtrace(trace TSRMLS_CC);
+
zend_update_property_string(class_type, &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC);
zend_update_property_long(class_type, &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
+ zend_update_property(class_type, &obj, "trace", sizeof("trace")-1, trace TSRMLS_CC);
return obj.value.obj;
}
@@ -128,6 +136,7 @@ static void zend_register_default_exception(TSRMLS_D)
zend_declare_property_long(default_exception_ptr, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED);
zend_declare_property_null(default_exception_ptr, "file", sizeof("file")-1, ZEND_ACC_PROTECTED);
zend_declare_property_null(default_exception_ptr, "line", sizeof("line")-1, ZEND_ACC_PROTECTED);
+ zend_declare_property_null(default_exception_ptr, "trace", sizeof("trace")-1, ZEND_ACC_PROTECTED);
}
ZEND_API zend_class_entry *zend_exception_get_default(void)