Add the ps_get_thread_area function to m68k to provide debugging of programs linked to libpthread. The code was copied from the MIPS implementations in gdb and gdbserver.
diff -ur gdb-6.6.orig/gdb/gdbserver/linux-m68k-low.c gdb-6.6/gdb/gdbserver/linux-m68k-low.c --- /home/davidw/tmp/gdb-6.6.orig/gdb/gdbserver/linux-m68k-low.c 2011-06-23 09:09:53.977584261 -0500 +++ gdb-6.6/gdb/gdbserver/linux-m68k-low.c 2011-06-23 09:44:41.434490495 -0500 @@ -153,6 +153,26 @@ return 0; } +#include <asm/ptrace.h> +#include "gdb_proc_service.h" + +/* 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 = { m68k_num_regs, m68k_regmap, diff -ur gdb-6.6.orig/gdb/m68klinux-nat.c gdb-6.6/gdb/m68klinux-nat.c --- /home/davidw/tmp/gdb-6.6.orig/gdb/m68klinux-nat.c 2011-06-23 09:09:54.167562142 -0500 +++ gdb-6.6/gdb/m68klinux-nat.c 2011-06-23 09:41:10.319081266 -0500 @@ -67,6 +67,26 @@ 45, 46, 47 }; +#include <asm/ptrace.h> +#include "gdb_proc_service.h" + +/* 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; +} + /* Which ptrace request retrieves which registers? These apply to the corresponding SET requests as well. */ #define NUM_GREGS (18) _______________________________________________ bug-gdb mailing list bug-gdb@gnu.org https://lists.gnu.org/mailman/listinfo/bug-gdb