This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc] Remove hard-coded platform-specific core-file register section names


Hello,

we now have a gdbarch_core_regset_sections callback to define the set of
core file sections needed to represent the architecture's register set.

However, this is currently used only in linux-nat.c when *generating*
Linux core files.  In corelow.c:get_core_registers, the code still uses
an hard-coded list of platform-specific sections to be checked for.
This means that this hard-coded list still needs to be updated whenever
a new patform-specific section is added.

The following patch fixes this by making corelow.c:get_core_registers
use that callback as well.   There was one minor twist in that the
current code provides human-readable names that are use in error or
warning messages if a section cannot be found.  To keep this feature,
the patch adds a human-readable name field to struct core_regset_section
and updates all existing instances.

Tested on powerpc64-linux and i386-linux.  Also tested on s390(x)-linux
in conjunction with the "32-bit binary with 64-bit register set" patch.

Any comments?  I'm planning on committing this next week.

Bye,
Ulrich


ChangeLog:

	* regset.h (struct core_regset_section): Add HUMAN_NAME.
	* i386-linux-tdep.c (i386_linux_regset_sections): Fill in HUMAN_NAME.
	* ppc-linux-tdep.c (ppc_linux_vsx_regset_sections): Likewise.
	(ppc_linux_vmx_regset_sections): Likewise.
	(ppc_linux_fp_regset_sections): Likewise.

	* corelow.c (get_core_register_section): Constify arguments.
	(get_core_registers): Use gdbarch_core_regset_sections instead
	of hard-coded platform-specific register section names.


diff -urNp gdb-orig/gdb/corelow.c gdb-head/gdb/corelow.c
--- gdb-orig/gdb/corelow.c	2009-12-18 19:58:29.000000000 +0100
+++ gdb-head/gdb/corelow.c	2009-12-21 14:44:19.000000000 +0100
@@ -510,9 +510,9 @@ deprecated_core_resize_section_table (in
 
 static void
 get_core_register_section (struct regcache *regcache,
-			   char *name,
+			   const char *name,
 			   int which,
-			   char *human_name,
+			   const char *human_name,
 			   int required)
 {
   static char *section_name = NULL;
@@ -593,6 +593,7 @@ static void
 get_core_registers (struct target_ops *ops,
 		    struct regcache *regcache, int regno)
 {
+  struct core_regset_section *sect_list;
   int i;
 
   if (!(core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch))
@@ -603,16 +604,30 @@ get_core_registers (struct target_ops *o
       return;
     }
 
-  get_core_register_section (regcache,
-			     ".reg", 0, "general-purpose", 1);
-  get_core_register_section (regcache,
-			     ".reg2", 2, "floating-point", 0);
-  get_core_register_section (regcache,
-			     ".reg-xfp", 3, "extended floating-point", 0);
-  get_core_register_section (regcache,
-  			     ".reg-ppc-vmx", 3, "ppc Altivec", 0);
-  get_core_register_section (regcache,
-			     ".reg-ppc-vsx", 4, "POWER7 VSX", 0);
+  sect_list = gdbarch_core_regset_sections (get_regcache_arch (regcache));
+  if (sect_list)
+    while (sect_list->sect_name != NULL)
+      {
+        if (strcmp (sect_list->sect_name, ".reg") == 0)
+	  get_core_register_section (regcache, sect_list->sect_name,
+				     0, sect_list->human_name, 1);
+        else if (strcmp (sect_list->sect_name, ".reg2") == 0)
+	  get_core_register_section (regcache, sect_list->sect_name,
+				     2, sect_list->human_name, 0);
+	else
+	  get_core_register_section (regcache, sect_list->sect_name,
+				     3, sect_list->human_name, 0);
+
+	sect_list++;
+      }
+
+  else
+    {
+      get_core_register_section (regcache,
+				 ".reg", 0, "general-purpose", 1);
+      get_core_register_section (regcache,
+				 ".reg2", 2, "floating-point", 0);
+    }
 
   /* Supply dummy value for all registers not found in the core.  */
   for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
diff -urNp gdb-orig/gdb/i386-linux-tdep.c gdb-head/gdb/i386-linux-tdep.c
--- gdb-orig/gdb/i386-linux-tdep.c	2009-12-18 19:58:29.000000000 +0100
+++ gdb-head/gdb/i386-linux-tdep.c	2009-12-21 14:42:53.000000000 +0100
@@ -49,9 +49,9 @@
 /* Supported register note sections.  */
 static struct core_regset_section i386_linux_regset_sections[] =
 {
-  { ".reg", 144 },
-  { ".reg2", 108 },
-  { ".reg-xfp", 512 },
+  { ".reg", 144, "general-purpose" },
+  { ".reg2", 108, "floating-point" },
+  { ".reg-xfp", 512, "extended floating-point" },
   { NULL, 0 }
 };
 
diff -urNp gdb-orig/gdb/ppc-linux-tdep.c gdb-head/gdb/ppc-linux-tdep.c
--- gdb-orig/gdb/ppc-linux-tdep.c	2009-12-18 19:58:29.000000000 +0100
+++ gdb-head/gdb/ppc-linux-tdep.c	2009-12-21 14:42:53.000000000 +0100
@@ -516,25 +516,25 @@ ppc64_standard_linkage1_target (struct f
 
 static struct core_regset_section ppc_linux_vsx_regset_sections[] =
 {
-  { ".reg", 268 },
-  { ".reg2", 264 },
-  { ".reg-ppc-vmx", 544 },
-  { ".reg-ppc-vsx", 256 },
+  { ".reg", 268, "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", 268 },
-  { ".reg2", 264 },
-  { ".reg-ppc-vmx", 544 },
+  { ".reg", 268, "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", 268 },
-  { ".reg2", 264 },
+  { ".reg", 268, "general-purpose" },
+  { ".reg2", 264, "floating-point" },
   { NULL, 0}
 };
 
diff -urNp gdb-orig/gdb/regset.h gdb-head/gdb/regset.h
--- gdb-orig/gdb/regset.h	2009-12-18 19:58:29.000000000 +0100
+++ gdb-head/gdb/regset.h	2009-12-21 14:42:53.000000000 +0100
@@ -28,6 +28,7 @@ struct core_regset_section
 {
   const char *sect_name;
   int size;
+  const char *human_name;
 };
 
 /* Data structure describing a register set.  */
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]