]> granicus.if.org Git - php/commitdiff
updates to helpers
authorkrakjoe <joe.watkins@live.co.uk>
Tue, 12 Nov 2013 09:26:26 +0000 (09:26 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Tue, 12 Nov 2013 09:26:26 +0000 (09:26 +0000)
phpdbg_help.c
phpdbg_print.c
phpdbg_print.h
phpdbg_prompt.c
phpdbg_prompt.h

index 21feb07926d1bfd637ae45dad6f9fb3f66b7549e..1a78c6928a925981e69448b7c82c6319654b87ea 100644 (file)
@@ -19,6 +19,9 @@
 
 #include "phpdbg.h"
 #include "phpdbg_help.h"
+#include "phpdbg_print.h"
+
+ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
 
 PHPDBG_HELP(exec) /* {{{ */
 {
@@ -31,7 +34,7 @@ PHPDBG_HELP(step) /* {{{ */
 {
     printf("You can enable and disable stepping at any phpdbg prompt during execution\n");
     printf("For example:\n");
-    printf("\tphpdbg> stepping 1\n");
+    printf("\t%sstepping 1\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
     printf("Will enable stepping\n");
     printf("While stepping is enabled you are presented with a prompt after the execution of each opcode\n");
     return SUCCESS;
@@ -56,11 +59,16 @@ PHPDBG_HELP(compile) /* {{{ */
 PHPDBG_HELP(print) /* {{{ */
 {
        printf("By default, print will show information about the current execution environment\n");
-       printf("To show specific information pass an expression to print, for example:\n");
-       printf("\tphpdbg> print opcodes[0]\n");
-       printf("Will show the opline @ 0\n");
-       printf("Available print commands:\n");
-       printf("\tNone\n");
+       printf("Specific printers loaded are show below:\n");
+       printf("%sCommands%s\n", PHPDBG_BOLD_LINE(TSRMLS_C), PHPDBG_END_LINE(TSRMLS_C));
+       {
+           phpdbg_command_t *print_command = phpdbg_print_commands;
+           
+           while (print_command && print_command->name) {
+                       printf("\t%s\t%s\n", print_command->name, print_command->tip);
+                       ++print_command;
+               }
+       }
        return SUCCESS;
 } /* }}} */
 
@@ -86,13 +94,13 @@ PHPDBG_HELP(break) /* {{{ */
        printf("\t\\my\\class::method\n");
        printf("\t0x16\n");
        printf("For example:\n");
-       printf("\tphpdbg> break test.php:1\n");
+       printf("\t%sbreak test.php:1\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
        printf("Will break execution on line 1 of test.php\n");
-       printf("\tphpdbg> break my_function\n");
+       printf("\t%sbreak my_function\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
        printf("Will break execution on entry to my_function\n");
-       printf("\tphpdbg> break \\my\\class::method\n");
+       printf("\t%sbreak \\my\\class::method\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
        printf("Will break execution on entry to \\my\\class::method\n");
-       printf("\tphpdbg> break 0x7ff68f570e08\n");
+       printf("\t%sbreak 0x7ff68f570e08\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
        printf("Will break at the opline with the address provided (addresses are shown during execution)\n");
        printf("It is important to note, an address is only valid for the current compiled representation of the script\n");
        printf("If you have to clean the environment and recompile then your opline break points will be invalid\n");
@@ -117,9 +125,9 @@ PHPDBG_HELP(quiet) /* {{{ */
 {
     printf("Setting quietness on will stop the OPLINE output during execution\n");
     printf("For example:\n");
-    printf("\tphpdbg> quiet 1\n");
+    printf("\t%squiet 1\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
     printf("Will silence OPLINE output, while\n");
-    printf("\tphpdbg> quiet 0\n");
+    printf("\t%squiet 0\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
     printf("Will enable OPLINE output again\n");
     return SUCCESS;
 } /* }}} */
@@ -128,7 +136,7 @@ PHPDBG_HELP(back) /* {{{ */
 {
        printf("The backtrace is gathered with the default debug_backtrace functionality.\n");
        printf("You can set the limit on the trace, for example:\n");
-       printf("\tphpdbg> back 5\n");
+       printf("\t%sback 5\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
        printf("Will limit the number of frames to 5, the default is no limit\n");
        return SUCCESS;
 } /* }}} */
@@ -136,11 +144,11 @@ PHPDBG_HELP(back) /* {{{ */
 PHPDBG_HELP(list) /* {{{ */
 {
        printf("The list command displays N line from current context file.\n");
-       printf("\tphpdbg> list 2\n");
+       printf("\t%slist 2\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
        printf("Will print next 2 lines from the current file\n");
-       printf("\tphpdbg> list func\n");
+       printf("\t%slist func\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
        printf("Will print the source of the global function \"func\"\n");
-       printf("\tphpdbg> list .mine\n");
+       printf("\t%slist .mine\n", PHPDBG_PROMPT_LINE(TSRMLS_C));
        printf("Will print the source of the class method \"mine\"\n");
        printf("Note: before listing functions you must have a populated function table, try compile !!\n");
        return SUCCESS;
index d49cc26fcb1dfd400c034a5a6942b15ab59e5772..747789799f8354a8a4b7f4bc5986c4687e0aa147 100644 (file)
 #include "phpdbg.h"
 #include "phpdbg_print.h"
 
-PHPDBG_PRINT(default) /* {{{ */
+ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
+
+PHPDBG_PRINT(opline) /* {{{ */
 {
-       printf("in default printer\n");
+       if (EG(in_execution) && EG(current_execute_data)) {
+           phpdbg_print_opline(
+               EG(current_execute_data), 1 TSRMLS_CC);
+       } else {
+           printf( 
+               "%sNot Executing!%s\n", 
+               PHPDBG_RED_LINE(TSRMLS_C), PHPDBG_END_LINE(TSRMLS_C));
+       }
+           
        return SUCCESS;
 } /* }}} */
index 825316a965d0710e91e1c0233c8d7350f263cb13..ae8453bd0ff5cedc906e71147a3c7b61c41e2969 100644 (file)
 /**
  * Printer Forward Declarations
  */
-PHPDBG_PRINT(default);
+PHPDBG_PRINT(opline);
 
 /**
  * Commands
  */
 static const phpdbg_command_t phpdbg_print_commands[] = {
-       PHPDBG_PRINT_D(default,     "the default print command"),
+       PHPDBG_PRINT_D(opline,     "print the current opline information"),
        {NULL, 0, 0}
 };
 
index dd225d6dbc43f4ff33a15b00ab5964b677cb1ba8..5fae1559d386f147a7fd4c78d5d7a493a404a228 100644 (file)
@@ -699,15 +699,15 @@ phpdbg_interactive_enter:
        return SUCCESS;
 } /* }}} */
 
-static void phpdbg_print_opline(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
+void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC) /* {{{ */
 {
     /* force out a line while stepping so the user knows what is happening */
-    if (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || (PHPDBG_G(flags) & PHPDBG_IS_STEPPING)) {
+    if (ignore_flags || (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || (PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) {
         zend_op *opline = execute_data->opline;
 
         printf(
             "%sOPLINE: %p:%s%s\n", 
-            PHPDBG_BOLD_LINE(TSRMLS_C), 
+            PHPDBG_BOLD_LINE(TSRMLS_C),
             opline, phpdbg_decode_opcode(opline->opcode), PHPDBG_END_LINE(TSRMLS_C));
     }
 } /* }}} */
@@ -731,7 +731,7 @@ zend_vm_enter:
 #endif
 
         phpdbg_print_opline(
-                   execute_data TSRMLS_CC);
+                   execute_data, 0 TSRMLS_CC);
 
         if ((PHPDBG_G(flags) & PHPDBG_HAS_FILE_BP)
             && phpdbg_find_breakpoint_file(execute_data->op_array TSRMLS_CC) == SUCCESS) {
index bddc7f99f7da53ff6f4aad7cffe4200217487642..f9fd39dfdb5dc0d19e1adde032b25fddae4c7ec7 100644 (file)
@@ -60,5 +60,6 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, char *cmd_line, size_t cmd_le
 
 int phpdbg_interactive(TSRMLS_D);
 void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC);
+void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC);
 
 #endif /* PHPDBG_PROMPT_H */