diff options
Diffstat (limited to 'sapi/phpdbg/phpdbg_frame.c')
| -rw-r--r-- | sapi/phpdbg/phpdbg_frame.c | 26 | 
1 files changed, 14 insertions, 12 deletions
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("<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();  } /* }}} */  | 
