From: Bob Weinand Date: Sun, 8 Dec 2013 20:43:19 +0000 (+0100) Subject: Renumbered frames in backtrace for internal functions X-Git-Tag: php-5.6.0alpha1~110^2~24^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3bf7ad5b5cfc630b97d1e51ea72cd52f2818dc9;p=php Renumbered frames in backtrace for internal functions --- diff --git a/phpdbg_frame.c b/phpdbg_frame.c index 5414242e3e..24aff59dd9 100644 --- a/phpdbg_frame.c +++ b/phpdbg_frame.c @@ -167,7 +167,8 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ zval **tmp; zval **file, **line; HashPosition position; - int i = 0, limit = num; + int i = 1, limit = num; + int user_defined; if (limit < 0) { phpdbg_error("Invalid backtrace size %d", limit); @@ -179,20 +180,25 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ zend_hash_internal_pointer_reset_ex(Z_ARRVAL(zbacktrace), &position); zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position); while (1) { - zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **)&file); + user_defined = zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **)&file); zend_hash_find(Z_ARRVAL_PP(tmp), "line", sizeof("line"), (void **)&line); zend_hash_move_forward_ex(Z_ARRVAL(zbacktrace), &position); - phpdbg_write("frame #%d: ", i++); - if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position) == FAILURE) { - phpdbg_write("{main} at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); + phpdbg_write("frame #0: {main} at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); break; } - phpdbg_dump_prototype(tmp TSRMLS_CC); - phpdbg_writeln(" at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); + if (user_defined == SUCCESS) { + phpdbg_write("frame #%d: ", i++); + phpdbg_dump_prototype(tmp TSRMLS_CC); + phpdbg_writeln(" at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); + } else { + phpdbg_write(" => "); + phpdbg_dump_prototype(tmp TSRMLS_CC); + phpdbg_writeln(" (internal function)"); + } } phpdbg_writeln(EMPTY);