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

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