[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GDB m68k debug multi-thread application fails: capability not availa
From: |
lars71dk |
Subject: |
Re: GDB m68k debug multi-thread application fails: capability not available [PATCH 1/2] gdb-6.6-m68k-pthread.patch |
Date: |
Fri, 31 May 2013 06:05:39 -0700 (PDT) |
User-agent: |
G2/1.0 |
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)