From 22ae0d51a184f95740217833def50a5cba951b0b Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 17 Nov 2013 09:30:44 +0000 Subject: [PATCH] add print exec command to show current execution context instructions make phpdbg_compile public --- phpdbg_help.c | 2 ++ phpdbg_print.c | 22 +++++++++++++++++++++- phpdbg_print.h | 2 ++ phpdbg_prompt.c | 2 +- phpdbg_prompt.h | 1 + 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/phpdbg_help.c b/phpdbg_help.c index e7de30af93..2a0c998c0b 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -94,6 +94,8 @@ PHPDBG_HELP(print) /* {{{ */ phpdbg_writeln("Will print the instructions for the global function my_function"); phpdbg_writeln("\t%sprint opline", PROMPT); phpdbg_writeln("Will print the instruction for the current opline"); + phpdbg_writeln("\t%sprint exec", PROMPT); + phpdbg_writeln("Will print the instruction for the execution context"); phpdbg_writeln(EMPTY); phpdbg_writeln("Specific printers loaded are show below:"); phpdbg_notice("Commands"); diff --git a/phpdbg_print.c b/phpdbg_print.c index 09e6d7fab7..9a4a1585d6 100644 --- a/phpdbg_print.c +++ b/phpdbg_print.c @@ -57,7 +57,7 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC) phpdbg_writeln( "\t#%d-%d %s() %s", op_array->line_start, op_array->line_end, - method->common.function_name, + method->common.function_name ? method->common.function_name : "{main}", op_array->filename ? op_array->filename : "unknown"); } @@ -86,6 +86,26 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC) } } +PHPDBG_PRINT(exec) /* {{{ */ +{ + if (PHPDBG_G(exec)) { + if (!PHPDBG_G(ops)) { + phpdbg_compile(TSRMLS_C); + } + + if (PHPDBG_G(ops)) { + phpdbg_notice( + "Context %s", PHPDBG_G(exec)); + + phpdbg_print_function_helper((zend_function*) PHPDBG_G(ops) TSRMLS_CC); + } + } else { + phpdbg_error("No execution context set"); + } + + return SUCCESS; +} /* }}} */ + PHPDBG_PRINT(class) /* {{{ */ { zend_class_entry **ce; diff --git a/phpdbg_print.h b/phpdbg_print.h index 01bc27fa43..dc6a13338c 100644 --- a/phpdbg_print.h +++ b/phpdbg_print.h @@ -34,6 +34,7 @@ /** * Printer Forward Declarations */ +PHPDBG_PRINT(exec); PHPDBG_PRINT(opline); PHPDBG_PRINT(class); PHPDBG_PRINT(method); @@ -43,6 +44,7 @@ PHPDBG_PRINT(func); * Commands */ static const phpdbg_command_t phpdbg_print_commands[] = { + PHPDBG_PRINT_D(exec, "print execution context instructions", 'e'), PHPDBG_PRINT_D(opline, "print the current opline information", 'o'), PHPDBG_PRINT_D(class, "print out the instructions in the specified class", 'c'), PHPDBG_PRINT_D(method, "print out the instructions in the specified method", 'm'), diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index d3876be0fb..0281fd7ec6 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -232,7 +232,7 @@ static PHPDBG_COMMAND(exec) /* {{{ */ return SUCCESS; } /* }}} */ -static inline int phpdbg_compile(TSRMLS_D) /* {{{ */ +int phpdbg_compile(TSRMLS_D) /* {{{ */ { zend_file_handle fh; diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h index 8e4a0c144c..f3839d0315 100644 --- a/phpdbg_prompt.h +++ b/phpdbg_prompt.h @@ -51,6 +51,7 @@ void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TS void phpdbg_welcome(zend_bool cleaning TSRMLS_DC); int phpdbg_interactive(TSRMLS_D); void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC); +int phpdbg_compile(TSRMLS_D); void phpdbg_clean(zend_bool full TSRMLS_DC); #if PHP_VERSION_ID >= 50500 -- 2.50.1