This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA]: breakpoint.c patch (prelude to pending breakpoint support)


The following is a patch to centralize the test for an active-enabled breakpoint. This patch is in response to Daniel J's comments to split up the pending-breakpoint support patch. With pending breakpoint support, the test will be modified to include a check for a pending breakpoint. This will simplify reviewing the last of the patches required for pending-breakpoint support.

Ok to commit?

-- Jeff J.

2003-12-10 Jeff Johnston <jjohnstn@redhat.com>

* breakpoint.c (breakpoint_enabled): New function to test whether breakpoint is
active and enabled.
( insert_bp_location, insert_breakpoints): Call new function to test
for enabled breakpoint.
(remove_breakpoint, breakpoint_here_p): Ditto.
(breakpoint_thread_match): Ditto.
(bpstat_should_step, bpstat_have_active_hw_watchpoints): Ditto.
(disable_breakpoints_in_shlibs): Ditto.
(hw_watchpoint_used_count): Ditto.
(disable_watchpoints_before_interactive_call_start): Ditto.
(breakpoint_re_set_one): Ditto.
(bpstat_stop_status): Use new function and simplify test.


Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.145
diff -u -p -r1.145 breakpoint.c
--- breakpoint.c	17 Nov 2003 00:55:49 -0000	1.145
+++ breakpoint.c	10 Dec 2003 21:53:31 -0000
@@ -332,6 +332,13 @@ int exception_support_initialized = 0;
    error ("catch of library unloads not yet implemented on this platform")
 #endif
 
+/* Return whether a breakpoint is an active enabled breakpoint.  */
+static int
+breakpoint_enabled (struct breakpoint *b)
+{
+  return b->enable_state == bp_enabled;
+}
+
 /* Set breakpoint count to NUM.  */
 
 void
@@ -757,7 +764,7 @@ insert_bp_location (struct bp_location *
 
   /* Permanent breakpoints cannot be inserted or removed.  Disabled
      breakpoints should not be inserted.  */
-  if (bpt->owner->enable_state != bp_enabled)
+  if (!breakpoint_enabled (bpt->owner))
     return 0;
 
   if (bpt->inserted || bpt->duplicate)
@@ -1107,7 +1114,7 @@ insert_breakpoints (void)
     {
       /* Permanent breakpoints cannot be inserted or removed.  Disabled
 	 breakpoints should not be inserted.  */
-      if (b->owner->enable_state != bp_enabled)
+      if (!breakpoint_enabled (b->owner))
 	continue;
 
       /* FIXME drow/2003-10-07: This code should be pushed elsewhere when
@@ -1457,7 +1464,7 @@ remove_breakpoint (struct bp_location *b
       b->inserted = (is == mark_inserted);
     }
   else if (b->loc_type == bp_loc_hardware_watchpoint
-	   && b->owner->enable_state == bp_enabled
+	   && breakpoint_enabled (b->owner)
 	   && !b->duplicate)
     {
       struct value *v;
@@ -1513,7 +1520,7 @@ remove_breakpoint (struct bp_location *b
   else if ((b->owner->type == bp_catch_fork ||
 	    b->owner->type == bp_catch_vfork ||
 	    b->owner->type == bp_catch_exec)
-	   && b->owner->enable_state == bp_enabled
+	   && breakpoint_enabled (b->owner)
 	   && !b->duplicate)
     {
       val = -1;
@@ -1538,7 +1545,7 @@ remove_breakpoint (struct bp_location *b
     }
   else if ((b->owner->type == bp_catch_catch ||
 	    b->owner->type == bp_catch_throw)
-	   && b->owner->enable_state == bp_enabled
+	   && breakpoint_enabled (b->owner)
 	   && !b->duplicate)
     {
 
@@ -1549,7 +1556,7 @@ remove_breakpoint (struct bp_location *b
     }
   else if (ep_is_exception_catchpoint (b->owner)
 	   && b->inserted	/* sometimes previous insert doesn't happen */
-	   && b->owner->enable_state == bp_enabled
+	   && breakpoint_enabled (b->owner)
 	   && !b->duplicate)
     {
 
@@ -1675,7 +1682,7 @@ breakpoint_here_p (CORE_ADDR pc)
 	  && bpt->loc_type != bp_loc_hardware_breakpoint)
 	continue;
 
-      if ((bpt->owner->enable_state == bp_enabled
+      if ((breakpoint_enabled (bpt->owner)
 	   || bpt->owner->enable_state == bp_permanent)
 	  && bpt->address == pc)	/* bp is enabled and matches pc */
 	{
@@ -1772,7 +1779,7 @@ breakpoint_thread_match (CORE_ADDR pc, p
 	  && bpt->loc_type != bp_loc_hardware_breakpoint)
 	continue;
 
-      if ((bpt->owner->enable_state == bp_enabled
+      if ((breakpoint_enabled (bpt->owner)
 	   || bpt->owner->enable_state == bp_permanent)
 	  && bpt->address == pc
 	  && (bpt->owner->thread == -1 || bpt->owner->thread == thread))
@@ -2574,9 +2581,7 @@ bpstat_stop_status (CORE_ADDR *pc, int n
 
   ALL_BREAKPOINTS_SAFE (b, temp)
   {
-    if (b->enable_state == bp_disabled
-	|| b->enable_state == bp_shlib_disabled
-	|| b->enable_state == bp_call_disabled)
+    if (!breakpoint_enabled (b) && b->enable_state != bp_permanent)
       continue;
 
     if (b->type != bp_watchpoint
@@ -3179,7 +3184,7 @@ bpstat_should_step (void)
 {
   struct breakpoint *b;
   ALL_BREAKPOINTS (b)
-    if (b->enable_state == bp_enabled && b->type == bp_watchpoint)
+    if (breakpoint_enabled (b) && b->type == bp_watchpoint)
       return 1;
   return 0;
 }
@@ -3190,7 +3195,7 @@ bpstat_have_active_hw_watchpoints (void)
 {
   struct bp_location *bpt;
   ALL_BP_LOCATIONS (bpt)
-    if ((bpt->owner->enable_state == bp_enabled)
+    if (breakpoint_enabled (bpt->owner)
 	&& bpt->inserted
 	&& bpt->loc_type == bp_loc_hardware_watchpoint)
       return 1;
@@ -4268,7 +4273,7 @@ disable_breakpoints_in_shlibs (int silen
 #if defined (PC_SOLIB)
     if (((b->type == bp_breakpoint) ||
 	 (b->type == bp_hardware_breakpoint)) &&
-	b->enable_state == bp_enabled &&
+	breakpoint_enabled (b) &&
 	!b->loc->duplicate &&
 	PC_SOLIB (b->loc->address))
       {
@@ -4491,14 +4496,13 @@ hw_watchpoint_used_count (enum bptype ty
   *other_type_used = 0;
   ALL_BREAKPOINTS (b)
   {
-    if (b->enable_state == bp_enabled)
+    if (breakpoint_enabled (b))
       {
 	if (b->type == type)
 	  i++;
 	else if ((b->type == bp_hardware_watchpoint ||
 		  b->type == bp_read_watchpoint ||
-		  b->type == bp_access_watchpoint)
-		 && b->enable_state == bp_enabled)
+		  b->type == bp_access_watchpoint))
 	  *other_type_used = 1;
       }
   }
@@ -4540,7 +4544,7 @@ disable_watchpoints_before_interactive_c
 	 || (b->type == bp_read_watchpoint)
 	 || (b->type == bp_access_watchpoint)
 	 || ep_is_exception_catchpoint (b))
-	&& (b->enable_state == bp_enabled))
+	&& breakpoint_enabled (b))
       {
 	b->enable_state = bp_call_disabled;
 	check_duplicates (b);
@@ -7063,7 +7067,7 @@ breakpoint_re_set_one (void *bint)
 	value_free (b->val);
       b->val = evaluate_expression (b->exp);
       release_value (b->val);
-      if (VALUE_LAZY (b->val) && b->enable_state == bp_enabled)
+      if (VALUE_LAZY (b->val) && breakpoint_enabled (b))
 	value_fetch_lazy (b->val);
 
       if (b->cond_string != NULL)
@@ -7073,7 +7077,7 @@ breakpoint_re_set_one (void *bint)
 	    xfree (b->cond);
 	  b->cond = parse_exp_1 (&s, (struct block *) 0, 0);
 	}
-      if (b->enable_state == bp_enabled)
+      if (breakpoint_enabled (b))
 	mention (b);
       value_free_to_mark (mark);
       break;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]