Commit:    2ba9e9306f6a696537a9ef1487a6912b0d342c5e
Author:    krakjoe <joe.watk...@live.co.uk>         Sun, 17 Nov 2013 15:39:23 
+0000
Parents:   e2f20c57c108ca2c6784e1367c9b0c68f73969c7
Branches:  PHP-5.6

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=2ba9e9306f6a696537a9ef1487a6912b0d342c5e

Log:
leave function + help

Changed paths:
  M  phpdbg.h
  M  phpdbg_help.c
  M  phpdbg_help.h
  M  phpdbg_prompt.c
  M  phpdbg_prompt.h


Diff:
diff --git a/phpdbg.h b/phpdbg.h
index 1b23039..625d0af 100644
--- a/phpdbg.h
+++ b/phpdbg.h
@@ -59,7 +59,10 @@
 # define PHPDBG_G(v) (phpdbg_globals.v)
 #endif
 
-#define PHPDBG_NEXT 2
+#define PHPDBG_NEXT   2
+#define PHPDBG_UNTIL  3
+#define PHPDBG_FINISH 4
+#define PHPDBG_LEAVE  5
 
 /* {{{ tables */
 #define PHPDBG_BREAK_FILE       0
diff --git a/phpdbg_help.c b/phpdbg_help.c
index 8ae9c94..fd09432 100644
--- a/phpdbg_help.c
+++ b/phpdbg_help.c
@@ -52,7 +52,8 @@ PHPDBG_HELP(step) /* {{{ */
 PHPDBG_HELP(next) /* {{{ */
 {
     phpdbg_help_header();
-       phpdbg_writeln("While stepping through execution, or after a 
breakpoint, use the next command to step back into the vm and execute the next 
opcode");
+       phpdbg_write("While stepping through execution, or after a breakpoint, 
");
+       phpdbg_writeln("use the next command to step back into the vm and 
execute the next opcode");
        phpdbg_help_footer();
        return SUCCESS;
 } /* }}} */
@@ -60,7 +61,8 @@ PHPDBG_HELP(next) /* {{{ */
 PHPDBG_HELP(until) /* {{{ */
 {
     phpdbg_help_header();
-       phpdbg_writeln("While stepping through execution, or after a 
breakpoint, use the until command to step back into the vm and reaches the next 
source line");
+       phpdbg_write("While stepping through execution, or after a breakpoint, 
");
+       phpdbg_writeln("use the until command to step back into the vm and 
reaches the next source line");
        phpdbg_help_footer();
        return SUCCESS;
 } /* }}} */
@@ -68,7 +70,19 @@ PHPDBG_HELP(until) /* {{{ */
 PHPDBG_HELP(finish) /* {{{ */
 {
     phpdbg_help_header();
-       phpdbg_writeln("While stepping through execution, or after a 
breakpoint, use the finish command to step back into the vm and continue until 
the current function has returned");
+       phpdbg_write("While stepping through execution, or after a breakpoint, 
");
+       phpdbg_writeln("use the finish command to step back into the vm and 
continue until the current scope has returned");
+       phpdbg_writeln("Note: this allows all breakpoints that would otherwise 
break execution in the current scope to be skipped");
+       phpdbg_help_footer();
+       return SUCCESS;
+} /* }}} */
+
+PHPDBG_HELP(leave) /* {{{ */
+{
+    phpdbg_help_header();
+       phpdbg_write("While stepping through execution, or after a breakpoint, 
");
+       phpdbg_writeln("use the finish command to step back into the vm and 
continue until the current scope is returning");
+       phpdbg_writeln("Note: this allows inspection of the return value from 
any scope before it is returned");
        phpdbg_help_footer();
        return SUCCESS;
 } /* }}} */
diff --git a/phpdbg_help.h b/phpdbg_help.h
index 758e501..e73782b 100644
--- a/phpdbg_help.h
+++ b/phpdbg_help.h
@@ -42,6 +42,7 @@ PHPDBG_HELP(run);
 PHPDBG_HELP(eval);
 PHPDBG_HELP(until);
 PHPDBG_HELP(finish);
+PHPDBG_HELP(leave);
 PHPDBG_HELP(print);
 PHPDBG_HELP(break);
 PHPDBG_HELP(clean);
@@ -63,6 +64,7 @@ static const phpdbg_command_t phpdbg_help_commands[] = {
        PHPDBG_HELP_D(eval,     "access to eval() allows you to affect the 
environment during execution", 'E'),
        PHPDBG_HELP_D(until,    "continue until the program reaches a source 
line different than the current one", 'u'),
        PHPDBG_HELP_D(finish,   "continue until the current function has 
returned", 'f'),
+       PHPDBG_HELP_D(leave,    "continue until the current function is 
returning", 'L'),
        PHPDBG_HELP_D(print,    "printing allows inspection of the execution 
environment", 'p'),
        PHPDBG_HELP_D(break,    "breakpoints allow execution interruption", 
'b'),
        PHPDBG_HELP_D(clean,    "resetting the environment is useful while 
debugging and recompiling", 'X'),
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index 069f92a..c57b167 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -39,6 +39,7 @@ static PHPDBG_COMMAND(run);
 static PHPDBG_COMMAND(eval);
 static PHPDBG_COMMAND(until);
 static PHPDBG_COMMAND(finish);
+static PHPDBG_COMMAND(leave);
 static PHPDBG_COMMAND(print);
 static PHPDBG_COMMAND(break);
 static PHPDBG_COMMAND(back);
@@ -60,7 +61,8 @@ static const phpdbg_command_t phpdbg_prompt_commands[] = {
        PHPDBG_COMMAND_EX_D(run,        "attempt execution",                    
    'r'),
        PHPDBG_COMMAND_EX_D(eval,       "evaluate some code",                   
    'E'),
        PHPDBG_COMMAND_EX_D(until,      "continue until reaches next line",     
    'u'),
-       PHPDBG_COMMAND_EX_D(finish,      "continue until reaches next line",    
    'f'),
+       PHPDBG_COMMAND_EX_D(finish,     "continue past the end of the stack",   
    'f'),
+       PHPDBG_COMMAND_EX_D(leave,      "continue until the end of the stack",  
    'L'),
        PHPDBG_COMMANDS_D(print,        "print something",                      
    'p', phpdbg_print_commands),
        PHPDBG_COMMANDS_D(break,        "set breakpoint",                       
    'b', phpdbg_break_commands),
        PHPDBG_COMMAND_EX_D(back,       "show trace",                           
    't'),
@@ -315,6 +317,11 @@ static PHPDBG_COMMAND(finish) /* {{{ */
        return PHPDBG_FINISH;
 } /* }}} */
 
+static PHPDBG_COMMAND(leave) /* {{{ */
+{
+       return PHPDBG_LEAVE;
+} /* }}} */
+
 static PHPDBG_COMMAND(run) /* {{{ */
 {
        if (EG(in_execution)) {
@@ -830,7 +837,8 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
                                                phpdbg_error("Failed to execute 
%s!", cmd);
                                        }
                                break;
-
+       
+                               case PHPDBG_LEAVE:
                                case PHPDBG_FINISH:
                                case PHPDBG_UNTIL:
                                case PHPDBG_NEXT: {
@@ -1024,6 +1032,7 @@ zend_vm_enter:
        \
        do {\
                switch (last_step = phpdbg_interactive(TSRMLS_C)) {\
+                       case PHPDBG_LEAVE:\
                        case PHPDBG_FINISH:\
                        case PHPDBG_UNTIL:\
                        case PHPDBG_NEXT:{\
@@ -1039,6 +1048,7 @@ zend_vm_enter:
                        goto next;
                }
                
+               /* run to next line */
                if (last_step == PHPDBG_UNTIL
                        && last_file == execute_data->op_array->filename
                        && last_lineno == execute_data->opline->lineno) {
@@ -1046,6 +1056,7 @@ zend_vm_enter:
                        goto next;
                }
                
+               /* run to finish */
                if (last_step == PHPDBG_FINISH) {
                        if (execute_data->opline < last_op) {
                                /* skip possible breakpoints */
@@ -1055,11 +1066,26 @@ zend_vm_enter:
                                last_op = NULL;
                        }
                }
+               
+               /* break for leave */
+               if (last_step == PHPDBG_LEAVE) {
+                       if (execute_data->opline == last_op) {
+                               phpdbg_notice(
+                                       "Breaking for leave at %s:%u",
+                                       zend_get_executed_filename(TSRMLS_C),
+                                       zend_get_executed_lineno(TSRMLS_C)
+                               );
+                               DO_INTERACTIVE();
+                       } else {
+                               /* skip possible breakpoints */
+                               goto next;
+                       }
+               }
 
                /* not while in conditionals */
                phpdbg_print_opline(
                        execute_data, 0 TSRMLS_CC);
-
+               
                /* conditions cannot be executed by eval()'d code */
                if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)
                        && (PHPDBG_G(flags) & PHPDBG_HAS_COND_BP)
@@ -1102,9 +1128,19 @@ zend_vm_enter:
 next:
                last_lineno = execute_data->opline->lineno;
                last_file   = execute_data->op_array->filename;
-
-               if (last_step == PHPDBG_FINISH && !last_op) {
-                       last_op = 
&execute_data->op_array->opcodes[execute_data->op_array->last-1];
+               
+               switch (last_step) {
+                       case PHPDBG_FINISH:
+                               if (!last_op) {
+                                       last_op = 
&execute_data->op_array->opcodes[execute_data->op_array->last-1];
+                               }
+                       break;
+                       
+                       case PHPDBG_LEAVE:
+                               if (!last_op) {
+                                       last_op = 
&execute_data->op_array->opcodes[execute_data->op_array->last-2];     
+                               }
+                       break;
                }
 
         PHPDBG_G(vmret) = execute_data->opline->handler(execute_data 
TSRMLS_CC);
diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h
index e4e45dd..65148e3 100644
--- a/phpdbg_prompt.h
+++ b/phpdbg_prompt.h
@@ -27,10 +27,6 @@
 
 #define PHPDBG_STRL(s) s, sizeof(s)-1
 
-#define PHPDBG_NEXT   2
-#define PHPDBG_UNTIL  3
-#define PHPDBG_FINISH 4
-
 /**
  * Command Executor
  */


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to