From: Bob Weinand Date: Tue, 21 Apr 2015 20:20:11 +0000 (+0200) Subject: Fix first frame in backtrace X-Git-Tag: PRE_PHP7_NSAPI_REMOVAL~191 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=76b1d755fc7778f80455b1bfb8ccc009083974c1;p=php Fix first frame in backtrace --- diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c index 6d1163b069..584052ee0b 100644 --- a/sapi/phpdbg/phpdbg_frame.c +++ b/sapi/phpdbg/phpdbg_frame.c @@ -182,7 +182,9 @@ void phpdbg_dump_backtrace(size_t num) /* {{{ */ HashPosition position; zval zbacktrace; zval *tmp; - zval *file, *line; + zval startline, startfile; + const char *startfilename; + zval *file = &startfile, *line = &startline; int i = 0, limit = num; PHPDBG_OUTPUT_BACKUP(); @@ -203,18 +205,13 @@ void phpdbg_dump_backtrace(size_t num) /* {{{ */ phpdbg_xml(""); + Z_LVAL(startline) = zend_get_executed_lineno(); + startfilename = zend_get_executed_filename(); + Z_STR(startfile) = zend_string_init(startfilename, strlen(startfilename), 0); + zend_hash_internal_pointer_reset_ex(Z_ARRVAL(zbacktrace), &position); tmp = zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), &position); - while (1) { - file = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("file")); - line = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("line")); - zend_hash_move_forward_ex(Z_ARRVAL(zbacktrace), &position); - - if (!(tmp = zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), &position))) { - phpdbg_write("frame", "id=\"%d\" symbol=\"{main}\" file=\"%s\" line=\"%d\"", "frame #%d: {main} at %s:%ld", i, Z_STRVAL_P(file), Z_LVAL_P(line)); - break; - } - + while ((tmp = zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), &position))) { if (file) { /* userland */ phpdbg_out("frame #%d: ", i); phpdbg_xml(""); zval_dtor(&zbacktrace); + zend_string_release(Z_STR(startfile)); PHPDBG_OUTPUT_BACKUP_RESTORE(); } /* }}} */