]> granicus.if.org Git - php/commitdiff
add print exec command to show current execution context instructions
authorkrakjoe <joe.watkins@live.co.uk>
Sun, 17 Nov 2013 09:30:44 +0000 (09:30 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Sun, 17 Nov 2013 09:30:44 +0000 (09:30 +0000)
make phpdbg_compile public

phpdbg_help.c
phpdbg_print.c
phpdbg_print.h
phpdbg_prompt.c
phpdbg_prompt.h

index e7de30af935934cafb8e382c9535a9968a6ba164..2a0c998c0bb857c642544efcd52a29706ead5a98 100644 (file)
@@ -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");
index 09e6d7fab7c2109af11d9c237293c2b03584291d..9a4a1585d6129faa164595536700ce031f1a610c 100644 (file)
@@ -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;
index 01bc27fa43e1361e20d93f6bc13c21ba3a875edd..dc6a13338cd63261eae1227ce7ddbd7282db0770 100644 (file)
@@ -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'),
index d3876be0fb5e8f55f595b3b36d4a16368cad622f..0281fd7ec6d8bbf5902280d20690c1b1567b0ec9 100644 (file)
@@ -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;
 
index 8e4a0c144c97fd755ac4f9591014b2f4349d9558..f3839d0315080fbd76a7830610251fdd10931a7a 100644 (file)
@@ -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