diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2012-06-26 14:43:01 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2012-06-26 14:43:01 +0000 |
commit | 6fea9e186c3da74c8f0ba9d007522a7575d24a73 (patch) | |
tree | 062ddc7f6108c8f4f26e1f63110472d4abe86058 /gdb/amd64-linux-nat.c | |
parent | a4fd3de5d3170b2c22c9fe4cf236cc31305ef103 (diff) | |
download | gdb-6fea9e186c3da74c8f0ba9d007522a7575d24a73.zip gdb-6fea9e186c3da74c8f0ba9d007522a7575d24a73.tar.gz gdb-6fea9e186c3da74c8f0ba9d007522a7575d24a73.tar.bz2 |
Use PTRACE_PEEKUSER to get fs_base/gs_base
* amd64-linux-nat.c: Include <sys/user.h>.
(ps_get_thread_area): Use PTRACE_PEEKUSER to get fs_base/gs_base
if HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE or
HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE is defined.
* configure.ac: Check if the fs_base and gs_base members of
`struct user_regs_struct' exist.
* config.in: Regenerated.
* configure: Likewise.
Diffstat (limited to 'gdb/amd64-linux-nat.c')
-rw-r--r-- | gdb/amd64-linux-nat.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c index 23eadbd..01982ac 100644 --- a/gdb/amd64-linux-nat.c +++ b/gdb/amd64-linux-nat.c @@ -34,6 +34,7 @@ #include <sys/debugreg.h> #include <sys/syscall.h> #include <sys/procfs.h> +#include <sys/user.h> #include <asm/prctl.h> /* FIXME ezannoni-2003-07-09: we need <sys/reg.h> to be included after <asm/ptrace.h> because the latter redefines FS and GS for no apparent @@ -479,10 +480,39 @@ ps_get_thread_area (const struct ps_prochandle *ph, switch (idx) { case FS: +#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE + { + /* PTRACE_ARCH_PRCTL is obsolete since 2.6.25, where the + fs_base and gs_base fields of user_regs_struct can be + used directly. */ + unsigned long fs; + errno = 0; + fs = ptrace (PTRACE_PEEKUSER, lwpid, + offsetof (struct user_regs_struct, fs_base), 0); + if (errno == 0) + { + *base = (void *) fs; + return PS_OK; + } + } +#endif if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_FS) == 0) return PS_OK; break; case GS: +#ifdef HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE + { + unsigned long gs; + errno = 0; + gs = ptrace (PTRACE_PEEKUSER, lwpid, + offsetof (struct user_regs_struct, gs_base), 0); + if (errno == 0) + { + *base = (void *) gs; + return PS_OK; + } + } +#endif if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_GS) == 0) return PS_OK; break; |