com php-src: Fix first frame in backtrace: sapi/phpdbg/phpdbg _frame.c
| From: | Bob Weinand | Date: | Tue, 21 Apr 2015 20:20:11 +0000 |
| Subject: | com php-src: Fix first frame in backtrace: sapi/phpdbg/phpdbg _frame.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-86421@lists.php.net to get a copy of this message | ||
Commit: 76b1d755fc7778f80455b1bfb8ccc009083974c1
Author: Bob Weinand <bobwei9@hotmail.com> Tue, 21 Apr 2015 22:20:11 +0200
Parents: 4376373da33214b52258ea7a38d605f6df011296
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=76b1d755fc7778f80455b1bfb8ccc009083974c1
Log:
Fix first frame in backtrace
Changed paths:
M sapi/phpdbg/phpdbg_frame.c
Diff:
diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c
index 6d1163b..584052e 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("<backtrace %r>");
+ 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("<frame %r id=\"%d\" file=\"%s\"
line=\"%d\"", i, Z_STRVAL_P(file), Z_LVAL_P(line));
@@ -227,12 +224,17 @@ void phpdbg_dump_backtrace(size_t num) /* {{{ */
phpdbg_dump_prototype(tmp);
phpdbg_out(" (internal function)\n");
}
+
+ 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);
}
- phpdbg_out("\n");
+ phpdbg_writeln("frame", "id=\"%d\" symbol=\"{main}\"
file=\"%s\" line=\"%d\"", "frame #%d: {main} at %s:%ld", i,
Z_STRVAL_P(file), Z_LVAL_P(line));
phpdbg_xml("</backtrace>");
zval_dtor(&zbacktrace);
+ zend_string_release(Z_STR(startfile));
PHPDBG_OUTPUT_BACKUP_RESTORE();
} /* }}} */