[xdebug-dev] xdebug xdebug/xdebug.c xdebug/xdebug_handler_dbgp.c xdebug/xdebug_handlers.h - Added support for conditions for file/line breakpoints.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Tue, 14 Mar 2006 22:20:49 +0100

Date: Tue Mar 14 22:20:48 CET 2006
User: Derick Rethans
Directory: xdebug

Log Message:
[3.00]
- Added support for conditions for file/line breakpoints.
- Added support for hit value checking to file/line breakpoints.
- Added support for "exception" breakpoints.
- Removed general breaks for normal PHP warnings, errors and exceptions.

Modified files:
           xdebug/xdebug.c (version: 1.306)
           xdebug/xdebug_handler_dbgp.c (version: 1.85)
           xdebug/xdebug_handlers.h (version: 1.33)

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.305
retrieving revision 1.306
diff -u -r1.305 -r1.306
--- xdebug/xdebug.c:1.305 Fri Mar 10 11:10:26 2006 GMT
+++ xdebug/xdebug.c Tue Mar 14 20:20:48 2006 GMT
@@ -1785,6 +1785,8 @@
 {
         zval *message, *file, *line;
         zend_class_entry *default_ce, *exception_ce;
+ xdebug_brk_info *extra_brk_info;
+ int do_exception = 0;
 
         if (!exception) {
                 return;
@@ -1804,9 +1806,17 @@
         if (XG(show_ex_trace)) {
                 print_stack(!(strcmp("cli", sapi_module.name) == 0), exception_ce->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line), !PG(display_errors) TSRMLS_CC);
         }
+
+ /* Check if we have a breakpoint on this exception */
         
+ if (xdebug_hash_find(XG(context).exception_breakpoints, exception_ce->name, strlen(exception_ce->name), (void *) &extra_brk_info)) {
+ if (handle_hit_value(extra_brk_info)) {
+ do_exception = 1;
+ }
+ }
+
         /* Start JIT if requested and not yet enabled */
- if (XG(remote_enable) && (XG(remote_mode) == XDEBUG_JIT) && !XG(remote_enabled)) {
+ if (do_exception && !XG(remote_enabled) && XG(remote_enable) && (XG(remote_mode) == XDEBUG_JIT)) {
                 XG(context).socket = xdebug_create_socket(XG(remote_host), XG(remote_port));
                 if (XG(context).socket >= 0) {
                         XG(remote_enabled) = 1;
@@ -1817,12 +1827,10 @@
                         XG(context).handler->remote_init(&(XG(context)), XDEBUG_JIT);
                 }
         }
- if (XG(remote_enabled)) {
-
+ if (do_exception && XG(remote_enabled)) {
                 if (!XG(context).handler->remote_error(&(XG(context)), 0, exception_ce->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line), XG(stack))) {
                         XG(remote_enabled) = 0;
                 }
-
         }
 }
 
@@ -1874,25 +1882,6 @@
         }
         xdfree(error_type_str);
 
- if (EG(error_reporting) & type) {
- /* Start JIT if requested and not yet enabled */
- if (XG(remote_enable) && (XG(remote_mode) == XDEBUG_JIT) && !XG(remote_enabled)) {
- XG(context).socket = xdebug_create_socket(XG(remote_host), XG(remote_port));
- if (XG(context).socket >= 0) {
- XG(remote_enabled) = 1;
- XG(context).program_name = NULL;
-
- /* Get handler from mode */
- XG(context).handler = xdebug_handler_get(XG(remote_handler));
- XG(context).handler->remote_init(&(XG(context)), XDEBUG_JIT);
- }
- }
- if (XG(remote_enabled)) {
- if (!XG(context).handler->remote_error(&(XG(context)), type, NULL, buffer, error_filename, error_lineno, XG(stack))) {
- XG(remote_enabled) = 0;
- }
- }
- }
         efree(buffer);
 
         /* Bail out if we can't recover */
@@ -2630,7 +2619,7 @@
                                                 /* Restore error reporting level */
                                                 EG(error_reporting) = old_error_reporting;
                                         }
- if (break_ok) {
+ if (break_ok && handle_hit_value(brk)) {
                                                 if (!XG(context).handler->remote_breakpoint(&(XG(context)), XG(stack), file, lineno, XDEBUG_BREAK)) {
                                                         XG(remote_enabled) = 0;
                                                         break;

[FILE: /xdebug/xdebug_handler_dbgp.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- xdebug/xdebug_handler_dbgp.c:1.84 Thu Mar 09 20:32:44 2006 GMT
+++ xdebug/xdebug_handler_dbgp.c Tue Mar 14 20:20:48 2006 GMT
@@ -800,6 +800,12 @@
                                 return brk;
                         }
                         break;
+
+ case BREAKPOINT_TYPE_EXCEPTION:
+ if (xdebug_hash_find(XG(context).exception_breakpoints, hkey, strlen(hkey), (void *) &brk)) {
+ return brk;
+ }
+ break;
         }
         return brk;
 }
@@ -843,6 +849,12 @@
                                 return SUCCESS;
                         }
                         break;
+
+ case BREAKPOINT_TYPE_EXCEPTION:
+ if (xdebug_hash_delete(XG(context).exception_breakpoints, hkey, strlen(hkey))) {
+ return SUCCESS;
+ }
+ break;
         }
         return FAILURE;
 }
@@ -974,6 +986,7 @@
         xdebug_brk_info *brk_info;
         char *tmp_name;
         int brk_id = 0;
+ int new_length = 0;
         function_stack_entry *fse;
         XDEBUG_STR_SWITCH_DECL;
 
@@ -984,6 +997,7 @@
         brk_info->classname = NULL;
         brk_info->functionname = NULL;
         brk_info->function_break_type = 0;
+ brk_info->exceptionname = NULL;
         brk_info->condition = NULL;
         brk_info->disabled = 0;
         brk_info->temporary = 0;
@@ -1012,6 +1026,7 @@
                 }
                 brk_info->lineno = strtol(CMD_OPTION('n'), NULL, 10);
 
+ /* If no filename is given, we use the current one */
                 if (!CMD_OPTION('f')) {
                         fse = xdebug_get_stack_tail(TSRMLS_C);
                         if (!fse) {
@@ -1025,6 +1040,11 @@
                         brk_info->file_len = strlen(brk_info->file);
                 }
 
+ /* Perhaps we have a break condition */
+ if (CMD_OPTION('-')) {
+ brk_info->condition = xdebug_base64_decode(CMD_OPTION('-'), strlen(CMD_OPTION('-')), &new_length);
+ }
+
                 tmp_name = xdebug_sprintf("%s$%lu", brk_info->file, brk_info->lineno);
                 brk_id = breakpoint_admin_add(context, BREAKPOINT_TYPE_LINE, tmp_name);
                 xdfree(tmp_name);
@@ -1068,7 +1088,19 @@
         } else
 
         if (strcmp(CMD_OPTION('t'), "exception") == 0) {
+#if PHP_MAJOR_VERSION >= 5
+ if (!CMD_OPTION('x')) {
+ RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_INVALID_ARGS);
+ }
+ brk_info->exceptionname = xdstrdup(CMD_OPTION('x'));
+ if (!xdebug_hash_add(context->exception_breakpoints, CMD_OPTION('x'), strlen(CMD_OPTION('x')), (void*) brk_info)) {
+ RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_BREAKPOINT_NOT_SET);
+ } else {
+ brk_id = breakpoint_admin_add(context, BREAKPOINT_TYPE_EXCEPTION, CMD_OPTION('x'));
+ }
+#else
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_BREAKPOINT_TYPE_NOT_SUPPORTED);
+#endif
         } else
 
         if (strcmp(CMD_OPTION('t'), "watch") == 0) {
@@ -2029,7 +2061,7 @@
 
 char *xdebug_dbgp_get_revision(void)
 {
- return "$Revision: 1.84 $";
+ return "$Revision: 1.85 $";
 }
 
 int xdebug_dbgp_cmdloop(xdebug_con *context TSRMLS_DC)
@@ -2145,6 +2177,7 @@
 
         context->breakpoint_list = xdebug_hash_alloc(64, (xdebug_hash_dtor) xdebug_hash_admin_dtor);
         context->function_breakpoints = xdebug_hash_alloc(64, (xdebug_hash_dtor) xdebug_hash_brk_dtor);
+ context->exception_breakpoints = xdebug_hash_alloc(64, (xdebug_hash_dtor) xdebug_hash_brk_dtor);
         context->class_breakpoints = xdebug_hash_alloc(64, (xdebug_hash_dtor) xdebug_hash_brk_dtor);
         context->line_breakpoints = xdebug_llist_alloc((xdebug_llist_dtor) xdebug_llist_brk_dtor);
         context->eval_id_lookup = xdebug_hash_alloc(64, (xdebug_hash_dtor) xdebug_hash_eval_info_dtor);
@@ -2188,6 +2221,7 @@
         xdfree(options->runtime);
         xdfree(context->options);
         xdebug_hash_destroy(context->function_breakpoints);
+ xdebug_hash_destroy(context->exception_breakpoints);
         xdebug_hash_destroy(context->class_breakpoints);
         xdebug_hash_destroy(context->eval_id_lookup);
         xdebug_llist_destroy(context->line_breakpoints, NULL);

[FILE: /xdebug/xdebug_handlers.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- xdebug/xdebug_handlers.h:1.32 Tue Feb 21 19:43:17 2006 GMT
+++ xdebug/xdebug_handlers.h Tue Mar 14 20:20:48 2006 GMT
@@ -39,9 +39,10 @@
         int last_line;
 };
 
-#define BREAKPOINT_TYPE_LINE 1
-#define BREAKPOINT_TYPE_FUNCTION 2
-#define BREAKPOINT_TYPE_METHOD 3
+#define BREAKPOINT_TYPE_LINE 1
+#define BREAKPOINT_TYPE_FUNCTION 2
+#define BREAKPOINT_TYPE_METHOD 3
+#define BREAKPOINT_TYPE_EXCEPTION 4
 
 struct _xdebug_brk_admin {
         int id;
@@ -61,6 +62,7 @@
         xdebug_hash *eval_id_lookup;
         int eval_id_sequence;
         xdebug_llist *line_breakpoints;
+ xdebug_llist *exception_breakpoints;
         xdebug_debug_list list;
         int do_break;
 
@@ -82,6 +84,7 @@
         char *type;
         char *classname;
         char *functionname;
+ char *exceptionname;
         int function_break_type; /* XDEBUG_BRK_FUNC_* */
         char *file;
         int file_len;
Received on Tue Mar 14 2006 - 22:23:38 GMT

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