gdb/gdb-archer-pie-addons-keep-...

123 lines
3.8 KiB
Diff
Raw Normal View History

2010-01-12 22:15:57 +00:00
--- ./gdb/breakpoint.c 2009-12-18 00:13:49.000000000 +0100
+++ ./gdb/breakpoint.c 2009-12-18 00:13:16.000000000 +0100
@@ -8563,6 +8563,49 @@ update_breakpoint_locations (struct brea
update_global_location_list (1);
}
+void
+breakpoints_relocate (struct objfile *objfile, struct section_offsets *delta)
+{
+ struct bp_location *bl, **blp_tmp;
+ int changed = 0;
+
+ gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
+
+ ALL_BP_LOCATIONS (bl, blp_tmp)
+ {
+ struct obj_section *osect;
+
+ /* BL->SECTION can be correctly NULL for breakpoints with multiple
+ locations expanded through symtab. */
+
+ ALL_OBJFILE_OSECTIONS (objfile, osect)
+ {
+ CORE_ADDR relocated_address;
+ CORE_ADDR delta_offset;
+
+ delta_offset = ANOFFSET (delta, osect->the_bfd_section->index);
+ if (delta_offset == 0)
+ continue;
+ relocated_address = bl->address + delta_offset;
+
+ if (obj_section_addr (osect) <= relocated_address
+ && relocated_address < obj_section_endaddr (osect))
+ {
+ if (bl->inserted)
+ remove_breakpoint (bl, mark_uninserted);
+
+ bl->address += delta_offset;
+ bl->requested_address += delta_offset;
+
+ changed = 1;
+ }
+ }
+ }
+
+ if (changed)
+ qsort (bp_location, bp_location_count, sizeof (*bp_location),
+ bp_location_compare_for_qsort);
+}
/* Reset a breakpoint given it's struct breakpoint * BINT.
The value we return ends up being the return value from catch_errors.
--- ./gdb/breakpoint.h 2009-12-18 00:13:48.000000000 +0100
+++ ./gdb/breakpoint.h 2009-12-17 22:11:10.000000000 +0100
@@ -970,4 +970,7 @@ extern struct breakpoint *get_tracepoint
is newly allocated; the caller should free when done with it. */
extern VEC(breakpoint_p) *all_tracepoints (void);
+extern void breakpoints_relocate (struct objfile *objfile,
+ struct section_offsets *delta);
+
#endif /* !defined (BREAKPOINT_H) */
--- ./gdb/objfiles.c 2009-12-18 00:13:48.000000000 +0100
+++ ./gdb/objfiles.c 2009-12-17 23:19:22.000000000 +0100
@@ -546,7 +546,7 @@ free_all_objfiles (void)
/* Relocate OBJFILE to NEW_OFFSETS. There should be OBJFILE->NUM_SECTIONS
entries in new_offsets. SEPARATE_DEBUG_OBJFILE is not touched here. */
-static void
+static int
objfile_relocate1 (struct objfile *objfile, struct section_offsets *new_offsets)
{
struct obj_section *s;
@@ -565,7 +565,7 @@ objfile_relocate1 (struct objfile *objfi
something_changed = 1;
}
if (!something_changed)
- return;
+ return 0;
}
/* OK, get all the symtabs. */
@@ -706,6 +706,13 @@ objfile_relocate1 (struct objfile *objfi
exec_set_section_address (bfd_get_filename (objfile->obfd), idx,
obj_section_addr (s));
}
+
+ /* Final call of breakpoint_re_set can keep breakpoint locations disabled if
+ their addresses match. */
+ if (objfile->separate_debug_objfile_backlink == NULL)
+ breakpoints_relocate (objfile, delta);
+
+ return 1;
}
/* Relocate OBJFILE to NEW_OFFSETS. There should be OBJFILE->NUM_SECTIONS
@@ -720,7 +727,9 @@ objfile_relocate1 (struct objfile *objfi
void
objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets)
{
- objfile_relocate1 (objfile, new_offsets);
+ int changed = 0;
+
+ changed |= objfile_relocate1 (objfile, new_offsets);
if (objfile->separate_debug_objfile != NULL)
{
@@ -747,11 +756,12 @@ objfile_relocate (struct objfile *objfil
objfile_addrs);
do_cleanups (my_cleanups);
- objfile_relocate1 (debug_objfile, new_debug_offsets);
+ changed |= objfile_relocate1 (debug_objfile, new_debug_offsets);
}
/* Relocate breakpoints as necessary, after things are relocated. */
- breakpoint_re_set ();
+ if (changed)
+ breakpoint_re_set ();
}
/* Return non-zero if OBJFILE has partial symbols. */