[xdebug-dev] xdebug xdebug/xdebug.c xdebug/xdebug_handler_dbgp.c - DBGp: Implemented support for hit conditions for breakpoints.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Thu, 9 Mar 2006 22:32:44 +0100

Date: Thu Mar 9 22:32:44 CET 2006
User: Derick Rethans
Directory: xdebug

Log Message:
[1.50]
- DBGp: Implemented support for hit conditions for breakpoints.

Modified files:
           xdebug/xdebug.c (version: 1.304)
           xdebug/xdebug_handler_dbgp.c (version: 1.84)

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.303
retrieving revision 1.304
diff -u -r1.303 -r1.304
--- xdebug/xdebug.c:1.303 Thu Mar 09 12:06:20 2006 GMT
+++ xdebug/xdebug.c Thu Mar 09 20:32:44 2006 GMT
@@ -1112,6 +1112,39 @@
         }
 }
 
+static int handle_hit_value(xdebug_brk_info *brk_info)
+{
+ /* Increase hit counter */
+ brk_info->hit_count++;
+
+ /* If the hit_value is 0, the condition check is disabled */
+ if (!brk_info->hit_value) {
+ return 1;
+ }
+
+ switch (brk_info->hit_condition) {
+ case XDEBUG_HIT_GREATER_EQUAL:
+ if (brk_info->hit_count >= brk_info->hit_value) {
+ return 1;
+ }
+ break;
+ case XDEBUG_HIT_EQUAL:
+ if (brk_info->hit_count == brk_info->hit_value) {
+ return 1;
+ }
+ break;
+ case XDEBUG_HIT_MOD:
+ if (brk_info->hit_count % brk_info->hit_value == 0) {
+ return 1;
+ }
+ break;
+ case XDEBUG_HIT_DISABLED:
+ return 1;
+ break;
+ }
+ return 0;
+}
+
 static int handle_breakpoints(function_stack_entry *fse, int breakpoint_type)
 {
         xdebug_brk_info *extra_brk_info = NULL;
@@ -1122,15 +1155,16 @@
         if (fse->function.type == XFUNC_NORMAL) {
                 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*/
+ * disabled AND handle_hit_value is happy */
                         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;
+ if (handle_hit_value(extra_brk_info)) {
+ 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)) {
+ return 0;
+ }
+ } else {
+ XG(context).do_break = 1;
                                         }
- } else {
- XG(context).do_break = 1;
                                 }
                         }
                 }
@@ -1141,9 +1175,11 @@
 
                 if (xdebug_hash_find(XG(context).class_breakpoints, tmp_name, strlen(tmp_name), (void *) &extra_brk_info)) {
                         /* Yup, breakpoint found, call handler if the breakpoint is not
- * disabled */
+ * disabled AND handle_hit_value is happy */
                         if (!extra_brk_info->disabled) {
- XG(context).do_break = 1;
+ if (handle_hit_value(extra_brk_info)) {
+ XG(context).do_break = 1;
+ }
                         }
                 }
                 xdfree(tmp_name);

[FILE: /xdebug/xdebug_handler_dbgp.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- xdebug/xdebug_handler_dbgp.c:1.83 Tue Feb 21 20:25:21 2006 GMT
+++ xdebug/xdebug_handler_dbgp.c Thu Mar 09 20:32:44 2006 GMT
@@ -745,6 +745,19 @@
         } else {
                 xdebug_xml_add_attribute(xml, "state", "enabled");
         }
+ xdebug_xml_add_attribute_ex(xml, "hit_count", xdebug_sprintf("%lu", brk->hit_count), 0, 1);
+ switch (brk->hit_condition) {
+ case XDEBUG_HIT_GREATER_EQUAL:
+ xdebug_xml_add_attribute(xml, "hit_condition", ">=");
+ break;
+ case XDEBUG_HIT_EQUAL:
+ xdebug_xml_add_attribute(xml, "hit_condition", "==");
+ break;
+ case XDEBUG_HIT_MOD:
+ xdebug_xml_add_attribute(xml, "hit_condition", "%");
+ break;
+ }
+ xdebug_xml_add_attribute_ex(xml, "hit_value", xdebug_sprintf("%lu", brk->hit_value), 0, 1);
 }
 
 static xdebug_brk_info* breakpoint_brk_info_fetch(int type, char *hkey)
@@ -2016,7 +2029,7 @@
 
 char *xdebug_dbgp_get_revision(void)
 {
- return "$Revision: 1.83 $";
+ return "$Revision: 1.84 $";
 }
 
 int xdebug_dbgp_cmdloop(xdebug_con *context TSRMLS_DC)
@@ -2249,12 +2262,9 @@
 
 int xdebug_dbgp_breakpoint(xdebug_con *context, xdebug_llist *stack, char *file, long lineno, int type)
 {
- function_stack_entry *i;
         xdebug_xml_node *response;
         TSRMLS_FETCH();
 
- i = xdebug_get_stack_tail(TSRMLS_C);
-
         XG(status) = DBGP_STATUS_BREAK;
         XG(reason) = DBGP_REASON_OK;
 
Received on Thu Mar 09 2006 - 22:32:51 GMT

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