[xdebug-dev] xdebug xdebug/xdebug.c xdebug/xdebug_handlers.h xdebug/xdebug_handler_dbgp.c - Implemented the "return" breakpoint for DBGp.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Mon, 12 Apr 2004 20:31:01 +0200

Date: Mon Apr 12 20:31:00 CEST 2004
User: Derick Rethans
Directory: xdebug

Log Message:
[1.50]
- Implemented the "return" breakpoint for DBGp.
- Fixed the "context_get" DBGp command to return errors in case the stack
  depth requested doesn't exist.
- Changed the -b and -e options to the DBGp "source" command to default
  to 0 and "end of script" so that either of those can be emitted. If -b
  exists and -e misses then the command will return all lines from the -b
  defined line to the end of the script. If -e exists and -b misses then
  all source until the line specified with -e is returned.

Modified files:
           xdebug/xdebug.c (version: 1.208)
           xdebug/xdebug_handlers.h (version: 1.28)
           xdebug/xdebug_handler_dbgp.c (version: 1.37)

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.207
retrieving revision 1.208
diff -u -r1.207 -r1.208
--- xdebug/xdebug.c:1.207 Sun Apr 11 12:22:08 2004 GMT
+++ xdebug/xdebug.c Mon Apr 12 16:31:00 2004 GMT
@@ -761,7 +761,7 @@
         }
 }
 
-static int handle_breakpoints(function_stack_entry *fse)
+static int handle_breakpoints(function_stack_entry *fse, int breakpoint_type)
 {
         xdebug_brk_info *extra_brk_info = NULL;
         char *tmp_name = NULL;
@@ -772,14 +772,14 @@
                 if (xdebug_hash_find(XG(context).function_breakpoints, fse->function.function, strlen(fse->function.function), (void *) &extra_brk_info)) {
                         /* Yup, breakpoint found, we call the handler when it's not
                          * disabled*/
- if (!extra_brk_info->disabled) {
- if (fse->user_defined == XDEBUG_EXTERNAL) {
- XG(context).do_break = 1;
- } else {
+ if (!extra_brk_info->disabled && (extra_brk_info->function_break_type == breakpoint_type)) {
+ if (fse->user_defined == XDEBUG_INTERNAL || (breakpoint_type == XDEBUG_BRK_FUNC_RETURN)) {
                                         if (!XG(context).handler->remote_breakpoint(&(XG(context)), XG(stack), fse->filename, fse->lineno, XDEBUG_BREAK)) {
                                                 XG(remote_enabled) = 0;
                                                 return 0;
                                         }
+ } else {
+ XG(context).do_break = 1;
                                 }
                         }
                 }
@@ -906,9 +906,9 @@
                 add_used_variables(fse, op_array);
         }
 
- /* Check for breakpoints */
+ /* Check for entry breakpoints */
         if (XG(remote_enabled) && XG(breakpoints_allowed)) {
- if (!handle_breakpoints(fse)) {
+ if (!handle_breakpoints(fse, XDEBUG_BRK_FUNC_CALL)) {
                         XG(remote_enabled) = 0;
                 }
         }
@@ -918,6 +918,10 @@
         }
         old_execute(op_array TSRMLS_CC);
 
+ if (XG(profiler_enabled)) {
+ xdebug_profiler_function_user_end(fse, op_array TSRMLS_CC);
+ }
+
         if (XG(collect_return) && do_return && XG(do_trace) && XG(trace_file)) {
                 if (EG(return_value_ptr_ptr) && *EG(return_value_ptr_ptr)) {
                         char* t = return_trace_stack_retval(fse, *EG(return_value_ptr_ptr) TSRMLS_CC);
@@ -926,11 +930,14 @@
                         xdfree(t);
                 }
         }
-
- if (XG(profiler_enabled)) {
- xdebug_profiler_function_user_end(fse, op_array TSRMLS_CC);
+
+ /* Check for return breakpoints */
+ if (XG(remote_enabled) && XG(breakpoints_allowed)) {
+ if (!handle_breakpoints(fse, XDEBUG_BRK_FUNC_RETURN)) {
+ XG(remote_enabled) = 0;
+ }
         }
-
+
         fse->symbol_table = NULL;
         xdebug_llist_remove(XG(stack), XDEBUG_LLIST_TAIL(XG(stack)), stack_element_dtor);
         XG(level)--;
@@ -950,9 +957,9 @@
 
         fse = add_stack_frame(edata, edata->op_array, XDEBUG_INTERNAL TSRMLS_CC);
 
- /* Check for breakpoints */
+ /* Check for entry breakpoints */
         if (XG(remote_enabled) && XG(breakpoints_allowed)) {
- if (!handle_breakpoints(fse)) {
+ if (!handle_breakpoints(fse, XDEBUG_BRK_FUNC_CALL)) {
                         XG(remote_enabled) = 0;
                 }
         }
@@ -962,6 +969,10 @@
         }
         execute_internal(current_execute_data, return_value_used TSRMLS_CC);
 
+ if (XG(profiler_enabled)) {
+ xdebug_profiler_function_internal_end(fse TSRMLS_CC);
+ }
+
         if (XG(collect_return) && do_return && XG(do_trace) && XG(trace_file)) {
                 cur_opcode = *EG(opline_ptr);
                 if (cur_opcode) {
@@ -973,10 +984,13 @@
                 }
         }
 
- if (XG(profiler_enabled)) {
- xdebug_profiler_function_internal_end(fse TSRMLS_CC);
+ /* Check for return breakpoints */
+ if (XG(remote_enabled) && XG(breakpoints_allowed)) {
+ if (!handle_breakpoints(fse, XDEBUG_BRK_FUNC_RETURN)) {
+ XG(remote_enabled) = 0;
+ }
         }
-
+
         xdebug_llist_remove(XG(stack), XDEBUG_LLIST_TAIL(XG(stack)), stack_element_dtor);
         XG(level)--;
 }

[FILE: /xdebug/xdebug_handlers.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- xdebug/xdebug_handlers.h:1.27 Thu Mar 25 15:57:31 2004 GMT
+++ xdebug/xdebug_handlers.h Mon Apr 12 16:31:00 2004 GMT
@@ -71,10 +71,14 @@
 #define XDEBUG_HIT_EQUAL 2
 #define XDEBUG_HIT_MOD 3
 
+#define XDEBUG_BRK_FUNC_CALL 1
+#define XDEBUG_BRK_FUNC_RETURN 2
+
 struct _xdebug_brk_info {
         char *type;
         char *classname;
         char *functionname;
+ int function_break_type; /* XDEBUG_BRK_FUNC_* */
         char *file;
         int file_len;
         int lineno;

[FILE: /xdebug/xdebug_handler_dbgp.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- xdebug/xdebug_handler_dbgp.c:1.36 Thu Apr 08 19:47:43 2004 GMT
+++ xdebug/xdebug_handler_dbgp.c Mon Apr 12 16:31:00 2004 GMT
@@ -618,6 +618,7 @@
         brk_info->file_len = 0;
         brk_info->classname = NULL;
         brk_info->functionname = NULL;
+ brk_info->function_break_type = 0;
         brk_info->condition = NULL;
         brk_info->disabled = 0;
         brk_info->temporary = 0;
@@ -665,7 +666,13 @@
                 xdebug_llist_insert_next(context->line_breakpoints, XDEBUG_LLIST_TAIL(context->line_breakpoints), (void*) brk_info);
         } else
 
- if (strcmp(CMD_OPTION('t'), "call") == 0) {
+ if ((strcmp(CMD_OPTION('t'), "call") == 0) || (strcmp(CMD_OPTION('t'), "return") == 0)) {
+ if (strcmp(CMD_OPTION('t'), "call") == 0) {
+ brk_info->function_break_type = XDEBUG_BRK_FUNC_CALL;
+ } else {
+ brk_info->function_break_type = XDEBUG_BRK_FUNC_RETURN;
+ }
+
                 if (!CMD_OPTION('m')) {
                         RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_INVALID_ARGS);
                 }
@@ -809,7 +816,7 @@
 DBGP_FUNC(source)
 {
         char *source, *encoded_source;
- int new_len;
+ int new_len, begin = 0, end = 999999;
         char *filename;
         function_stack_entry *fse;
 
@@ -823,11 +830,14 @@
                 filename = CMD_OPTION('f');
         }
 
- if (CMD_OPTION('b') && CMD_OPTION('e')) {
- source = return_source(filename, strtol(CMD_OPTION('b'), NULL, 10), strtol(CMD_OPTION('e'), NULL, 10) TSRMLS_CC);
- } else {
- source = return_source(filename, 0, 999999 TSRMLS_CC);
+ if (CMD_OPTION('b')) {
+ begin = strtol(CMD_OPTION('b'), NULL, 10);
+ }
+ if (CMD_OPTION('e')) {
+ begin = strtol(CMD_OPTION('e'), NULL, 10);
         }
+ source = return_source(filename, begin, end TSRMLS_CC);
+
         if (!source) {
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_CANT_OPEN_FILE);
         } else {
@@ -1035,10 +1045,12 @@
                 if (ht) {
                         xdebug_hash_apply(ht, (void *) node, func);
                 }
+
+ XG(active_symbol_table) = NULL;
+ return 0;
         }
         
- XG(active_symbol_table) = NULL;
- return 0;
+ return 1;
 }
 
 
@@ -1316,7 +1328,7 @@
 
 char *xdebug_dbgp_get_revision(void)
 {
- return "$Revision: 1.36 $";
+ return "$Revision: 1.37 $";
 }
 
 int xdebug_dbgp_cmdloop(xdebug_con *context TSRMLS_DC)
Received on Mon Apr 12 2004 - 20:31:02 BST

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:02 BST