[PATCH 3/5] scope ITSET break

Yao Qi yao@codesourcery.com
Tue Apr 2 14:12:00 GMT 2013


The 'target set' of command break can be called as 'trigger set',
because the 'target set' of break apply equals to the set breakpoint
can trigger.  Each breakpoint can get the reference of a 'target set'.

Note that we don't support 'stop set' described in HPD spec and
Pedro's original patch.

gdb:

2013-04-02  Pedro Alves  <pedro@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* breakpoint.c: Include "itset.h".
	(bpstat_check_trigger_set): New.
	(breakpoint_thread_match): Handle the trigger set.
	(bpstat_check_breakpoint_conditions): Handle the trigger set.
	(init_raw_breakpoint_without_location):  Initialize new
	field.
	(base_breakpoint_dtor):  Free the trigger set.
	* breakpoint.h (struct itset): Forward declare.
	(struct breakpoint) <trigger_set>: New field.
---
 gdb/breakpoint.c |   43 +++++++++++++++++++++++++++++++++++++------
 gdb/breakpoint.h |    4 ++++
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index c844187..4c6f295 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -32,6 +32,7 @@
 #include "value.h"
 #include "command.h"
 #include "inferior.h"
+#include "itset.h"
 #include "gdbthread.h"
 #include "target.h"
 #include "language.h"
@@ -3990,6 +3991,22 @@ hardware_watchpoint_inserted_in_range (struct address_space *aspace,
   return 0;
 }
 
+/* Test whether this stopping thread is in the I/T set for this
+   breakpoint.  */
+
+static int
+bpstat_check_trigger_set (const struct breakpoint *b,
+			  struct thread_info *thread)
+{
+  if (b->trigger_set == NULL)
+    return 1;
+
+  if (itset_contains_thread (b->trigger_set, thread))
+    return 1;
+
+  return 0;
+}
+
 /* breakpoint_thread_match (PC, PTID) returns true if the breakpoint at
    PC is valid for process/thread PTID.  */
 
@@ -3999,7 +4016,7 @@ breakpoint_thread_match (struct address_space *aspace, CORE_ADDR pc,
 {
   struct bp_location *bl, **blp_tmp;
   /* The thread and task IDs associated to PTID, computed lazily.  */
-  int thread = -1;
+  struct thread_info *thread = NULL;
   int task = 0;
   
   ALL_BP_LOCATIONS (bl, blp_tmp)
@@ -4021,9 +4038,9 @@ breakpoint_thread_match (struct address_space *aspace, CORE_ADDR pc,
 	  /* This is a thread-specific breakpoint.  Check that ptid
 	     matches that thread.  If thread hasn't been computed yet,
 	     it is now time to do so.  */
-	  if (thread == -1)
-	    thread = pid_to_thread_id (ptid);
-	  if (bl->owner->thread != thread)
+	  if (thread == NULL)
+	    thread = find_thread_ptid (ptid);
+	  if (bl->owner->thread != thread->num)
 	    continue;
 	}
 
@@ -4037,6 +4054,15 @@ breakpoint_thread_match (struct address_space *aspace, CORE_ADDR pc,
 	  if (bl->owner->task != task)
 	    continue;
         }
+      if (bl->owner->trigger_set != NULL)
+	{
+	  /* A breakpoint with a trigger itset.  Check that ptid
+	     matches that set.  */
+	  if (thread == NULL)
+	    thread = find_thread_ptid (ptid);
+	  if (!bpstat_check_trigger_set (bl->owner, thread))
+	    continue;
+	}
 
       if (overlay_debugging 
 	  && section_is_overlay (bl->section)
@@ -5022,7 +5048,7 @@ bpstat_check_watchpoint (bpstat bs)
 static void
 bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
 {
-  int thread_id = pid_to_thread_id (ptid);
+  struct thread_info *thread = find_thread_ptid (ptid);
   const struct bp_location *bl;
   struct breakpoint *b;
 
@@ -5128,10 +5154,13 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
 	{
 	  bs->stop = 0;
 	}
-      else if (b->thread != -1 && b->thread != thread_id)
+      else if (b->thread != -1 && b->thread != thread->num)
 	{
 	  bs->stop = 0;
 	}
+      else if (b->trigger_set != NULL
+	       && !bpstat_check_trigger_set (b, thread))
+	bs->stop = 0;
       else if (b->ignore_count > 0)
 	{
 	  b->ignore_count--;
@@ -6954,6 +6983,7 @@ init_raw_breakpoint_without_location (struct breakpoint *b,
   b->language = current_language->la_language;
   b->input_radix = input_radix;
   b->thread = -1;
+  b->trigger_set = itset_get_target_set_reference ();
   b->enable_state = bp_enabled;
   b->next = 0;
   b->silent = 0;
@@ -12792,6 +12822,7 @@ base_breakpoint_dtor (struct breakpoint *self)
   xfree (self->addr_string);
   xfree (self->filter);
   xfree (self->addr_string_range_end);
+  itset_free (self->trigger_set);
 }
 
 static struct bp_location *
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 68f3ed9..bfdfff8 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -34,6 +34,7 @@ struct bpstats;
 struct bp_location;
 struct linespec_result;
 struct linespec_sals;
+struct itset;
 
 /* This is the maximum number of bytes a breakpoint instruction can
    take.  Feel free to increase it.  It's just used in a few places to
@@ -745,6 +746,9 @@ struct breakpoint
        or 0 if don't care.  */
     int task;
 
+    /* I/T set controlling where this breakpoint will stop.  */
+    struct itset *trigger_set;
+
     /* Count of the number of times this breakpoint was taken, dumped
        with the info, but not used for anything else.  Useful for
        seeing how many times you hit a break prior to the program
-- 
1.7.7.6



More information about the Gdb-patches mailing list