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();
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));
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();
} /* }}} */