From c43af07cc890456dbf2562a836961f59f216d880 Mon Sep 17 00:00:00 2001 From: Elena Zannoni Date: Thu, 17 Jul 2003 12:49:52 +0000 Subject: [PATCH] 2003-07-17 Elena Zannoni * Makefile.in (x86-64-linux-nat.o): Update dependencies. * x86-64-linux-nat.c (ps_get_thread_area): New function. Add include of asm/prctl.h, asm/ptrace.h, and gdb_proc_service.h. --- gdb/ChangeLog | 6 ++++++ gdb/Makefile.in | 2 +- gdb/x86-64-linux-nat.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 35dab2eb868..aa707688171 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2003-07-17 Elena Zannoni + + * Makefile.in (x86-64-linux-nat.o): Update dependencies. + * x86-64-linux-nat.c (ps_get_thread_area): New function. Add + include of asm/prctl.h, asm/ptrace.h, and gdb_proc_service.h. + 2003-07-16 Theodore A. Roth * avr-tdep.c (avr_skip_prologue): Return PC unchanged if no prologue diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 7cf0c07fcc1..95e4439d2b4 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -2374,7 +2374,7 @@ wince.o: wince.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) $(gdbcore_h) \ wrapper.o: wrapper.c $(defs_h) $(value_h) $(wrapper_h) x86-64-linux-nat.o: x86-64-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \ $(regcache_h) $(gdb_assert_h) $(gdb_string_h) $(gregset_h) \ - $(x86_64_tdep_h) + $(x86_64_tdep_h) $(gdb_proc_service_h) x86-64-linux-tdep.o: x86-64-linux-tdep.c $(defs_h) $(inferior_h) $(gdbcore_h) \ $(regcache_h) $(osabi_h) $(gdb_string_h) $(x86_64_tdep_h) x86-64-tdep.o: x86-64-tdep.c $(defs_h) \ diff --git a/gdb/x86-64-linux-nat.c b/gdb/x86-64-linux-nat.c index c44c35e8647..87b69c9d853 100644 --- a/gdb/x86-64-linux-nat.c +++ b/gdb/x86-64-linux-nat.c @@ -32,7 +32,17 @@ #include #include #include +#include +/* FIXME ezannoni-2003-07-09: we need to be included after + because the latter redefines FS and GS for no apparent + reason, and those definitions don't match the ones that libpthread_db + uses, which come from . */ +/* ezannoni-2003-07-09: I think this is fixed. The extraneous defs have + been removed from ptrace.h in the kernel. However, better safe than + sorry. */ +#include #include +#include "gdb_proc_service.h" /* Prototypes for supply_gregset etc. */ #include "gregset.h" @@ -306,3 +316,34 @@ x86_64_linux_dr_get_status (void) { return x86_64_linux_dr_get (DR_STATUS); } + +extern ps_err_e +ps_get_thread_area (const struct ps_prochandle *ph, + lwpid_t lwpid, int idx, void **base) +{ + +/* This definition comes from prctl.h, but some kernels may not have it. */ +#ifndef PTRACE_ARCH_PRCTL +#define PTRACE_ARCH_PRCTL 30 +#endif + + /* FIXME: ezannoni-2003-07-09 see comment above about include file order. + We could be getting bogus values for these two. */ + gdb_assert (FS < ELF_NGREG); + gdb_assert (GS < ELF_NGREG); + switch (idx) + { + case FS: + if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_FS) == 0) + return PS_OK; + break; + case GS: + if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_GS) == 0) + return PS_OK; + break; + default: /* Should not happen. */ + return PS_BADADDR; + } + return PS_ERR; /* ptrace failed. */ +} + -- 2.30.2