[rfc] [07/18] Cell multi-arch: Preserve bp location info across objfile relocation

Ulrich Weigand uweigand@de.ibm.com
Sun Sep 7 21:14:00 GMT 2008


Hello,

this patch isn't strictly multi-arch related, but enhances the behaviour
of multi-location breakpoint in the presence of objfile relocation.

The problem is that breakpoint_re_set looks at addresses of breakpoints
to carry over the enabled/disabled state of breakpoint locations.

This doesn't work when objfiles are getting relocated.  This patch 
improves the situation by providing explicit information about
relocation to the breakpoint logic: objfile_relocate now calls a
routine breakpoint_relocate (instead of breakpoint_re_set), which
gets the list of objfile section deltas that an objfile was relocated by.

It then uses this information to update b->address of all (non-inserted)
breakpoints in the range covered by that objfile.  (For *inserted*
breakpoints this is difficult, as b->address need to match the address
where the target has inserted the breakpoint.  However, at the time an
objfile is relocated, breakpoints relating to this file should not be
inserted anyway!)

This patch isn't really a prerequisite for the multi-arch patches, but
it fixes a couple of test cases for SPU stand-alone applications.

Bye,
Ulrich


ChangeLog:

	* breakpoint.h (breakpoint_relocate): New.
	* breakpoint.c (breakpoint_relocate): New function.
	* objfiles.c (objfile_relocate): Call breakpoint_relocate
	instead of breakpoint_re_set.
	

Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c
+++ src/gdb/breakpoint.c
@@ -7680,6 +7680,37 @@ breakpoint_re_set (void)
   
   create_overlay_event_breakpoint ("_ovly_debug_event");
 }
+
+/* Update breakpoint location list after an object file was relocated.  */
+void
+breakpoint_relocate (struct objfile *objfile, struct section_offsets *delta)
+{
+  struct bp_location *b;
+  struct obj_section *s;
+
+  /* Update the breakpoint addresses so that breakpoint_re_set has a chance
+     to identify the previous locations (to carry over enabled state).  */
+  ALL_BP_LOCATIONS (b)
+    {
+      if (b->inserted || b->loc_type == bp_loc_other)
+	continue;
+
+      ALL_OBJFILE_OSECTIONS (objfile, s)
+	{
+	  CORE_ADDR offset = ANOFFSET (delta, s->the_bfd_section->index);
+
+	  if (b->address >= obj_section_addr (s) - offset
+	      && b->address < obj_section_endaddr (s) - offset)
+	    {
+	      b->address += offset;
+	      break;
+	    }
+	}
+    }
+
+  /* Now reset all breakpoints.  */
+  breakpoint_re_set ();
+}
 
 /* Reset the thread number of this breakpoint:
 
Index: src/gdb/breakpoint.h
===================================================================
--- src.orig/gdb/breakpoint.h
+++ src/gdb/breakpoint.h
@@ -689,6 +689,8 @@ extern int breakpoint_thread_match (CORE
 
 extern void until_break_command (char *, int, int);
 
+extern void breakpoint_relocate (struct objfile *, struct section_offsets *);
+
 extern void breakpoint_re_set (void);
 
 extern void breakpoint_re_set_thread (struct breakpoint *);
Index: src/gdb/objfiles.c
===================================================================
--- src.orig/gdb/objfiles.c
+++ src/gdb/objfiles.c
@@ -672,7 +672,7 @@ objfile_relocate (struct objfile *objfil
     }
 
   /* Relocate breakpoints as necessary, after things are relocated. */
-  breakpoint_re_set ();
+  breakpoint_relocate (objfile, delta);
 }
 
 /* Many places in gdb want to test just to see if we have any partial
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com



More information about the Gdb-patches mailing list