This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Fix OpenBSD/amd64 sigtramp detection
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: gdb-patches at sourceware dot org
- Date: Sat, 17 Dec 2011 13:22:24 +0100 (CET)
- Subject: [PATCH] Fix OpenBSD/amd64 sigtramp detection
Catching up with a change in our kernel. Committed.
Joel, is this ok for the branch too?
2011-12-17 Mark Kettenis <kettenis@gnu.org>
* amd64obsd-tdep.c (amd64obsd_sigtramp_p): Detect new signal
trampoline to be introduced in OpenBSD 5.0.
Index: amd64obsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64obsd-tdep.c,v
retrieving revision 1.34
diff -u -p -r1.34 amd64obsd-tdep.c
--- amd64obsd-tdep.c 18 Mar 2011 18:52:29 -0000 1.34
+++ amd64obsd-tdep.c 17 Dec 2011 12:19:16 -0000
@@ -88,12 +88,18 @@ amd64obsd_sigtramp_p (struct frame_info
{
CORE_ADDR pc = get_frame_pc (this_frame);
CORE_ADDR start_pc = (pc & ~(amd64obsd_page_size - 1));
- const gdb_byte sigreturn[] =
+ const gdb_byte osigreturn[] =
{
0x48, 0xc7, 0xc0,
0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
0xcd, 0x80 /* int $0x80 */
};
+ const gdb_byte sigreturn[] =
+ {
+ 0x48, 0xc7, 0xc0,
+ 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
+ 0x0f, 0x05 /* syscall */
+ };
size_t buflen = (sizeof sigreturn) + 1;
gdb_byte *buf;
char *name;
@@ -116,9 +122,12 @@ amd64obsd_sigtramp_p (struct frame_info
/* Check for sigreturn(2). Depending on how the assembler encoded
the `movq %rsp, %rdi' instruction, the code starts at offset 6 or
- 7. */
+ 7. OpenBSD 5.0 and later use the `syscall' instruction. Older
+ versions use `int $0x80'. Check for both. */
if (memcmp (buf, sigreturn, sizeof sigreturn)
- && memcpy (buf + 1, sigreturn, sizeof sigreturn))
+ && memcmp (buf + 1, sigreturn, sizeof sigreturn)
+ && memcmp (buf, osigreturn, sizeof osigreturn)
+ && memcmp (buf + 1, osigreturn, sizeof osigreturn))
return 0;
return 1;