Blob Blame History Raw
diff -Naurp insight-10.0.50.20200110.orig/gdb/breakpoint.c insight-10.0.50.20200110.new/gdb/breakpoint.c
--- insight-10.0.50.20200110.orig/gdb/breakpoint.c	2020-02-07 00:46:03.000000000 +0100
+++ insight-10.0.50.20200110.new/gdb/breakpoint.c	2020-02-07 13:55:38.047020009 +0100
@@ -15397,6 +15397,51 @@ static struct cmd_list_element *enablebr
 cmd_list_element *commands_cmd_element = nullptr;
 
 void
+breakpoints_relocate (struct objfile *objfile, const 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 = 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);
+
+	      bl->address += delta_offset;
+	      bl->requested_address += delta_offset;
+
+	      changed = 1;
+	    }
+	}
+    }
+
+  if (changed)
+    std::sort (bp_locations, bp_locations + bp_locations_count,
+	       bp_location_is_less_than);
+}
+
+void _initialize_breakpoint (void);
+void
 _initialize_breakpoint (void)
 {
   struct cmd_list_element *c;
diff -Naurp insight-10.0.50.20200110.orig/gdb/breakpoint.h insight-10.0.50.20200110.new/gdb/breakpoint.h
--- insight-10.0.50.20200110.orig/gdb/breakpoint.h	2020-01-03 10:42:10.000000000 +0100
+++ insight-10.0.50.20200110.new/gdb/breakpoint.h	2020-02-07 13:55:18.987856186 +0100
@@ -1696,6 +1696,9 @@ extern const char *ep_parse_optional_if_
    UIOUT iff debugging multiple threads.  */
 extern void maybe_print_thread_hit_breakpoint (struct ui_out *uiout);
 
+extern void breakpoints_relocate (struct objfile *objfile,
+				  const section_offsets &delta);
+
 /* Print the specified breakpoint.  */
 extern void print_breakpoint (breakpoint *bp);
 
diff -Naurp insight-10.0.50.20200110.orig/gdb/objfiles.c insight-10.0.50.20200110.new/gdb/objfiles.c
--- insight-10.0.50.20200110.orig/gdb/objfiles.c	2020-01-10 12:05:27.000000000 +0100
+++ insight-10.0.50.20200110.new/gdb/objfiles.c	2020-02-07 12:57:58.277501554 +0100
@@ -750,6 +750,11 @@ objfile_relocate1 (struct objfile *objfi
 				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);
+
   /* Data changed.  */
   return 1;
 }