This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
gdb and gdbserver support for MIPS NPTL
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 17 Mar 2005 10:22:08 -0500
- Subject: gdb and gdbserver support for MIPS NPTL
This patch provides ps_get_thread_area for both mips-linux-gdb and
mips-linux gdbserver. I haven't checked it in yet, because the
corresponding kernel changes and glibc changes are still pending; I'll check
it in when they've been approved. Just wanted to get it off my hard drive.
--
Daniel Jacobowitz
CodeSourcery, LLC
2005-03-17 Daniel Jacobowitz <dan@codesourcery.com>
* linux-mips-low.c: Include "gdb_proc_service.h".
(PTRACE_GET_THREAD_AREA): Define.
(ps_get_thread_area): New function.
* Makefile.in: Update dependencies for linux-mips-low.o,
linux-i386-low.o, and linux-x86-64-low.o.
2005-03-17 Daniel Jacobowitz <dan@codesourcery.com>
* linux-mips-low.c: Include "gdb_proc_service.h".
(PTRACE_GET_THREAD_AREA): Define.
(ps_get_thread_area): New function.
* Makefile.in (mips-linux-nat.o): Update dependencies.
Index: gdb/gdb/gdbserver/linux-mips-low.c
===================================================================
--- gdb.orig/gdb/gdbserver/linux-mips-low.c 2002-06-11 13:32:39.000000000 -0400
+++ gdb/gdb/gdbserver/linux-mips-low.c 2005-02-13 21:59:15.000000000 -0500
@@ -22,6 +22,26 @@
#include "server.h"
#include "linux-low.h"
+#include <sys/ptrace.h>
+
+/* Correct for all GNU/Linux targets (for quite some time). */
+#define GDB_GREGSET_T elf_gregset_t
+#define GDB_FPREGSET_T elf_fpregset_t
+
+#ifndef HAVE_ELF_FPREGSET_T
+/* Make sure we have said types. Not all platforms bring in <linux/elf.h>
+ via <sys/procfs.h>. */
+#ifdef HAVE_LINUX_ELF_H
+#include <linux/elf.h>
+#endif
+#endif
+
+#include "../gdb_proc_service.h"
+
+#ifndef PTRACE_GET_THREAD_AREA
+#define PTRACE_GET_THREAD_AREA 25
+#endif
+
#ifdef HAVE_SYS_REG_H
#include <sys/reg.h>
#endif
@@ -140,6 +160,23 @@ mips_breakpoint_at (CORE_ADDR where)
return 0;
}
+/* Fetch the thread-local storage pointer for libthread_db. */
+
+ps_err_e
+ps_get_thread_area (const struct ps_prochandle *ph,
+ lwpid_t lwpid, int idx, void **base)
+{
+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
+ return PS_ERR;
+
+ /* IDX is the bias from the thread pointer to the beginning of the
+ thread descriptor. It has to be subtracted due to implementation
+ quirks in libthread_db. */
+ *base = (void *) ((char *)*base - idx);
+
+ return PS_OK;
+}
+
struct linux_target_ops the_low_target = {
mips_num_regs,
mips_regmap,
Index: gdb/gdb/gdbserver/Makefile.in
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/gdbserver/Makefile.in,v
retrieving revision 1.28
diff -u -p -r1.28 Makefile.in
--- gdb/gdb/gdbserver/Makefile.in 4 Mar 2005 18:16:25 -0000 1.28
+++ gdb/gdb/gdbserver/Makefile.in 17 Mar 2005 15:19:12 -0000
@@ -261,13 +261,16 @@ linux-low.o: linux-low.c $(linux_low_h)
$(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< @USE_THREAD_DB@
linux-arm-low.o: linux-arm-low.c $(linux_low_h) $(server_h)
-linux-i386-low.o: linux-i386-low.c $(linux_low_h) $(server_h)
+linux-i386-low.o: linux-i386-low.c $(linux_low_h) $(server_h) \
+ $(gdb_proc_service_h)
linux-ia64-low.o: linux-ia64-low.c $(linux_low_h) $(server_h)
-linux-mips-low.o: linux-mips-low.c $(linux_low_h) $(server_h)
+linux-mips-low.o: linux-mips-low.c $(linux_low_h) $(server_h) \
+ $(gdb_proc_service_h)
linux-ppc-low.o: linux-ppc-low.c $(linux_low_h) $(server_h)
linux-s390-low.o: linux-s390-low.c $(linux_low_h) $(server_h)
linux-sh-low.o: linux-sh-low.c $(linux_low_h) $(server_h)
-linux-x86-64-low.o: linux-x86-64-low.c $(linux_low_h) $(server_h)
+linux-x86-64-low.o: linux-x86-64-low.c $(linux_low_h) $(server_h) \
+ $(gdb_proc_service_h)
reg-arm.o : reg-arm.c $(regdef_h)
reg-arm.c : $(srcdir)/../regformats/reg-arm.dat $(regdat_sh)
Index: gdb/gdb/mips-linux-nat.c
===================================================================
--- gdb.orig/gdb/mips-linux-nat.c 2004-10-30 18:54:40.000000000 -0400
+++ gdb/gdb/mips-linux-nat.c 2005-02-13 22:01:48.087685946 -0500
@@ -22,6 +22,12 @@
#include "defs.h"
#include "mips-tdep.h"
+#include "gdb_proc_service.h"
+
+#ifndef PTRACE_GET_THREAD_AREA
+#define PTRACE_GET_THREAD_AREA 25
+#endif
+
/* Pseudo registers can not be read. ptrace does not provide a way to
read (or set) MIPS_PS_REGNUM, and there's no point in reading or
setting MIPS_ZERO_REGNUM. We also can not set BADVADDR, CAUSE, or
@@ -62,3 +68,20 @@ mips_linux_cannot_store_register (int re
else
return 1;
}
+
+/* Fetch the thread-local storage pointer for libthread_db. */
+
+ps_err_e
+ps_get_thread_area (const struct ps_prochandle *ph,
+ lwpid_t lwpid, int idx, void **base)
+{
+ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
+ return PS_ERR;
+
+ /* IDX is the bias from the thread pointer to the beginning of the
+ thread descriptor. It has to be subtracted due to implementation
+ quirks in libthread_db. */
+ *base = (void *) ((char *)*base - idx);
+
+ return PS_OK;
+}
Index: gdb/gdb/Makefile.in
===================================================================
--- gdb.orig/gdb/Makefile.in 2005-01-28 01:40:24.000000000 -0500
+++ gdb/gdb/Makefile.in 2005-02-13 21:59:15.000000000 -0500
@@ -2247,7 +2247,7 @@ mips64obsd-tdep.o: mips64obsd-tdep.c $(d
$(regset_h) $(trad_frame_h) $(tramp_frame_h) $(gdb_assert_h) \
$(gdb_string_h) $(mips_tdep_h) $(solib_svr4_h)
mips-irix-tdep.o: mips-irix-tdep.c $(defs_h) $(osabi_h) $(elf_bfd_h)
-mips-linux-nat.o: mips-linux-nat.c $(defs_h) $(mips_tdep_h)
+mips-linux-nat.o: mips-linux-nat.c $(defs_h) $(mips_tdep_h) $(gdb_proc_service_h)
mips-linux-tdep.o: mips-linux-tdep.c $(defs_h) $(gdbcore_h) $(target_h) \
$(solib_svr4_h) $(osabi_h) $(mips_tdep_h) $(gdb_string_h) \
$(gdb_assert_h) $(frame_h) $(regcache_h) $(trad_frame_h) \