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

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