[patch 1/3] Clear stale specific locs, not whole bpts

Jan Kratochvil jan.kratochvil@redhat.com
Mon May 3 20:02:00 GMT 2010


Hi,

while I do not have a reproducer of a bug I believe this is a right cleanup as
currently after update_breakpoint_locations thread_info->stop_bpstat may
contain stale bp_location references.  Just the current code never
dereferences such stale reference.

As the new handle_inferior_event code can execute multiple actions where the
preceding ones can call update_breakpoint_locations I have found this fixups
as required for this patchset.


Thanks,
Jan


gdb/
2010-05-03  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Clear stale specific bp_location from former whole breakpoint.
	* breakpoint.c (delete_breakpoint): Move the stale referencing clear
	code ...
	(free_bp_location): ... here.  Rename there the called function to
	bpstat_remove_bp_location_callback.
	(bpstat_remove_breakpoint_callback): Rename to ...
	(bpstat_remove_bp_location_callback): ... here, change DATA resolution
	to struct bp_location.  Change the called function to
	bpstat_remove_bp_location.  Create new declaration for the function.
	(bpstat_remove_breakpoint): Rename to ...
	(bpstat_remove_bp_location): ..., change the parameter to loc, adjust
	code for the new parameter type.

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -206,6 +206,9 @@ static void update_global_location_list (int);
 
 static void update_global_location_list_nothrow (int);
 
+static int bpstat_remove_bp_location_callback (struct thread_info *th,
+					       void *data);
+
 static int is_hardware_watchpoint (const struct breakpoint *bpt);
 
 static int is_watchpoint (const struct breakpoint *bpt);
@@ -5377,6 +5380,18 @@ allocate_bp_location (struct breakpoint *bpt)
 
 static void free_bp_location (struct bp_location *loc)
 {
+  /* Be sure no bpstat's are pointing at it after it's been freed.  */
+  /* FIXME, how can we find all bpstat's?
+     We just check stop_bpstat for now.  Note that we cannot just
+     remove bpstats pointing at bpt from the stop_bpstat list
+     entirely, as breakpoint commands are associated with the bpstat;
+     if we remove it here, then the later call to
+         bpstat_do_actions (&stop_bpstat);
+     in event-top.c won't do anything, and temporary breakpoints
+     with commands won't work.  */
+
+  iterate_over_threads (bpstat_remove_bp_location_callback, loc);
+
   if (loc->cond)
     xfree (loc->cond);
 
@@ -9208,13 +9223,13 @@ update_global_location_list_nothrow (int inserting)
     update_global_location_list (inserting);
 }
 
-/* Clear BPT from a BPS.  */
+/* Clear LOC from a BPS.  */
 static void
-bpstat_remove_breakpoint (bpstat bps, struct breakpoint *bpt)
+bpstat_remove_bp_location (bpstat bps, struct bp_location *loc)
 {
   bpstat bs;
   for (bs = bps; bs; bs = bs->next)
-    if (bs->breakpoint_at && bs->breakpoint_at->owner == bpt)
+    if (bs->breakpoint_at == loc)
       {
 	bs->breakpoint_at = NULL;
 	bs->old_val = NULL;
@@ -9224,10 +9239,11 @@ bpstat_remove_breakpoint (bpstat bps, struct breakpoint *bpt)
 
 /* Callback for iterate_over_threads.  */
 static int
-bpstat_remove_breakpoint_callback (struct thread_info *th, void *data)
+bpstat_remove_bp_location_callback (struct thread_info *th, void *data)
 {
-  struct breakpoint *bpt = data;
-  bpstat_remove_breakpoint (th->stop_bpstat, bpt);
+  struct bp_location *loc = data;
+
+  bpstat_remove_bp_location (th->stop_bpstat, loc);
   return 0;
 }
 
@@ -9291,18 +9307,6 @@ delete_breakpoint (struct breakpoint *bpt)
   xfree (bpt->exec_pathname);
   clean_up_filters (&bpt->syscalls_to_be_caught);
 
-  /* Be sure no bpstat's are pointing at it after it's been freed.  */
-  /* FIXME, how can we find all bpstat's?
-     We just check stop_bpstat for now.  Note that we cannot just
-     remove bpstats pointing at bpt from the stop_bpstat list
-     entirely, as breakpoint commands are associated with the bpstat;
-     if we remove it here, then the later call to
-         bpstat_do_actions (&stop_bpstat);
-     in event-top.c won't do anything, and temporary breakpoints
-     with commands won't work.  */
-
-  iterate_over_threads (bpstat_remove_breakpoint_callback, bpt);
-
   /* Now that breakpoint is removed from breakpoint
      list, update the global location list.  This
      will remove locations that used to belong to



More information about the Gdb-patches mailing list