From: "David S. Miller" <davem@davemloft.net>
To: gdb-patches@sources.redhat.com
Cc: drow@false.org, mark.kettenis@xs4all.nl
Subject: [PATCH]: Use core regset when possible in linux-nat.c
Date: Thu, 06 Apr 2006 22:06:00 -0000 [thread overview]
Message-ID: <20060406.150330.76592441.davem@davemloft.net> (raw)
As discussed in:
http://sources.redhat.com/ml/gdb/2006-04/msg00030.html
Some Linux platforms have different ptrace vs. core file
register layouts.
The suggested way to handle this is to use the core regset
interfaces. Not all Linux target support that yet, so we
have to check and use the old code if the target does not
have core regset support.
Tested on sparc*-*-linux* Both gdb.base/corefile.exp and
gdb.base/gcore.exp pass (*1), which is what I was originally trying to
achieve :-)
Ok to apply?
*1: The test in corefile.exp to look at the mmap() area pointed
to by buf2 fails due to a Linux kernel bug, it doesn't dump
mmap() areas which have not been written to into the core
file so gdb can't look at it. I've posted a patch to linux-kernel
already suggesting to take away that check in the ELF core dumper.
2006-04-06 David S. Miller <davem@sunset.davemloft.net>
* linux-nat.c (linux_nat_do_thread_registers): Use the
regset_from_core_section infrastructure if the target
supports it.
* Makefile.in: Update dependencies.
--- ./linux-nat.c.~1~ 2006-04-05 18:08:11.000000000 -0700
+++ ./linux-nat.c 2006-04-06 14:56:06.000000000 -0700
@@ -36,6 +36,7 @@
#include "gdbthread.h"
#include "gdbcmd.h"
#include "regcache.h"
+#include "regset.h"
#include "inf-ptrace.h"
#include "auxv.h"
#include <sys/param.h> /* for MAXPATHLEN */
@@ -2529,21 +2530,49 @@ linux_nat_do_thread_registers (bfd *obfd
gdb_fpxregset_t fpxregs;
#endif
unsigned long lwp = ptid_get_lwp (ptid);
-
- fill_gregset (&gregs, -1);
+ struct gdbarch *gdbarch = current_gdbarch;
+ const struct regset *regset;
+ int core_regset_p;
+
+ core_regset_p = gdbarch_regset_from_core_section_p (gdbarch);
+ if (core_regset_p)
+ {
+ regset = gdbarch_regset_from_core_section (gdbarch, ".reg",
+ sizeof (gregs));
+ regset->collect_regset (regset, current_regcache, -1,
+ &gregs, sizeof (gregs));
+ }
+ else
+ fill_gregset (&gregs, -1);
note_data = (char *) elfcore_write_prstatus (obfd,
note_data,
note_size,
lwp,
stop_signal, &gregs);
- fill_fpregset (&fpregs, -1);
+ if (core_regset_p)
+ {
+ regset = gdbarch_regset_from_core_section (gdbarch, ".reg2",
+ sizeof (fpregs));
+ regset->collect_regset (regset, current_regcache, -1,
+ &fpregs, sizeof (fpregs));
+ }
+ else
+ fill_fpregset (&fpregs, -1);
note_data = (char *) elfcore_write_prfpreg (obfd,
note_data,
note_size,
&fpregs, sizeof (fpregs));
#ifdef FILL_FPXREGSET
- fill_fpxregset (&fpxregs, -1);
+ if (core_regset_p)
+ {
+ regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp",
+ sizeof (fpxregs));
+ regset->collect_regset (regset, current_regcache, -1,
+ &fpxregs, sizeof (fpxregs));
+ }
+ else
+ fill_fpxregset (&fpxregs, -1);
note_data = (char *) elfcore_write_prxfpreg (obfd,
note_data,
note_size,
--- ./Makefile.in.~1~ 2006-04-05 15:55:07.000000000 -0700
+++ ./Makefile.in 2006-04-06 14:56:33.000000000 -0700
@@ -2195,8 +2195,8 @@ linux-fork.o: linux-fork.c $(defs_h) $(i
$(linux_nat_h)
linux-nat.o: linux-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdb_string_h) \
$(gdb_wait_h) $(gdb_assert_h) $(linux_nat_h) $(gdbthread_h) \
- $(gdbcmd_h) $(regcache_h) $(inf_ptrace_h) $(auxv_h) $(elf_bfd_h) \
- $(gregset_h) $(gdbcore_h) $(gdbthread_h) $(gdb_stat_h) \
+ $(gdbcmd_h) $(regcache_h) $(regset_h) $(inf_ptrace_h) $(auxv_h) \
+ $(elf_bfd_h) $(gregset_h) $(gdbcore_h) $(gdbthread_h) $(gdb_stat_h) \
$(linux_fork_h)
linux-thread-db.o: linux-thread-db.c $(defs_h) $(gdb_assert_h) \
$(gdb_proc_service_h) $(gdb_thread_db_h) $(bfd_h) $(exceptions_h) \
next reply other threads:[~2006-04-06 22:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-06 22:06 David S. Miller [this message]
2006-04-08 20:34 ` Daniel Jacobowitz
2006-04-08 21:54 ` David S. Miller
2006-05-05 20:15 ` Daniel Jacobowitz
2006-05-05 22:40 ` David S. Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060406.150330.76592441.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=drow@false.org \
--cc=gdb-patches@sources.redhat.com \
--cc=mark.kettenis@xs4all.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox