Blame SOURCES/gdb-archer-pie-addons-keep-disabled.patch

190f2a
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
190f2a
From: Fedora GDB patches <invalid@email.com>
190f2a
Date: Fri, 27 Oct 2017 21:07:50 +0200
190f2a
Subject: gdb-archer-pie-addons-keep-disabled.patch
190f2a
190f2a
;;=push+jan: Breakpoints disabling matching should not be based on address.
190f2a
190f2a
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
190f2a
--- a/gdb/breakpoint.c
190f2a
+++ b/gdb/breakpoint.c
190f2a
@@ -15522,6 +15522,50 @@ initialize_breakpoint_ops (void)
190f2a
 
190f2a
 static struct cmd_list_element *enablebreaklist = NULL;
190f2a
 
190f2a
+void
190f2a
+breakpoints_relocate (struct objfile *objfile, struct section_offsets *delta)
190f2a
+{
190f2a
+  struct bp_location *bl, **blp_tmp;
190f2a
+  int changed = 0;
190f2a
+
190f2a
+  gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
190f2a
+
190f2a
+  ALL_BP_LOCATIONS (bl, blp_tmp)
190f2a
+    {
190f2a
+      struct obj_section *osect;
190f2a
+
190f2a
+      /* BL->SECTION can be correctly NULL for breakpoints with multiple
190f2a
+         locations expanded through symtab.  */
190f2a
+
190f2a
+      ALL_OBJFILE_OSECTIONS (objfile, osect)
190f2a
+	{
190f2a
+	  CORE_ADDR relocated_address;
190f2a
+	  CORE_ADDR delta_offset;
190f2a
+
190f2a
+	  delta_offset = ANOFFSET (delta, osect->the_bfd_section->index);
190f2a
+	  if (delta_offset == 0)
190f2a
+	    continue;
190f2a
+	  relocated_address = bl->address + delta_offset;
190f2a
+
190f2a
+	  if (obj_section_addr (osect) <= relocated_address
190f2a
+	      && relocated_address < obj_section_endaddr (osect))
190f2a
+	    {
190f2a
+	      if (bl->inserted)
190f2a
+		remove_breakpoint (bl);
190f2a
+
190f2a
+	      bl->address += delta_offset;
190f2a
+	      bl->requested_address += delta_offset;
190f2a
+
190f2a
+	      changed = 1;
190f2a
+	    }
190f2a
+	}
190f2a
+    }
190f2a
+
190f2a
+  if (changed)
190f2a
+    qsort (bp_locations, bp_locations_count, sizeof (*bp_locations),
190f2a
+	   bp_locations_compare);
190f2a
+}
190f2a
+
190f2a
 void
190f2a
 _initialize_breakpoint (void)
190f2a
 {
190f2a
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
190f2a
--- a/gdb/breakpoint.h
190f2a
+++ b/gdb/breakpoint.h
190f2a
@@ -1679,6 +1679,9 @@ extern const char *ep_parse_optional_if_clause (const char **arg);
190f2a
    UIOUT iff debugging multiple threads.  */
190f2a
 extern void maybe_print_thread_hit_breakpoint (struct ui_out *uiout);
190f2a
 
190f2a
+extern void breakpoints_relocate (struct objfile *objfile,
190f2a
+				  struct section_offsets *delta);
190f2a
+
190f2a
 /* Print the specified breakpoint.  */
190f2a
 extern void print_breakpoint (breakpoint *bp);
190f2a
 
190f2a
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
190f2a
--- a/gdb/objfiles.c
190f2a
+++ b/gdb/objfiles.c
190f2a
@@ -883,6 +883,11 @@ objfile_relocate1 (struct objfile *objfile,
190f2a
 				obj_section_addr (s));
190f2a
     }
190f2a
 
190f2a
+  /* Final call of breakpoint_re_set can keep breakpoint locations disabled if
190f2a
+     their addresses match.  */
190f2a
+  if (objfile->separate_debug_objfile_backlink == NULL)
190f2a
+    breakpoints_relocate (objfile, delta);
190f2a
+
190f2a
   /* Data changed.  */
190f2a
   return 1;
190f2a
 }