Blame SOURCES/gdb-rhbz1182151-ibm-z13-08of22.patch

2c2fa1
commit 5aa82d050d61784823767fe3c982b6862fa47391
2c2fa1
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
2c2fa1
Date:   Thu Sep 4 15:26:43 2014 +0000
2c2fa1
2c2fa1
    Replace 'core_regset_sections' by iterator method
2c2fa1
    
2c2fa1
    The core_regset_sections list in gdbarch (needed for multi-arch
2c2fa1
    capable core file generation support) is replaced by an iterator
2c2fa1
    method.  Overall, this reduces the code a bit, and it allows for more
2c2fa1
    flexibility.
2c2fa1
    
2c2fa1
    gdb/ChangeLog:
2c2fa1
    
2c2fa1
    	* amd64-linux-tdep.c (amd64_linux_regset_sections): Remove.
2c2fa1
    	(amd64_linux_iterate_over_regset_sections): New.
2c2fa1
    	(amd64_linux_init_abi_common): Don't install the regset section
2c2fa1
    	list, but the new iterator in gdbarch.
2c2fa1
    	* arm-linux-tdep.c (arm_linux_fpa_regset_sections)
2c2fa1
    	(arm_linux_vfp_regset_sections): Remove.  Move combined logic...
2c2fa1
    	(arm_linux_iterate_over_regset_sections): ...here.  New function.
2c2fa1
    	(arm_linux_init_abi): Set iterator instead of section list.
2c2fa1
    	* corelow.c (get_core_registers_cb): New function, logic moved
2c2fa1
    	from...
2c2fa1
    	(get_core_registers): ...loop body here.  Use new iterator method
2c2fa1
    	instead of walking through the regset section list.
2c2fa1
    	* gdbarch.sh: Remove 'core_regset_sections'.  New method
2c2fa1
    	'iterate_over_regset_sections'.  New typedef
2c2fa1
    	'iterate_over_regset_sections_cb'.
2c2fa1
    	* gdbarch.c: Regenerate.
2c2fa1
    	* gdbarch.h: Likewise.
2c2fa1
    	* i386-linux-tdep.c (i386_linux_regset_sections)
2c2fa1
    	(i386_linux_sse_regset_sections, i386_linux_avx_regset_sections):
2c2fa1
    	Remove.
2c2fa1
    	(i386_linux_iterate_over_regset_sections): New.
2c2fa1
    	(i386_linux_init_abi): Don't choose a regset section list, but
2c2fa1
    	install new iterator in gdbarch.
2c2fa1
    	* linux-tdep.c (struct linux_collect_regset_section_cb_data): New.
2c2fa1
    	(linux_collect_regset_section_cb): New function, logic moved
2c2fa1
    	from...
2c2fa1
    	(linux_collect_thread_registers): ...loop body here.  Use iterator
2c2fa1
    	method instead of walking through list.
2c2fa1
    	(linux_make_corefile_notes_1): Check for presence of iterator
2c2fa1
    	method instead of regset section list.
2c2fa1
    	* ppc-linux-tdep.c (ppc_linux_vsx_regset_sections)
2c2fa1
    	(ppc_linux_vmx_regset_sections, ppc_linux_fp_regset_sections)
2c2fa1
    	(ppc64_linux_vsx_regset_sections, ppc64_linux_vmx_regset_sections)
2c2fa1
    	(ppc64_linux_fp_regset_sections): Remove.  Move combined logic...
2c2fa1
    	(ppc_linux_iterate_over_regset_sections): ...here.  New function.
2c2fa1
    	(ppc_linux_init_abi): Don't choose from above regset section
2c2fa1
    	lists, but install new iterator in gdbarch.
2c2fa1
    	* regset.h (struct core_regset_section): Remove.
2c2fa1
    	* s390-linux-tdep.c (struct gdbarch_tdep): Add new fields
2c2fa1
    	have_linux_v1, have_linux_v2, and have_tdb.
2c2fa1
    	(s390_linux32_regset_sections, s390_linux32v1_regset_sections)
2c2fa1
    	(s390_linux32v2_regset_sections, s390_linux64_regset_sections)
2c2fa1
    	(s390_linux64v1_regset_sections, s390_linux64v2_regset_sections)
2c2fa1
    	(s390x_linux64_regset_sections, s390x_linux64v1_regset_sections)
2c2fa1
    	(s390x_linux64v2_regset_sections): Remove.  Move combined logic...
2c2fa1
    	(s390_iterate_over_regset_sections): ...here.  New function.  Use
2c2fa1
    	new tdep fields.
2c2fa1
    	(s390_gdbarch_init): Set new tdep fields.  Don't choose from above
2c2fa1
    	regset section lists, but install new iterator.
2c2fa1
2c2fa1
### a/gdb/ChangeLog
2c2fa1
### b/gdb/ChangeLog
2c2fa1
## -1,3 +1,55 @@
2c2fa1
+2014-09-30  Andreas Arnez  <arnez@linux.vnet.ibm.com>
2c2fa1
+
2c2fa1
+	* amd64-linux-tdep.c (amd64_linux_regset_sections): Remove.
2c2fa1
+	(amd64_linux_iterate_over_regset_sections): New.
2c2fa1
+	(amd64_linux_init_abi_common): Don't install the regset section
2c2fa1
+	list, but the new iterator in gdbarch.
2c2fa1
+	* arm-linux-tdep.c (arm_linux_fpa_regset_sections)
2c2fa1
+	(arm_linux_vfp_regset_sections): Remove.  Move combined logic...
2c2fa1
+	(arm_linux_iterate_over_regset_sections): ...here.  New function.
2c2fa1
+	(arm_linux_init_abi): Set iterator instead of section list.
2c2fa1
+	* corelow.c (get_core_registers_cb): New function, logic moved
2c2fa1
+	from...
2c2fa1
+	(get_core_registers): ...loop body here.  Use new iterator method
2c2fa1
+	instead of walking through the regset section list.
2c2fa1
+	* gdbarch.sh: Remove 'core_regset_sections'.  New method
2c2fa1
+	'iterate_over_regset_sections'.  New typedef
2c2fa1
+	'iterate_over_regset_sections_cb'.
2c2fa1
+	* gdbarch.c: Regenerate.
2c2fa1
+	* gdbarch.h: Likewise.
2c2fa1
+	* i386-linux-tdep.c (i386_linux_regset_sections)
2c2fa1
+	(i386_linux_sse_regset_sections, i386_linux_avx_regset_sections):
2c2fa1
+	Remove.
2c2fa1
+	(i386_linux_iterate_over_regset_sections): New.
2c2fa1
+	(i386_linux_init_abi): Don't choose a regset section list, but
2c2fa1
+	install new iterator in gdbarch.
2c2fa1
+	* linux-tdep.c (struct linux_collect_regset_section_cb_data): New.
2c2fa1
+	(linux_collect_regset_section_cb): New function, logic moved
2c2fa1
+	from...
2c2fa1
+	(linux_collect_thread_registers): ...loop body here.  Use iterator
2c2fa1
+	method instead of walking through list.
2c2fa1
+	(linux_make_corefile_notes_1): Check for presence of iterator
2c2fa1
+	method instead of regset section list.
2c2fa1
+	* ppc-linux-tdep.c (ppc_linux_vsx_regset_sections)
2c2fa1
+	(ppc_linux_vmx_regset_sections, ppc_linux_fp_regset_sections)
2c2fa1
+	(ppc64_linux_vsx_regset_sections, ppc64_linux_vmx_regset_sections)
2c2fa1
+	(ppc64_linux_fp_regset_sections): Remove.  Move combined logic...
2c2fa1
+	(ppc_linux_iterate_over_regset_sections): ...here.  New function.
2c2fa1
+	(ppc_linux_init_abi): Don't choose from above regset section
2c2fa1
+	lists, but install new iterator in gdbarch.
2c2fa1
+	* regset.h (struct core_regset_section): Remove.
2c2fa1
+	* s390-linux-tdep.c (struct gdbarch_tdep): Add new fields
2c2fa1
+	have_linux_v1, have_linux_v2, and have_tdb.
2c2fa1
+	(s390_linux32_regset_sections, s390_linux32v1_regset_sections)
2c2fa1
+	(s390_linux32v2_regset_sections, s390_linux64_regset_sections)
2c2fa1
+	(s390_linux64v1_regset_sections, s390_linux64v2_regset_sections)
2c2fa1
+	(s390x_linux64_regset_sections, s390x_linux64v1_regset_sections)
2c2fa1
+	(s390x_linux64v2_regset_sections): Remove.  Move combined logic...
2c2fa1
+	(s390_iterate_over_regset_sections): ...here.  New function.  Use
2c2fa1
+	new tdep fields.
2c2fa1
+	(s390_gdbarch_init): Set new tdep fields.  Don't choose from above
2c2fa1
+	regset section lists, but install new iterator.
2c2fa1
+
2c2fa1
 2014-09-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
2c2fa1
 
2c2fa1
 	* solib-svr4.c (svr4_parse_libraries): Use "library-list-svr4.dtd".
2c2fa1
Index: gdb-7.6.1/gdb/arm-linux-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/arm-linux-tdep.c	2016-02-21 21:24:15.859813662 +0100
2c2fa1
+++ gdb-7.6.1/gdb/arm-linux-tdep.c	2016-02-21 21:24:21.585851082 +0100
2c2fa1
@@ -724,21 +724,24 @@
2c2fa1
   return NULL;
2c2fa1
 }
2c2fa1
 
2c2fa1
-/* Core file register set sections.  */
2c2fa1
+/* Iterate over core file register note sections.  */
2c2fa1
 
2c2fa1
-static struct core_regset_section arm_linux_fpa_regset_sections[] =
2c2fa1
+static void
2c2fa1
+arm_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
2c2fa1
+					iterate_over_regset_sections_cb *cb,
2c2fa1
+					void *cb_data,
2c2fa1
+					const struct regcache *regcache)
2c2fa1
 {
2c2fa1
-  { ".reg", ARM_LINUX_SIZEOF_GREGSET, "general-purpose" },
2c2fa1
-  { ".reg2", ARM_LINUX_SIZEOF_NWFPE, "FPA floating-point" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2c2fa1
 
2c2fa1
-static struct core_regset_section arm_linux_vfp_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", ARM_LINUX_SIZEOF_GREGSET, "general-purpose" },
2c2fa1
-  { ".reg-arm-vfp", ARM_LINUX_SIZEOF_VFP, "VFP floating-point" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
+  cb (".reg", ARM_LINUX_SIZEOF_GREGSET, "general-purpose", cb_data);
2c2fa1
+
2c2fa1
+  if (tdep->have_vfp_registers)
2c2fa1
+    cb (".reg-arm-vfp", ARM_LINUX_SIZEOF_VFP, "VFP floating-point",
2c2fa1
+	cb_data);
2c2fa1
+  else if (tdep->have_fpa_registers)
2c2fa1
+    cb (".reg2", ARM_LINUX_SIZEOF_NWFPE, "FPA floating-point", cb_data);
2c2fa1
+}
2c2fa1
 
2c2fa1
 /* Determine target description from core file.  */
2c2fa1
 
2c2fa1
@@ -1266,13 +1269,10 @@
2c2fa1
   /* Core file support.  */
2c2fa1
   set_gdbarch_regset_from_core_section (gdbarch,
2c2fa1
 					arm_linux_regset_from_core_section);
2c2fa1
+  set_gdbarch_iterate_over_regset_sections
2c2fa1
+    (gdbarch, arm_linux_iterate_over_regset_sections);
2c2fa1
   set_gdbarch_core_read_description (gdbarch, arm_linux_core_read_description);
2c2fa1
 
2c2fa1
-  if (tdep->have_vfp_registers)
2c2fa1
-    set_gdbarch_core_regset_sections (gdbarch, arm_linux_vfp_regset_sections);
2c2fa1
-  else if (tdep->have_fpa_registers)
2c2fa1
-    set_gdbarch_core_regset_sections (gdbarch, arm_linux_fpa_regset_sections);
2c2fa1
-
2c2fa1
   set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type);
2c2fa1
 
2c2fa1
   /* Displaced stepping.  */
2c2fa1
Index: gdb-7.6.1/gdb/corelow.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/corelow.c	2016-02-21 21:24:15.859813662 +0100
2c2fa1
+++ gdb-7.6.1/gdb/corelow.c	2016-02-21 21:24:21.586851089 +0100
2c2fa1
@@ -621,6 +621,22 @@
2c2fa1
 				  bfd_section_vma (core_bfd, section)));
2c2fa1
 }
2c2fa1
 
2c2fa1
+/* Callback for get_core_registers that handles a single core file
2c2fa1
+   register note section. */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+get_core_registers_cb (const char *sect_name, int size,
2c2fa1
+		       const char *human_name, void *cb_data)
2c2fa1
+{
2c2fa1
+  struct regcache *regcache = (struct regcache *) cb_data;
2c2fa1
+
2c2fa1
+  if (strcmp (sect_name, ".reg") == 0)
2c2fa1
+    get_core_register_section (regcache, sect_name, 0, human_name, 1);
2c2fa1
+  else if (strcmp (sect_name, ".reg2") == 0)
2c2fa1
+    get_core_register_section (regcache, sect_name, 2, human_name, 0);
2c2fa1
+  else
2c2fa1
+    get_core_register_section (regcache, sect_name, 3, human_name, 0);
2c2fa1
+}
2c2fa1
 
2c2fa1
 /* Get the registers out of a core file.  This is the machine-
2c2fa1
    independent part.  Fetch_core_registers is the machine-dependent
2c2fa1
@@ -633,8 +649,8 @@
2c2fa1
 get_core_registers (struct target_ops *ops,
2c2fa1
 		    struct regcache *regcache, int regno)
2c2fa1
 {
2c2fa1
-  struct core_regset_section *sect_list;
2c2fa1
   int i;
2c2fa1
+  struct gdbarch *gdbarch;
2c2fa1
 
2c2fa1
   if (!(core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch))
2c2fa1
       && (core_vec == NULL || core_vec->core_read_registers == NULL))
2c2fa1
@@ -644,23 +660,11 @@
2c2fa1
       return;
2c2fa1
     }
2c2fa1
 
2c2fa1
-  sect_list = gdbarch_core_regset_sections (get_regcache_arch (regcache));
2c2fa1
-  if (sect_list)
2c2fa1
-    while (sect_list->sect_name != NULL)
2c2fa1
-      {
2c2fa1
-        if (strcmp (sect_list->sect_name, ".reg") == 0)
2c2fa1
-	  get_core_register_section (regcache, sect_list->sect_name,
2c2fa1
-				     0, sect_list->human_name, 1);
2c2fa1
-        else if (strcmp (sect_list->sect_name, ".reg2") == 0)
2c2fa1
-	  get_core_register_section (regcache, sect_list->sect_name,
2c2fa1
-				     2, sect_list->human_name, 0);
2c2fa1
-	else
2c2fa1
-	  get_core_register_section (regcache, sect_list->sect_name,
2c2fa1
-				     3, sect_list->human_name, 0);
2c2fa1
-
2c2fa1
-	sect_list++;
2c2fa1
-      }
2c2fa1
-
2c2fa1
+  gdbarch = get_regcache_arch (regcache);
2c2fa1
+  if (gdbarch_iterate_over_regset_sections_p (gdbarch))
2c2fa1
+    gdbarch_iterate_over_regset_sections (gdbarch,
2c2fa1
+					  get_core_registers_cb,
2c2fa1
+					  (void *) regcache, NULL);
2c2fa1
   else
2c2fa1
     {
2c2fa1
       get_core_register_section (regcache,
2c2fa1
Index: gdb-7.6.1/gdb/gdbarch.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/gdbarch.c	2016-02-21 21:24:15.859813662 +0100
2c2fa1
+++ gdb-7.6.1/gdb/gdbarch.c	2016-02-21 21:24:21.587851096 +0100
2c2fa1
@@ -266,7 +266,7 @@
2c2fa1
   gdbarch_register_reggroup_p_ftype *register_reggroup_p;
2c2fa1
   gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
2c2fa1
   gdbarch_regset_from_core_section_ftype *regset_from_core_section;
2c2fa1
-  struct core_regset_section * core_regset_sections;
2c2fa1
+  gdbarch_iterate_over_regset_sections_ftype *iterate_over_regset_sections;
2c2fa1
   gdbarch_make_corefile_notes_ftype *make_corefile_notes;
2c2fa1
   gdbarch_elfcore_write_linux_prpsinfo_ftype *elfcore_write_linux_prpsinfo;
2c2fa1
   gdbarch_find_memory_regions_ftype *find_memory_regions;
2c2fa1
@@ -742,6 +742,7 @@
2c2fa1
   /* Skip verify of register_reggroup_p, invalid_p == 0 */
2c2fa1
   /* Skip verify of fetch_pointer_argument, has predicate.  */
2c2fa1
   /* Skip verify of regset_from_core_section, has predicate.  */
2c2fa1
+  /* Skip verify of iterate_over_regset_sections, has predicate.  */
2c2fa1
   /* Skip verify of make_corefile_notes, has predicate.  */
2c2fa1
   /* Skip verify of elfcore_write_linux_prpsinfo, has predicate.  */
2c2fa1
   /* Skip verify of find_memory_regions, has predicate.  */
2c2fa1
@@ -927,9 +928,6 @@
2c2fa1
                       "gdbarch_dump: core_read_description = <%s>\n",
2c2fa1
                       host_address_to_string (gdbarch->core_read_description));
2c2fa1
   fprintf_unfiltered (file,
2c2fa1
-                      "gdbarch_dump: core_regset_sections = %s\n",
2c2fa1
-                      host_address_to_string (gdbarch->core_regset_sections));
2c2fa1
-  fprintf_unfiltered (file,
2c2fa1
                       "gdbarch_dump: gdbarch_core_xfer_shared_libraries_p() = %d\n",
2c2fa1
                       gdbarch_core_xfer_shared_libraries_p (gdbarch));
2c2fa1
   fprintf_unfiltered (file,
2c2fa1
@@ -1125,6 +1123,12 @@
2c2fa1
                       "gdbarch_dump: iterate_over_objfiles_in_search_order = <%s>\n",
2c2fa1
                       host_address_to_string (gdbarch->iterate_over_objfiles_in_search_order));
2c2fa1
   fprintf_unfiltered (file,
2c2fa1
+                      "gdbarch_dump: gdbarch_iterate_over_regset_sections_p() = %d\n",
2c2fa1
+                      gdbarch_iterate_over_regset_sections_p (gdbarch));
2c2fa1
+  fprintf_unfiltered (file,
2c2fa1
+                      "gdbarch_dump: iterate_over_regset_sections = <%s>\n",
2c2fa1
+                      host_address_to_string (gdbarch->iterate_over_regset_sections));
2c2fa1
+  fprintf_unfiltered (file,
2c2fa1
                       "gdbarch_dump: long_bit = %s\n",
2c2fa1
                       plongest (gdbarch->long_bit));
2c2fa1
   fprintf_unfiltered (file,
2c2fa1
@@ -3398,20 +3402,28 @@
2c2fa1
   gdbarch->regset_from_core_section = regset_from_core_section;
2c2fa1
 }
2c2fa1
 
2c2fa1
-struct core_regset_section *
2c2fa1
-gdbarch_core_regset_sections (struct gdbarch *gdbarch)
2c2fa1
+int
2c2fa1
+gdbarch_iterate_over_regset_sections_p (struct gdbarch *gdbarch)
2c2fa1
+{
2c2fa1
+  gdb_assert (gdbarch != NULL);
2c2fa1
+  return gdbarch->iterate_over_regset_sections != NULL;
2c2fa1
+}
2c2fa1
+
2c2fa1
+void
2c2fa1
+gdbarch_iterate_over_regset_sections (struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
2c2fa1
 {
2c2fa1
   gdb_assert (gdbarch != NULL);
2c2fa1
+  gdb_assert (gdbarch->iterate_over_regset_sections != NULL);
2c2fa1
   if (gdbarch_debug >= 2)
2c2fa1
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_core_regset_sections called\n");
2c2fa1
-  return gdbarch->core_regset_sections;
2c2fa1
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_iterate_over_regset_sections called\n");
2c2fa1
+  gdbarch->iterate_over_regset_sections (gdbarch, cb, cb_data, regcache);
2c2fa1
 }
2c2fa1
 
2c2fa1
 void
2c2fa1
-set_gdbarch_core_regset_sections (struct gdbarch *gdbarch,
2c2fa1
-                                  struct core_regset_section * core_regset_sections)
2c2fa1
+set_gdbarch_iterate_over_regset_sections (struct gdbarch *gdbarch,
2c2fa1
+                                          gdbarch_iterate_over_regset_sections_ftype iterate_over_regset_sections)
2c2fa1
 {
2c2fa1
-  gdbarch->core_regset_sections = core_regset_sections;
2c2fa1
+  gdbarch->iterate_over_regset_sections = iterate_over_regset_sections;
2c2fa1
 }
2c2fa1
 
2c2fa1
 int
2c2fa1
Index: gdb-7.6.1/gdb/gdbarch.h
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/gdbarch.h	2016-02-21 21:24:15.859813662 +0100
2c2fa1
+++ gdb-7.6.1/gdb/gdbarch.h	2016-02-21 21:24:21.588851102 +0100
2c2fa1
@@ -85,6 +85,9 @@
2c2fa1
 typedef int (iterate_over_objfiles_in_search_order_cb_ftype)
2c2fa1
   (struct objfile *objfile, void *cb_data);
2c2fa1
 
2c2fa1
+typedef void (iterate_over_regset_sections_cb)
2c2fa1
+  (const char *sect_name, int size, const char *human_name, void *cb_data);
2c2fa1
+
2c2fa1
 
2c2fa1
 /* The following are pre-initialized by GDBARCH.  */
2c2fa1
 
2c2fa1
@@ -742,10 +745,18 @@
2c2fa1
 extern const struct regset * gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size);
2c2fa1
 extern void set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch, gdbarch_regset_from_core_section_ftype *regset_from_core_section);
2c2fa1
 
2c2fa1
-/* Supported register notes in a core file. */
2c2fa1
-
2c2fa1
-extern struct core_regset_section * gdbarch_core_regset_sections (struct gdbarch *gdbarch);
2c2fa1
-extern void set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, struct core_regset_section * core_regset_sections);
2c2fa1
+/* Iterate over all supported register notes in a core file.  For each
2c2fa1
+   supported register note section, the iterator must call CB and pass
2c2fa1
+   CB_DATA unchanged.  If REGCACHE is not NULL, the iterator can limit
2c2fa1
+   the supported register note sections based on the current register
2c2fa1
+   values.  Otherwise it should enumerate all supported register note
2c2fa1
+   sections. */
2c2fa1
+
2c2fa1
+extern int gdbarch_iterate_over_regset_sections_p (struct gdbarch *gdbarch);
2c2fa1
+
2c2fa1
+typedef void (gdbarch_iterate_over_regset_sections_ftype) (struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache);
2c2fa1
+extern void gdbarch_iterate_over_regset_sections (struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache);
2c2fa1
+extern void set_gdbarch_iterate_over_regset_sections (struct gdbarch *gdbarch, gdbarch_iterate_over_regset_sections_ftype *iterate_over_regset_sections);
2c2fa1
 
2c2fa1
 /* Create core file notes */
2c2fa1
 
2c2fa1
Index: gdb-7.6.1/gdb/gdbarch.sh
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/gdbarch.sh	2016-02-21 21:24:15.859813662 +0100
2c2fa1
+++ gdb-7.6.1/gdb/gdbarch.sh	2016-02-21 21:24:21.588851102 +0100
2c2fa1
@@ -648,8 +648,13 @@
2c2fa1
 # name SECT_NAME and size SECT_SIZE.
2c2fa1
 M:const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size
2c2fa1
 
2c2fa1
-# Supported register notes in a core file.
2c2fa1
-v:struct core_regset_section *:core_regset_sections:const char *name, int len::::::host_address_to_string (gdbarch->core_regset_sections)
2c2fa1
+# Iterate over all supported register notes in a core file.  For each
2c2fa1
+# supported register note section, the iterator must call CB and pass
2c2fa1
+# CB_DATA unchanged.  If REGCACHE is not NULL, the iterator can limit
2c2fa1
+# the supported register note sections based on the current register
2c2fa1
+# values.  Otherwise it should enumerate all supported register note
2c2fa1
+# sections.
2c2fa1
+M:void:iterate_over_regset_sections:iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache:cb, cb_data, regcache
2c2fa1
 
2c2fa1
 # Create core file notes
2c2fa1
 M:char *:make_corefile_notes:bfd *obfd, int *note_size:obfd, note_size
2c2fa1
@@ -1135,6 +1140,9 @@
2c2fa1
 
2c2fa1
 typedef int (iterate_over_objfiles_in_search_order_cb_ftype)
2c2fa1
   (struct objfile *objfile, void *cb_data);
2c2fa1
+
2c2fa1
+typedef void (iterate_over_regset_sections_cb)
2c2fa1
+  (const char *sect_name, int size, const char *human_name, void *cb_data);
2c2fa1
 EOF
2c2fa1
 
2c2fa1
 # function typedef's
2c2fa1
Index: gdb-7.6.1/gdb/linux-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/linux-tdep.c	2016-02-21 21:24:15.859813662 +0100
2c2fa1
+++ gdb-7.6.1/gdb/linux-tdep.c	2016-02-21 21:24:21.589851109 +0100
2c2fa1
@@ -1409,6 +1409,57 @@
2c2fa1
   return note_data;
2c2fa1
 }
2c2fa1
 
2c2fa1
+/* Structure for passing information from
2c2fa1
+   linux_collect_thread_registers via an iterator to
2c2fa1
+   linux_collect_regset_section_cb. */
2c2fa1
+
2c2fa1
+struct linux_collect_regset_section_cb_data
2c2fa1
+{
2c2fa1
+  struct gdbarch *gdbarch;
2c2fa1
+  const struct regcache *regcache;
2c2fa1
+  bfd *obfd;
2c2fa1
+  char *note_data;
2c2fa1
+  int *note_size;
2c2fa1
+  unsigned long lwp;
2c2fa1
+  enum gdb_signal stop_signal;
2c2fa1
+  int abort_iteration;
2c2fa1
+};
2c2fa1
+
2c2fa1
+/* Callback for iterate_over_regset_sections that records a single
2c2fa1
+   regset in the corefile note section.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+linux_collect_regset_section_cb (const char *sect_name, int size,
2c2fa1
+				 const char *human_name, void *cb_data)
2c2fa1
+{
2c2fa1
+  const struct regset *regset;
2c2fa1
+  char *buf;
2c2fa1
+  struct linux_collect_regset_section_cb_data *data = cb_data;
2c2fa1
+
2c2fa1
+  if (data->abort_iteration)
2c2fa1
+    return;
2c2fa1
+
2c2fa1
+  regset = gdbarch_regset_from_core_section (data->gdbarch, sect_name, size);
2c2fa1
+  gdb_assert (regset && regset->collect_regset);
2c2fa1
+
2c2fa1
+  buf = xmalloc (size);
2c2fa1
+  regset->collect_regset (regset, data->regcache, -1, buf, size);
2c2fa1
+
2c2fa1
+  /* PRSTATUS still needs to be treated specially.  */
2c2fa1
+  if (strcmp (sect_name, ".reg") == 0)
2c2fa1
+    data->note_data = (char *) elfcore_write_prstatus
2c2fa1
+      (data->obfd, data->note_data, data->note_size, data->lwp,
2c2fa1
+       gdb_signal_to_host (data->stop_signal), buf);
2c2fa1
+  else
2c2fa1
+    data->note_data = (char *) elfcore_write_register_note
2c2fa1
+      (data->obfd, data->note_data, data->note_size,
2c2fa1
+       sect_name, buf, size);
2c2fa1
+  xfree (buf);
2c2fa1
+
2c2fa1
+  if (data->note_data == NULL)
2c2fa1
+    data->abort_iteration = 1;
2c2fa1
+}
2c2fa1
+
2c2fa1
 /* Records the thread's register state for the corefile note
2c2fa1
    section.  */
2c2fa1
 
2c2fa1
@@ -1419,47 +1470,25 @@
2c2fa1
 				enum gdb_signal stop_signal)
2c2fa1
 {
2c2fa1
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
2c2fa1
-  struct core_regset_section *sect_list;
2c2fa1
-  unsigned long lwp;
2c2fa1
+  struct linux_collect_regset_section_cb_data data;
2c2fa1
 
2c2fa1
-  sect_list = gdbarch_core_regset_sections (gdbarch);
2c2fa1
-  gdb_assert (sect_list);
2c2fa1
+  data.gdbarch = gdbarch;
2c2fa1
+  data.regcache = regcache;
2c2fa1
+  data.obfd = obfd;
2c2fa1
+  data.note_data = note_data;
2c2fa1
+  data.note_size = note_size;
2c2fa1
+  data.stop_signal = stop_signal;
2c2fa1
+  data.abort_iteration = 0;
2c2fa1
 
2c2fa1
   /* For remote targets the LWP may not be available, so use the TID.  */
2c2fa1
-  lwp = ptid_get_lwp (ptid);
2c2fa1
-  if (!lwp)
2c2fa1
-    lwp = ptid_get_tid (ptid);
2c2fa1
-
2c2fa1
-  while (sect_list->sect_name != NULL)
2c2fa1
-    {
2c2fa1
-      const struct regset *regset;
2c2fa1
-      char *buf;
2c2fa1
-
2c2fa1
-      regset = gdbarch_regset_from_core_section (gdbarch,
2c2fa1
-						 sect_list->sect_name,
2c2fa1
-						 sect_list->size);
2c2fa1
-      gdb_assert (regset && regset->collect_regset);
2c2fa1
-
2c2fa1
-      buf = xmalloc (sect_list->size);
2c2fa1
-      regset->collect_regset (regset, regcache, -1, buf, sect_list->size);
2c2fa1
-
2c2fa1
-      /* PRSTATUS still needs to be treated specially.  */
2c2fa1
-      if (strcmp (sect_list->sect_name, ".reg") == 0)
2c2fa1
-	note_data = (char *) elfcore_write_prstatus
2c2fa1
-			       (obfd, note_data, note_size, lwp,
2c2fa1
-				gdb_signal_to_host (stop_signal), buf);
2c2fa1
-      else
2c2fa1
-	note_data = (char *) elfcore_write_register_note
2c2fa1
-			       (obfd, note_data, note_size,
2c2fa1
-				sect_list->sect_name, buf, sect_list->size);
2c2fa1
-      xfree (buf);
2c2fa1
-      sect_list++;
2c2fa1
-
2c2fa1
-      if (!note_data)
2c2fa1
-	return NULL;
2c2fa1
-    }
2c2fa1
-
2c2fa1
-  return note_data;
2c2fa1
+  data.lwp = ptid_get_lwp (ptid);
2c2fa1
+  if (!data.lwp)
2c2fa1
+    data.lwp = ptid_get_tid (ptid);
2c2fa1
+
2c2fa1
+  gdbarch_iterate_over_regset_sections (gdbarch,
2c2fa1
+					linux_collect_regset_section_cb,
2c2fa1
+					&data, regcache);
2c2fa1
+  return data.note_data;
2c2fa1
 }
2c2fa1
 
2c2fa1
 /* Fetch the siginfo data for the current thread, if it exists.  If
2c2fa1
@@ -1839,7 +1868,7 @@
2c2fa1
      converted to gdbarch_core_regset_sections, we no longer need to fall back
2c2fa1
      to the target method at this point.  */
2c2fa1
 
2c2fa1
-  if (!gdbarch_core_regset_sections (gdbarch))
2c2fa1
+  if (!gdbarch_iterate_over_regset_sections_p (gdbarch))
2c2fa1
     return target_make_corefile_notes (obfd, note_size);
2c2fa1
   else
2c2fa1
     return linux_make_corefile_notes (gdbarch, obfd, note_size,
2c2fa1
Index: gdb-7.6.1/gdb/ppc-linux-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/ppc-linux-tdep.c	2016-02-21 21:24:15.859813662 +0100
2c2fa1
+++ gdb-7.6.1/gdb/ppc-linux-tdep.c	2016-02-21 21:24:21.590851115 +0100
2c2fa1
@@ -260,54 +260,6 @@
2c2fa1
 				      readbuf, writebuf);
2c2fa1
 }
2c2fa1
 
2c2fa1
-static struct core_regset_section ppc_linux_vsx_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", 48 * 4, "general-purpose" },
2c2fa1
-  { ".reg2", 264, "floating-point" },
2c2fa1
-  { ".reg-ppc-vmx", 544, "ppc Altivec" },
2c2fa1
-  { ".reg-ppc-vsx", 256, "POWER7 VSX" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section ppc_linux_vmx_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", 48 * 4, "general-purpose" },
2c2fa1
-  { ".reg2", 264, "floating-point" },
2c2fa1
-  { ".reg-ppc-vmx", 544, "ppc Altivec" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section ppc_linux_fp_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", 48 * 4, "general-purpose" },
2c2fa1
-  { ".reg2", 264, "floating-point" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section ppc64_linux_vsx_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", 48 * 8, "general-purpose" },
2c2fa1
-  { ".reg2", 264, "floating-point" },
2c2fa1
-  { ".reg-ppc-vmx", 544, "ppc Altivec" },
2c2fa1
-  { ".reg-ppc-vsx", 256, "POWER7 VSX" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section ppc64_linux_vmx_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", 48 * 8, "general-purpose" },
2c2fa1
-  { ".reg2", 264, "floating-point" },
2c2fa1
-  { ".reg-ppc-vmx", 544, "ppc Altivec" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section ppc64_linux_fp_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", 48 * 8, "general-purpose" },
2c2fa1
-  { ".reg2", 264, "floating-point" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
 /* PLT stub in executable.  */
2c2fa1
 static struct ppc_insn_pattern powerpc32_plt_stub[] =
2c2fa1
   {
2c2fa1
@@ -589,6 +541,28 @@
2c2fa1
   return NULL;
2c2fa1
 }
2c2fa1
 
2c2fa1
+/* Iterate over supported core file register note sections. */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
2c2fa1
+					iterate_over_regset_sections_cb *cb,
2c2fa1
+					void *cb_data,
2c2fa1
+					const struct regcache *regcache)
2c2fa1
+{
2c2fa1
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2c2fa1
+  int have_altivec = tdep->ppc_vr0_regnum != -1;
2c2fa1
+  int have_vsx = tdep->ppc_vsr0_upper_regnum != -1;
2c2fa1
+
2c2fa1
+  cb (".reg", 48 * tdep->wordsize, "general-purpose", cb_data);
2c2fa1
+  cb (".reg2", 264, "floating-point", cb_data);
2c2fa1
+
2c2fa1
+  if (have_altivec)
2c2fa1
+    cb (".reg-ppc-vmx", 544, "ppc Altivec", cb_data);
2c2fa1
+
2c2fa1
+  if (have_vsx)
2c2fa1
+    cb (".reg-ppc-vsx", 256, "POWER7 VSX", cb_data);
2c2fa1
+}
2c2fa1
+
2c2fa1
 static void
2c2fa1
 ppc_linux_sigtramp_cache (struct frame_info *this_frame,
2c2fa1
 			  struct trad_frame_cache *this_cache,
2c2fa1
@@ -1790,19 +1764,6 @@
2c2fa1
       else
2c2fa1
 	set_gdbarch_gcore_bfd_target (gdbarch, "elf32-powerpc");
2c2fa1
 
2c2fa1
-      /* Supported register sections.  */
2c2fa1
-      if (tdesc_find_feature (info.target_desc,
2c2fa1
-			      "org.gnu.gdb.power.vsx"))
2c2fa1
-	set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					  ppc_linux_vsx_regset_sections);
2c2fa1
-      else if (tdesc_find_feature (info.target_desc,
2c2fa1
-			       "org.gnu.gdb.power.altivec"))
2c2fa1
-	set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					  ppc_linux_vmx_regset_sections);
2c2fa1
-      else
2c2fa1
-	set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					  ppc_linux_fp_regset_sections);
2c2fa1
-
2c2fa1
       if (powerpc_so_ops.in_dynsym_resolve_code == NULL)
2c2fa1
 	{
2c2fa1
 	  powerpc_so_ops = svr4_so_ops;
2c2fa1
@@ -1854,19 +1815,6 @@
2c2fa1
 	set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpcle");
2c2fa1
       else
2c2fa1
 	set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpc");
2c2fa1
-
2c2fa1
-      /* Supported register sections.  */
2c2fa1
-      if (tdesc_find_feature (info.target_desc,
2c2fa1
-			      "org.gnu.gdb.power.vsx"))
2c2fa1
-	set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					  ppc64_linux_vsx_regset_sections);
2c2fa1
-      else if (tdesc_find_feature (info.target_desc,
2c2fa1
-			       "org.gnu.gdb.power.altivec"))
2c2fa1
-	set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					  ppc64_linux_vmx_regset_sections);
2c2fa1
-      else
2c2fa1
-	set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					  ppc64_linux_fp_regset_sections);
2c2fa1
     }
2c2fa1
 
2c2fa1
   /* PPC32 uses a different prpsinfo32 compared to most other Linux
2c2fa1
@@ -1878,6 +1826,8 @@
2c2fa1
   set_gdbarch_regset_from_core_section (gdbarch,
2c2fa1
 					ppc_linux_regset_from_core_section);
2c2fa1
   set_gdbarch_core_read_description (gdbarch, ppc_linux_core_read_description);
2c2fa1
+  set_gdbarch_iterate_over_regset_sections (gdbarch,
2c2fa1
+					    ppc_linux_iterate_over_regset_sections);
2c2fa1
 
2c2fa1
   /* Enable TLS support.  */
2c2fa1
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
2c2fa1
Index: gdb-7.6.1/gdb/regset.h
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/regset.h	2016-02-21 21:24:15.859813662 +0100
2c2fa1
+++ gdb-7.6.1/gdb/regset.h	2016-02-21 21:24:21.590851115 +0100
2c2fa1
@@ -23,14 +23,6 @@
2c2fa1
 struct gdbarch;
2c2fa1
 struct regcache;
2c2fa1
 
2c2fa1
-/* Data structure for the supported register notes in a core file.  */
2c2fa1
-struct core_regset_section
2c2fa1
-{
2c2fa1
-  const char *sect_name;
2c2fa1
-  int size;
2c2fa1
-  const char *human_name;
2c2fa1
-};
2c2fa1
-
2c2fa1
 /* Data structure describing a register set.  */
2c2fa1
 
2c2fa1
 typedef void (supply_regset_ftype) (const struct regset *, struct regcache *,
2c2fa1
Index: gdb-7.6.1/gdb/s390-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/s390-tdep.c	2016-02-21 21:24:15.859813662 +0100
2c2fa1
+++ gdb-7.6.1/gdb/s390-tdep.c	2016-02-21 21:24:21.591851122 +0100
2c2fa1
@@ -84,6 +84,10 @@
2c2fa1
 
2c2fa1
   const struct regset *fpregset;
2c2fa1
   int sizeof_fpregset;
2c2fa1
+
2c2fa1
+  int have_linux_v1;
2c2fa1
+  int have_linux_v2;
2c2fa1
+  int have_tdb;
2c2fa1
 };
2c2fa1
 
2c2fa1
 
2c2fa1
@@ -691,84 +695,6 @@
2c2fa1
   s390_collect_regset
2c2fa1
 };
2c2fa1
 
2c2fa1
-static struct core_regset_section s390_linux32_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", s390_sizeof_gregset, "general-purpose" },
2c2fa1
-  { ".reg2", s390_sizeof_fpregset, "floating-point" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section s390_linux32v1_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", s390_sizeof_gregset, "general-purpose" },
2c2fa1
-  { ".reg2", s390_sizeof_fpregset, "floating-point" },
2c2fa1
-  { ".reg-s390-last-break", 8, "s390 last-break address" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section s390_linux32v2_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", s390_sizeof_gregset, "general-purpose" },
2c2fa1
-  { ".reg2", s390_sizeof_fpregset, "floating-point" },
2c2fa1
-  { ".reg-s390-last-break", 8, "s390 last-break address" },
2c2fa1
-  { ".reg-s390-system-call", 4, "s390 system-call" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section s390_linux64_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", s390_sizeof_gregset, "general-purpose" },
2c2fa1
-  { ".reg2", s390_sizeof_fpregset, "floating-point" },
2c2fa1
-  { ".reg-s390-high-gprs", 16*4, "s390 GPR upper halves" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section s390_linux64v1_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", s390_sizeof_gregset, "general-purpose" },
2c2fa1
-  { ".reg2", s390_sizeof_fpregset, "floating-point" },
2c2fa1
-  { ".reg-s390-high-gprs", 16*4, "s390 GPR upper halves" },
2c2fa1
-  { ".reg-s390-last-break", 8, "s930 last-break address" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section s390_linux64v2_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", s390_sizeof_gregset, "general-purpose" },
2c2fa1
-  { ".reg2", s390_sizeof_fpregset, "floating-point" },
2c2fa1
-  { ".reg-s390-high-gprs", 16*4, "s390 GPR upper halves" },
2c2fa1
-  { ".reg-s390-last-break", 8, "s930 last-break address" },
2c2fa1
-  { ".reg-s390-system-call", 4, "s390 system-call" },
2c2fa1
-  { ".reg-s390-tdb", s390_sizeof_tdbregset, "s390 TDB" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section s390x_linux64_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", s390x_sizeof_gregset, "general-purpose" },
2c2fa1
-  { ".reg2", s390_sizeof_fpregset, "floating-point" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section s390x_linux64v1_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", s390x_sizeof_gregset, "general-purpose" },
2c2fa1
-  { ".reg2", s390_sizeof_fpregset, "floating-point" },
2c2fa1
-  { ".reg-s390-last-break", 8, "s930 last-break address" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section s390x_linux64v2_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", s390x_sizeof_gregset, "general-purpose" },
2c2fa1
-  { ".reg2", s390_sizeof_fpregset, "floating-point" },
2c2fa1
-  { ".reg-s390-last-break", 8, "s930 last-break address" },
2c2fa1
-  { ".reg-s390-system-call", 4, "s390 system-call" },
2c2fa1
-  { ".reg-s390-tdb", s390_sizeof_tdbregset, "s390 TDB" },
2c2fa1
-  { NULL, 0}
2c2fa1
-};
2c2fa1
-
2c2fa1
-
2c2fa1
 /* Return the appropriate register set for the core section identified
2c2fa1
    by SECT_NAME and SECT_SIZE.  */
2c2fa1
 static const struct regset *
2c2fa1
@@ -799,6 +725,38 @@
2c2fa1
   return NULL;
2c2fa1
 }
2c2fa1
 
2c2fa1
+/* Iterate over supported core file register note sections. */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+s390_iterate_over_regset_sections (struct gdbarch *gdbarch,
2c2fa1
+				   iterate_over_regset_sections_cb *cb,
2c2fa1
+				   void *cb_data,
2c2fa1
+				   const struct regcache *regcache)
2c2fa1
+{
2c2fa1
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2c2fa1
+
2c2fa1
+  cb (".reg", tdep->sizeof_gregset, "general-purpose", cb_data);
2c2fa1
+  cb (".reg2", s390_sizeof_fpregset, "floating-point", cb_data);
2c2fa1
+
2c2fa1
+  if (tdep->abi == ABI_LINUX_S390 && tdep->gpr_full_regnum != -1)
2c2fa1
+    cb (".reg-s390-high-gprs", 16 * 4, "s390 GPR upper halves", cb_data);
2c2fa1
+
2c2fa1
+  if (tdep->have_linux_v1)
2c2fa1
+    cb (".reg-s390-last-break", 8, "s930 last-break address", cb_data);
2c2fa1
+
2c2fa1
+  if (tdep->have_linux_v2)
2c2fa1
+    cb (".reg-s390-system-call", 4, "s390 system-call", cb_data);
2c2fa1
+
2c2fa1
+  /* If regcache is set, we are in "write" (gcore) mode.  In this
2c2fa1
+     case, don't iterate over the TDB unless its registers are
2c2fa1
+     available.  */
2c2fa1
+  if (tdep->have_tdb
2c2fa1
+      && (regcache == NULL
2c2fa1
+	  || REG_VALID == regcache_register_status (regcache,
2c2fa1
+						    S390_TDB_DWORD0_REGNUM)))
2c2fa1
+    cb (".reg-s390-tdb", s390_sizeof_tdbregset, "s390 TDB", cb_data);
2c2fa1
+}
2c2fa1
+
2c2fa1
 static const struct target_desc *
2c2fa1
 s390_core_read_description (struct gdbarch *gdbarch,
2c2fa1
 			    struct target_ops *target, bfd *abfd)
2c2fa1
@@ -3031,6 +2989,7 @@
2c2fa1
   int have_upper = 0;
2c2fa1
   int have_linux_v1 = 0;
2c2fa1
   int have_linux_v2 = 0;
2c2fa1
+  int have_tdb = 0;
2c2fa1
   int first_pseudo_reg, last_pseudo_reg;
2c2fa1
   static const char *const stap_register_prefixes[] = { "%", NULL };
2c2fa1
   static const char *const stap_register_indirection_prefixes[] = { "(",
2c2fa1
@@ -3175,6 +3134,7 @@
2c2fa1
 	    valid_p &= tdesc_numbered_register (feature, tdesc_data,
2c2fa1
 						S390_TDB_DWORD0_REGNUM + i,
2c2fa1
 						tdb_regs[i]);
2c2fa1
+	  have_tdb = 1;
2c2fa1
 	}
2c2fa1
 
2c2fa1
       if (!valid_p)
2c2fa1
@@ -3204,6 +3164,9 @@
2c2fa1
   /* Otherwise create a new gdbarch for the specified machine type.  */
2c2fa1
   tdep = XCALLOC (1, struct gdbarch_tdep);
2c2fa1
   tdep->abi = tdep_abi;
2c2fa1
+  tdep->have_linux_v1 = have_linux_v1;
2c2fa1
+  tdep->have_linux_v2 = have_linux_v2;
2c2fa1
+  tdep->have_tdb = have_tdb;
2c2fa1
   gdbarch = gdbarch_alloc (&info, tdep);
2c2fa1
 
2c2fa1
   set_gdbarch_believe_pcc_promotion (gdbarch, 0);
2c2fa1
@@ -3234,6 +3197,8 @@
2c2fa1
   set_gdbarch_regset_from_core_section (gdbarch,
2c2fa1
                                         s390_regset_from_core_section);
2c2fa1
   set_gdbarch_core_read_description (gdbarch, s390_core_read_description);
2c2fa1
+  set_gdbarch_iterate_over_regset_sections (gdbarch,
2c2fa1
+					    s390_iterate_over_regset_sections);
2c2fa1
   set_gdbarch_cannot_store_register (gdbarch, s390_cannot_store_register);
2c2fa1
   set_gdbarch_write_pc (gdbarch, s390_write_pc);
2c2fa1
   set_gdbarch_pseudo_register_read (gdbarch, s390_pseudo_register_read);
2c2fa1
@@ -3301,31 +3266,6 @@
2c2fa1
       set_gdbarch_addr_bits_remove (gdbarch, s390_addr_bits_remove);
2c2fa1
       set_solib_svr4_fetch_link_map_offsets
2c2fa1
 	(gdbarch, svr4_ilp32_fetch_link_map_offsets);
2c2fa1
-
2c2fa1
-      if (have_upper)
2c2fa1
-	{
2c2fa1
-	  if (have_linux_v2)
2c2fa1
-	    set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					      s390_linux64v2_regset_sections);
2c2fa1
-	  else if (have_linux_v1)
2c2fa1
-	    set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					      s390_linux64v1_regset_sections);
2c2fa1
-	  else
2c2fa1
-	    set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					      s390_linux64_regset_sections);
2c2fa1
-	}
2c2fa1
-      else
2c2fa1
-	{
2c2fa1
-	  if (have_linux_v2)
2c2fa1
-	    set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					      s390_linux32v2_regset_sections);
2c2fa1
-	  else if (have_linux_v1)
2c2fa1
-	    set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					      s390_linux32v1_regset_sections);
2c2fa1
-	  else
2c2fa1
-	    set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					      s390_linux32_regset_sections);
2c2fa1
-	}
2c2fa1
       break;
2c2fa1
 
2c2fa1
     case ABI_LINUX_ZSERIES:
2c2fa1
@@ -3345,16 +3285,6 @@
2c2fa1
                                                     s390_address_class_type_flags_to_name);
2c2fa1
       set_gdbarch_address_class_name_to_type_flags (gdbarch,
2c2fa1
                                                     s390_address_class_name_to_type_flags);
2c2fa1
-
2c2fa1
-      if (have_linux_v2)
2c2fa1
-	set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					  s390x_linux64v2_regset_sections);
2c2fa1
-      else if (have_linux_v1)
2c2fa1
-	set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					  s390x_linux64v1_regset_sections);
2c2fa1
-      else
2c2fa1
-	set_gdbarch_core_regset_sections (gdbarch,
2c2fa1
-					  s390x_linux64_regset_sections);
2c2fa1
       break;
2c2fa1
     }
2c2fa1
 
2c2fa1
Index: gdb-7.6.1/gdb/amd64-linux-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/amd64-linux-tdep.c	2016-02-21 21:41:37.020617839 +0100
2c2fa1
+++ gdb-7.6.1/gdb/amd64-linux-tdep.c	2016-02-21 21:41:44.948669651 +0100
2c2fa1
@@ -51,15 +51,6 @@
2c2fa1
 #include "record-full.h"
2c2fa1
 #include "linux-record.h"
2c2fa1
 
2c2fa1
-/* Supported register note sections.  */
2c2fa1
-static struct core_regset_section amd64_linux_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", 27 * 8, "general-purpose" },
2c2fa1
-  { ".reg2", 512, "floating-point" },
2c2fa1
-  { ".reg-xstate", I386_XSTATE_MAX_SIZE, "XSAVE extended state" },
2c2fa1
-  { NULL, 0 }
2c2fa1
-};
2c2fa1
-
2c2fa1
 /* Mapping between the general-purpose registers in `struct user'
2c2fa1
    format and GDB's register cache layout.  */
2c2fa1
 
2c2fa1
@@ -1376,6 +1367,19 @@
2c2fa1
     }
2c2fa1
 }
2c2fa1
 
2c2fa1
+/* Iterate over core file register note sections.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+amd64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
2c2fa1
+					  iterate_over_regset_sections_cb *cb,
2c2fa1
+					  void *cb_data,
2c2fa1
+					  const struct regcache *regcache)
2c2fa1
+{
2c2fa1
+  cb (".reg", 27 * 8, "general-purpose", cb_data);
2c2fa1
+  cb (".reg2", 512, "floating-point", cb_data);
2c2fa1
+  cb (".reg-xstate", I386_XSTATE_MAX_SIZE, "XSAVE extended state", cb_data);
2c2fa1
+}
2c2fa1
+
2c2fa1
 static void
2c2fa1
 amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch)
2c2fa1
 {
2c2fa1
@@ -1410,8 +1414,9 @@
2c2fa1
   /* GNU/Linux uses the dynamic linker included in the GNU C Library.  */
2c2fa1
   set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
2c2fa1
 
2c2fa1
-  /* Install supported register note sections.  */
2c2fa1
-  set_gdbarch_core_regset_sections (gdbarch, amd64_linux_regset_sections);
2c2fa1
+  /* Iterate over core file register note sections.  */
2c2fa1
+  set_gdbarch_iterate_over_regset_sections
2c2fa1
+    (gdbarch, amd64_linux_iterate_over_regset_sections);
2c2fa1
 
2c2fa1
   set_gdbarch_core_read_description (gdbarch,
2c2fa1
 				     amd64_linux_core_read_description);
2c2fa1
Index: gdb-7.6.1/gdb/i386-linux-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/i386-linux-tdep.c	2016-02-21 21:41:37.020617839 +0100
2c2fa1
+++ gdb-7.6.1/gdb/i386-linux-tdep.c	2016-02-21 21:41:44.948669651 +0100
2c2fa1
@@ -52,28 +52,6 @@
2c2fa1
 #include "features/i386/i386-mmx-linux.c"
2c2fa1
 #include "features/i386/i386-avx-linux.c"
2c2fa1
 
2c2fa1
-/* Supported register note sections.  */
2c2fa1
-static struct core_regset_section i386_linux_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", 68, "general-purpose" },
2c2fa1
-  { ".reg2", 108, "floating-point" },
2c2fa1
-  { NULL, 0 }
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section i386_linux_sse_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", 68, "general-purpose" },
2c2fa1
-  { ".reg-xfp", 512, "extended floating-point" },
2c2fa1
-  { NULL, 0 }
2c2fa1
-};
2c2fa1
-
2c2fa1
-static struct core_regset_section i386_linux_avx_regset_sections[] =
2c2fa1
-{
2c2fa1
-  { ".reg", 68, "general-purpose" },
2c2fa1
-  { ".reg-xstate", I386_XSTATE_MAX_SIZE, "XSAVE extended state" },
2c2fa1
-  { NULL, 0 }
2c2fa1
-};
2c2fa1
-
2c2fa1
 /* Return non-zero, when the register is in the corresponding register
2c2fa1
    group.  Put the LINUX_ORIG_EAX register in the system group.  */
2c2fa1
 static int
2c2fa1
@@ -661,6 +639,26 @@
2c2fa1
     return tdesc_i386_mmx_linux;
2c2fa1
 }
2c2fa1
 
2c2fa1
+/* Iterate over core file register note sections.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+i386_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
2c2fa1
+					 iterate_over_regset_sections_cb *cb,
2c2fa1
+					 void *cb_data,
2c2fa1
+					 const struct regcache *regcache)
2c2fa1
+{
2c2fa1
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2c2fa1
+
2c2fa1
+  cb (".reg", 68, "general-purpose", cb_data);
2c2fa1
+
2c2fa1
+  if (tdep->xcr0 & I386_XSTATE_AVX)
2c2fa1
+    cb (".reg-xstate", I386_XSTATE_MAX_SIZE, "XSAVE extended state", cb_data);
2c2fa1
+  else if (tdep->xcr0 & I386_XSTATE_SSE)
2c2fa1
+    cb (".reg-xfp", 512, "extended floating-point", cb_data);
2c2fa1
+  else
2c2fa1
+    cb (".reg2", 108, "floating-point", cb_data);
2c2fa1
+}
2c2fa1
+
2c2fa1
 /* Linux kernel shows PC value after the 'int $0x80' instruction even if
2c2fa1
    inferior is still inside the syscall.  On next PTRACE_SINGLESTEP it will
2c2fa1
    finish the syscall but PC will not change.
2c2fa1
@@ -939,14 +937,9 @@
2c2fa1
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
2c2fa1
                                              svr4_fetch_objfile_link_map);
2c2fa1
 
2c2fa1
-  /* Install supported register note sections.  */
2c2fa1
-  if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.avx"))
2c2fa1
-    set_gdbarch_core_regset_sections (gdbarch, i386_linux_avx_regset_sections);
2c2fa1
-  else if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.sse"))
2c2fa1
-    set_gdbarch_core_regset_sections (gdbarch, i386_linux_sse_regset_sections);
2c2fa1
-  else
2c2fa1
-    set_gdbarch_core_regset_sections (gdbarch, i386_linux_regset_sections);
2c2fa1
-
2c2fa1
+  /* Core file support.  */
2c2fa1
+  set_gdbarch_iterate_over_regset_sections
2c2fa1
+    (gdbarch, i386_linux_iterate_over_regset_sections);
2c2fa1
   set_gdbarch_core_read_description (gdbarch,
2c2fa1
 				     i386_linux_core_read_description);
2c2fa1