From 2f9b34d4b639b79a82d75f4ed509bfbc0e72e9de Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 10 Nov 2013 15:16:45 +0000 Subject: [PATCH] backtrace --- phpdbg_prompt.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index f61f8d408f..3be2753ce9 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -136,6 +136,21 @@ static PHPDBG_COMMAND(eval) { /* {{{ */ return SUCCESS; } /* }}} */ +static PHPDBG_COMMAND(back) { /* {{{ */ + if (EG(in_execution)) { + const zend_execute_data *current = EG(current_execute_data); + if (current) { + do { + printf("%d\n", current->opline->opcode); + } while ((current = current->prev_execute_data)); + } + return SUCCESS; + } else { + printf("Not executing !\n"); + return FAILURE; + } +} /* }}} */ + static PHPDBG_COMMAND(print) { /* {{{ */ if (!expr_len) { printf("Showing Execution Context Information:\n"); @@ -213,6 +228,7 @@ static const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_COMMAND_D(eval, "evaluate some code"), PHPDBG_COMMAND_D(print, "print something"), PHPDBG_COMMAND_D(break, "set breakpoint"), + PHPDBG_COMMAND_D(back, "show backtrace"), PHPDBG_COMMAND_D(help, "show help menu"), PHPDBG_COMMAND_D(quit, "exit phpdbg"), {NULL, 0, 0} @@ -267,9 +283,8 @@ int phpdbg_interactive(int argc, char **argv TSRMLS_DC) /* {{{ */ void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC) { - zend_bool original_in_execution; + zend_bool original_in_execution = EG(in_execution); - original_in_execution = EG(in_execution); EG(in_execution) = 1; if (0) { -- 2.50.1