Replace 'core_regset_sections' by iterator method

The core_regset_sections list in gdbarch (needed for multi-arch
capable core file generation support) is replaced by an iterator
method.  Overall, this reduces the code a bit, and it allows for more
flexibility.

gdb/ChangeLog:

	* amd64-linux-tdep.c (amd64_linux_regset_sections): Remove.
	(amd64_linux_iterate_over_regset_sections): New.
	(amd64_linux_init_abi_common): Don't install the regset section
	list, but the new iterator in gdbarch.
	* arm-linux-tdep.c (arm_linux_fpa_regset_sections)
	(arm_linux_vfp_regset_sections): Remove.  Move combined logic...
	(arm_linux_iterate_over_regset_sections): ...here.  New function.
	(arm_linux_init_abi): Set iterator instead of section list.
	* corelow.c (get_core_registers_cb): New function, logic moved
	from...
	(get_core_registers): ...loop body here.  Use new iterator method
	instead of walking through the regset section list.
	* gdbarch.sh: Remove 'core_regset_sections'.  New method
	'iterate_over_regset_sections'.  New typedef
	'iterate_over_regset_sections_cb'.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Likewise.
	* i386-linux-tdep.c (i386_linux_regset_sections)
	(i386_linux_sse_regset_sections, i386_linux_avx_regset_sections):
	Remove.
	(i386_linux_iterate_over_regset_sections): New.
	(i386_linux_init_abi): Don't choose a regset section list, but
	install new iterator in gdbarch.
	* linux-tdep.c (struct linux_collect_regset_section_cb_data): New.
	(linux_collect_regset_section_cb): New function, logic moved
	from...
	(linux_collect_thread_registers): ...loop body here.  Use iterator
	method instead of walking through list.
	(linux_make_corefile_notes_1): Check for presence of iterator
	method instead of regset section list.
	* ppc-linux-tdep.c (ppc_linux_vsx_regset_sections)
	(ppc_linux_vmx_regset_sections, ppc_linux_fp_regset_sections)
	(ppc64_linux_vsx_regset_sections, ppc64_linux_vmx_regset_sections)
	(ppc64_linux_fp_regset_sections): Remove.  Move combined logic...
	(ppc_linux_iterate_over_regset_sections): ...here.  New function.
	(ppc_linux_init_abi): Don't choose from above regset section
	lists, but install new iterator in gdbarch.
	* regset.h (struct core_regset_section): Remove.
	* s390-linux-tdep.c (struct gdbarch_tdep): Add new fields
	have_linux_v1, have_linux_v2, and have_tdb.
	(s390_linux32_regset_sections, s390_linux32v1_regset_sections)
	(s390_linux32v2_regset_sections, s390_linux64_regset_sections)
	(s390_linux64v1_regset_sections, s390_linux64v2_regset_sections)
	(s390x_linux64_regset_sections, s390x_linux64v1_regset_sections)
	(s390x_linux64v2_regset_sections): Remove.  Move combined logic...
	(s390_iterate_over_regset_sections): ...here.  New function.  Use
	new tdep fields.
	(s390_gdbarch_init): Set new tdep fields.  Don't choose from above
	regset section lists, but install new iterator.
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 316b254..7ab3255 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -257,54 +257,6 @@
 				      readbuf, writebuf);
 }
 
-static struct core_regset_section ppc_linux_vsx_regset_sections[] =
-{
-  { ".reg", 48 * 4, "general-purpose" },
-  { ".reg2", 264, "floating-point" },
-  { ".reg-ppc-vmx", 544, "ppc Altivec" },
-  { ".reg-ppc-vsx", 256, "POWER7 VSX" },
-  { NULL, 0}
-};
-
-static struct core_regset_section ppc_linux_vmx_regset_sections[] =
-{
-  { ".reg", 48 * 4, "general-purpose" },
-  { ".reg2", 264, "floating-point" },
-  { ".reg-ppc-vmx", 544, "ppc Altivec" },
-  { NULL, 0}
-};
-
-static struct core_regset_section ppc_linux_fp_regset_sections[] =
-{
-  { ".reg", 48 * 4, "general-purpose" },
-  { ".reg2", 264, "floating-point" },
-  { NULL, 0}
-};
-
-static struct core_regset_section ppc64_linux_vsx_regset_sections[] =
-{
-  { ".reg", 48 * 8, "general-purpose" },
-  { ".reg2", 264, "floating-point" },
-  { ".reg-ppc-vmx", 544, "ppc Altivec" },
-  { ".reg-ppc-vsx", 256, "POWER7 VSX" },
-  { NULL, 0}
-};
-
-static struct core_regset_section ppc64_linux_vmx_regset_sections[] =
-{
-  { ".reg", 48 * 8, "general-purpose" },
-  { ".reg2", 264, "floating-point" },
-  { ".reg-ppc-vmx", 544, "ppc Altivec" },
-  { NULL, 0}
-};
-
-static struct core_regset_section ppc64_linux_fp_regset_sections[] =
-{
-  { ".reg", 48 * 8, "general-purpose" },
-  { ".reg2", 264, "floating-point" },
-  { NULL, 0}
-};
-
 /* PLT stub in executable.  */
 static struct ppc_insn_pattern powerpc32_plt_stub[] =
   {
@@ -558,6 +510,28 @@
   return NULL;
 }
 
+/* Iterate over supported core file register note sections. */
+
+static void
+ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
+					iterate_over_regset_sections_cb *cb,
+					void *cb_data,
+					const struct regcache *regcache)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int have_altivec = tdep->ppc_vr0_regnum != -1;
+  int have_vsx = tdep->ppc_vsr0_upper_regnum != -1;
+
+  cb (".reg", 48 * tdep->wordsize, "general-purpose", cb_data);
+  cb (".reg2", 264, "floating-point", cb_data);
+
+  if (have_altivec)
+    cb (".reg-ppc-vmx", 544, "ppc Altivec", cb_data);
+
+  if (have_vsx)
+    cb (".reg-ppc-vsx", 256, "POWER7 VSX", cb_data);
+}
+
 static void
 ppc_linux_sigtramp_cache (struct frame_info *this_frame,
 			  struct trad_frame_cache *this_cache,
@@ -1352,19 +1326,6 @@
       else
 	set_gdbarch_gcore_bfd_target (gdbarch, "elf32-powerpc");
 
-      /* Supported register sections.  */
-      if (tdesc_find_feature (info.target_desc,
-			      "org.gnu.gdb.power.vsx"))
-	set_gdbarch_core_regset_sections (gdbarch,
-					  ppc_linux_vsx_regset_sections);
-      else if (tdesc_find_feature (info.target_desc,
-			       "org.gnu.gdb.power.altivec"))
-	set_gdbarch_core_regset_sections (gdbarch,
-					  ppc_linux_vmx_regset_sections);
-      else
-	set_gdbarch_core_regset_sections (gdbarch,
-					  ppc_linux_fp_regset_sections);
-
       if (powerpc_so_ops.in_dynsym_resolve_code == NULL)
 	{
 	  powerpc_so_ops = svr4_so_ops;
@@ -1416,19 +1377,6 @@
 	set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpcle");
       else
 	set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpc");
-
-      /* Supported register sections.  */
-      if (tdesc_find_feature (info.target_desc,
-			      "org.gnu.gdb.power.vsx"))
-	set_gdbarch_core_regset_sections (gdbarch,
-					  ppc64_linux_vsx_regset_sections);
-      else if (tdesc_find_feature (info.target_desc,
-			       "org.gnu.gdb.power.altivec"))
-	set_gdbarch_core_regset_sections (gdbarch,
-					  ppc64_linux_vmx_regset_sections);
-      else
-	set_gdbarch_core_regset_sections (gdbarch,
-					  ppc64_linux_fp_regset_sections);
     }
 
   /* PPC32 uses a different prpsinfo32 compared to most other Linux
@@ -1440,6 +1388,8 @@
   set_gdbarch_regset_from_core_section (gdbarch,
 					ppc_linux_regset_from_core_section);
   set_gdbarch_core_read_description (gdbarch, ppc_linux_core_read_description);
+  set_gdbarch_iterate_over_regset_sections (gdbarch,
+					    ppc_linux_iterate_over_regset_sections);
 
   /* Enable TLS support.  */
   set_gdbarch_fetch_tls_load_module_address (gdbarch,