aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorCarlos Eduardo Seo <cseo@linux.vnet.ibm.com>2008-05-24 16:32:01 +0000
committerCarlos Eduardo Seo <cseo@linux.vnet.ibm.com>2008-05-24 16:32:01 +0000
commit17ea7499a94cca815ea904ccfdb2743d208a6688 (patch)
treea7124b178d90dfeb2bf6b85b58c8fe95222f93c7 /gdb/linux-nat.c
parentbb864ac122ca01559e202562d69b7619027e8e2c (diff)
downloadgdb-17ea7499a94cca815ea904ccfdb2743d208a6688.zip
gdb-17ea7499a94cca815ea904ccfdb2743d208a6688.tar.gz
gdb-17ea7499a94cca815ea904ccfdb2743d208a6688.tar.bz2
* gdbarch.sh: Added new gdbarch struct
core_regset_sections. * gdbarch.c: Refreshed. * gdbarch.h: Refreshed. * regset.h (core_regset_section): Declared. * linux-nat.c (linux_nat_do_thread_registers): Added support for the new gdbarch struct core_regset_sections. * utils.c (host_address_to_string): New function. * defs.h (host_address_to_string): New prototype. * i386-linux-tdep.c (i386_regset_rections): New register sections list for i386. (i386_linux_init_abi): Initialized new gdbarch struct core_regset_sections. * Makefile.in: Updated to reflect dependency changes. * ppc-linux-tdep.c (ppc_regset_sections): Register sections list for ppc. (ppc_linux_init_abi): Initialized new gdbarch struct core_regset_sections
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r--gdb/linux-nat.c80
1 files changed, 51 insertions, 29 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 091e641..47dac59 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -3112,15 +3112,14 @@ linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid,
{
gdb_gregset_t gregs;
gdb_fpregset_t fpregs;
-#ifdef FILL_FPXREGSET
- gdb_fpxregset_t fpxregs;
-#endif
unsigned long lwp = ptid_get_lwp (ptid);
struct regcache *regcache = get_thread_regcache (ptid);
struct gdbarch *gdbarch = get_regcache_arch (regcache);
const struct regset *regset;
int core_regset_p;
struct cleanup *old_chain;
+ struct core_regset_section *sect_list;
+ char *gdb_regset;
old_chain = save_inferior_ptid ();
inferior_ptid = ptid;
@@ -3128,6 +3127,8 @@ linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid,
do_cleanups (old_chain);
core_regset_p = gdbarch_regset_from_core_section_p (gdbarch);
+ sect_list = gdbarch_core_regset_sections (gdbarch);
+
if (core_regset_p
&& (regset = gdbarch_regset_from_core_section (gdbarch, ".reg",
sizeof (gregs))) != NULL
@@ -3143,35 +3144,56 @@ linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid,
lwp,
stop_signal, &gregs);
- if (core_regset_p
- && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2",
- sizeof (fpregs))) != NULL
- && regset->collect_regset != NULL)
- regset->collect_regset (regset, regcache, -1,
- &fpregs, sizeof (fpregs));
- else
- fill_fpregset (regcache, &fpregs, -1);
-
- note_data = (char *) elfcore_write_prfpreg (obfd,
- note_data,
- note_size,
- &fpregs, sizeof (fpregs));
+ /* The loop below uses the new struct core_regset_section, which stores
+ the supported section names and sizes for the core file. Note that
+ note PRSTATUS needs to be treated specially. But the other notes are
+ structurally the same, so they can benefit from the new struct. */
+ if (core_regset_p && sect_list != NULL)
+ while (sect_list->sect_name != NULL)
+ {
+ /* .reg was already handled above. */
+ if (strcmp (sect_list->sect_name, ".reg") == 0)
+ {
+ sect_list++;
+ continue;
+ }
+ regset = gdbarch_regset_from_core_section (gdbarch,
+ sect_list->sect_name,
+ sect_list->size);
+ gdb_assert (regset && regset->collect_regset);
+ gdb_regset = xmalloc (sect_list->size);
+ regset->collect_regset (regset, regcache, -1,
+ gdb_regset, sect_list->size);
+ note_data = (char *) elfcore_write_register_note (obfd,
+ note_data,
+ note_size,
+ sect_list->sect_name,
+ gdb_regset,
+ sect_list->size);
+ xfree (gdb_regset);
+ sect_list++;
+ }
-#ifdef FILL_FPXREGSET
- if (core_regset_p
- && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp",
- sizeof (fpxregs))) != NULL
- && regset->collect_regset != NULL)
- regset->collect_regset (regset, regcache, -1,
- &fpxregs, sizeof (fpxregs));
+ /* For architectures that does not have the struct core_regset_section
+ implemented, we use the old method. When all the architectures have
+ the new support, the code below should be deleted. */
else
- fill_fpxregset (regcache, &fpxregs, -1);
+ {
+ if (core_regset_p
+ && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2",
+ sizeof (fpregs))) != NULL
+ && regset->collect_regset != NULL)
+ regset->collect_regset (regset, regcache, -1,
+ &fpregs, sizeof (fpregs));
+ else
+ fill_fpregset (regcache, &fpregs, -1);
+
+ note_data = (char *) elfcore_write_prfpreg (obfd,
+ note_data,
+ note_size,
+ &fpregs, sizeof (fpregs));
+ }
- note_data = (char *) elfcore_write_prxfpreg (obfd,
- note_data,
- note_size,
- &fpxregs, sizeof (fpxregs));
-#endif
return note_data;
}