From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4612 invoked by alias); 17 Mar 2005 15:23:47 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 3223 invoked from network); 17 Mar 2005 15:22:13 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sourceware.org with SMTP; 17 Mar 2005 15:22:13 -0000 Received: from drow by nevyn.them.org with local (Exim 4.44 #1 (Debian)) id 1DBwp6-0008Fd-If for ; Thu, 17 Mar 2005 10:22:08 -0500 Date: Thu, 17 Mar 2005 15:23:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sources.redhat.com Subject: gdb and gdbserver support for MIPS NPTL Message-ID: <20050317152208.GA31661@nevyn.them.org> Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040907i X-SW-Source: 2005-03/txt/msg00226.txt.bz2 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 * 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 * 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 + +/* 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 + via . */ +#ifdef HAVE_LINUX_ELF_H +#include +#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 #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) \