diff options
| author | Andi Gutmans <andi@php.net> | 2002-05-02 17:20:48 +0000 |
|---|---|---|
| committer | Andi Gutmans <andi@php.net> | 2002-05-02 17:20:48 +0000 |
| commit | 7e5ec2d7616ec1a2573b76d3222333cc36e4dd3c (patch) | |
| tree | c8299fa894c60b04e7b981992c041526fca3b2ce /Zend/zend_builtin_functions.c | |
| parent | 7a64b2b7e54f437381366895d7c38f7d7a54671a (diff) | |
| download | php-git-7e5ec2d7616ec1a2573b76d3222333cc36e4dd3c.tar.gz | |
Initial support for built-in backtracing.
There are still a few problems such as includes and calling other functions
from internal functions which aren't seen (will have to think if and how to
fix this).
Also the main scripts filename isn't available. Need to think about that.
Diffstat (limited to 'Zend/zend_builtin_functions.c')
| -rw-r--r-- | Zend/zend_builtin_functions.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index dc398e73de..0f30efb30e 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -65,6 +65,7 @@ static ZEND_FUNCTION(get_loaded_extensions); static ZEND_FUNCTION(extension_loaded); static ZEND_FUNCTION(get_extension_funcs); static ZEND_FUNCTION(get_defined_constants); +static ZEND_FUNCTION(debug_backtrace); #if ZEND_DEBUG static ZEND_FUNCTION(zend_test_func); #endif @@ -116,6 +117,7 @@ static zend_function_entry builtin_functions[] = { ZEND_FE(extension_loaded, NULL) ZEND_FE(get_extension_funcs, NULL) ZEND_FE(get_defined_constants, NULL) + ZEND_FE(debug_backtrace, NULL) #if ZEND_DEBUG ZEND_FE(zend_test_func, NULL) #endif @@ -1180,6 +1182,33 @@ ZEND_FUNCTION(get_defined_constants) } +/* {{{ proto void debug_backtrace(void) + Prints out a backtrace */ +ZEND_FUNCTION(debug_backtrace) +{ + zend_execute_data *ptr; + int lineno; + + + ptr = EG(current_execute_data); + lineno = ptr->opline->lineno; + + ptr = ptr->prev_execute_data; + + while (ptr) { + if (ptr->object) { + printf("%s::", Z_OBJCE(*ptr->object)->name); + } + printf("%s() [%s:%d]\n", ptr->function_state.function->common.function_name, ptr->function_state.function->op_array.filename, lineno); + lineno = ptr->opline->lineno; + ptr = ptr->prev_execute_data; + } + + printf("main() [...:%d]\n", lineno); + RETURN_TRUE; +} + + /* {{{ proto bool extension_loaded(string extension_name) Returns true if the named extension is loaded */ ZEND_FUNCTION(extension_loaded) |
