This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[pushed] gdbserver: 64-bit kernel / 32-inferior, syscall restarting
- From: Pedro Alves <palves at redhat dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Date: Mon, 23 Feb 2015 13:17:36 +0000
- Subject: [pushed] gdbserver: 64-bit kernel / 32-inferior, syscall restarting
- Authentication-results: sourceware.org; auth=none
I pushed this to fix the new FAILs clone-thread_db.exp introduced,
as shown by the buildbot:
https://sourceware.org/ml/gdb-patches/2015-02/msg00653.html
I thought of adding a new test to exercise syscall restarting,
but we already have interrupt.exp for that. I'll post a
follow up series that makes that test work with gdbserver instead.
It's currently skipped due to no inferior i/o when testing with
gdbserver.
---------
[PATCH] gdbserver: 64-bit kernel / 32-inferior, syscall restarting
$ make check RUNTESTFLAGS="--target_board=native-gdbserver/-m32 clone-thread_db.exp"
gdb.log shows:
Running target native-gdbserver/-m32
...
clone-thread_db: src/gdb/testsuite/gdb.threads/clone-thread_db.c:57: thread_fn: Assertion `res != -1' failed.
...
(gdb) FAIL: gdb.threads/clone-thread_db.exp: continue to end
That was waitpid returning -1 / EINTR. We don't see that when testing
with unix/-m32 (native debugging). Turns out to be that when
debugging a 32-bit inferior, a 64-bit GDBserver is reading/writing
$orig_eax from/to the wrong ptrace register buffer offset. When
gdbserver is 64-bit, the ptrace register buffer is in 64-bit layout,
so the register is found at "ORIG_EAX * 8", not at "ORIG_EAX * 4".
Fixes these with --target_board=native-gdbserver/-m32 on x86_64 Fedora 20:
-FAIL: gdb.threads/clone-thread_db.exp: continue to end
+PASS: gdb.threads/clone-thread_db.exp: continue to end
-FAIL: gdb.threads/hand-call-in-threads.exp: all dummies popped
+PASS: gdb.threads/hand-call-in-threads.exp: all dummies popped
PASS: gdb.threads/hand-call-in-threads.exp: breakpoint on all_threads_running
PASS: gdb.threads/hand-call-in-threads.exp: breakpoint on hand_call
PASS: gdb.threads/hand-call-in-threads.exp: disable scheduler locking
@@ -29339,15 +29331,15 @@ PASS: gdb.threads/hand-call-in-threads.e
PASS: gdb.threads/hand-call-in-threads.exp: discard hand call, thread 4
PASS: gdb.threads/hand-call-in-threads.exp: discard hand call, thread 5
PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 1
-FAIL: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 2
-FAIL: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 3
-FAIL: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 4
+PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 2
+PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 3
+PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 4
PASS: gdb.threads/hand-call-in-threads.exp: dummy stack frame number, thread 5
PASS: gdb.threads/hand-call-in-threads.exp: enable scheduler locking
PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 1
-FAIL: gdb.threads/hand-call-in-threads.exp: hand call, thread 2
-FAIL: gdb.threads/hand-call-in-threads.exp: hand call, thread 3
-FAIL: gdb.threads/hand-call-in-threads.exp: hand call, thread 4
+PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 2
+PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 3
+PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 4
PASS: gdb.threads/hand-call-in-threads.exp: hand call, thread 5
PASS: gdb.threads/hand-call-in-threads.exp: prepare to discard hand call, thread 1
PASS: gdb.threads/hand-call-in-threads.exp: prepare to discard hand call, thread 2
gdb/gdbserver/ChangeLog
2015-02-23 Pedro Alves <palves@redhat.com>
* linux-x86-low.c (REGSIZE): Define in both 32-bit and 64-bit
modes.
(x86_fill_gregset, x86_store_gregset): Use it when handling
$orig_eax.
---
gdb/gdbserver/ChangeLog | 7 +++++++
gdb/gdbserver/linux-x86-low.c | 7 +++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index cfdb3e7..d724e6c 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,10 @@
+2015-02-23 Pedro Alves <palves@redhat.com>
+
+ * linux-x86-low.c (REGSIZE): Define in both 32-bit and 64-bit
+ modes.
+ (x86_fill_gregset, x86_store_gregset): Use it when handling
+ $orig_eax.
+
2015-02-20 Pedro Alves <palves@redhat.com>
* thread-db.c: Include "nat/linux-procfs.h".
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 2c3fccc..e58a7ac 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -176,6 +176,7 @@ static /*const*/ int i386_regmap[] =
/* So code below doesn't have to care, i386 or amd64. */
#define ORIG_EAX ORIG_RAX
+#define REGSIZE 8
static const int x86_64_regmap[] =
{
@@ -221,6 +222,8 @@ static /*const*/ int i386_regmap[] =
#define I386_NUM_REGS (sizeof (i386_regmap) / sizeof (i386_regmap[0]))
+#define REGSIZE 4
+
#endif
#ifdef __x86_64__
@@ -374,7 +377,7 @@ x86_fill_gregset (struct regcache *regcache, void *buf)
collect_register (regcache, i, ((char *) buf) + i386_regmap[i]);
collect_register_by_name (regcache, "orig_eax",
- ((char *) buf) + ORIG_EAX * 4);
+ ((char *) buf) + ORIG_EAX * REGSIZE);
}
static void
@@ -396,7 +399,7 @@ x86_store_gregset (struct regcache *regcache, const void *buf)
supply_register (regcache, i, ((char *) buf) + i386_regmap[i]);
supply_register_by_name (regcache, "orig_eax",
- ((char *) buf) + ORIG_EAX * 4);
+ ((char *) buf) + ORIG_EAX * REGSIZE);
}
static void
--
1.9.3