From 0fe85704c41edcaec1c672f3fe45413e4b15fa04 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sat, 15 May 2004 21:06:50 +0000 Subject: [PATCH] * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Replace hexadecimal offset with decimal offset. (amd64obsd_sigcontext_addr): Return correct address for entire signal trampoline. --- gdb/ChangeLog | 5 +++++ gdb/amd64obsd-tdep.c | 22 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9f546b46f02..04e8da8a893 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2004-05-15 Mark Kettenis + * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Replace hexadecimal + offset with decimal offset. + (amd64obsd_sigcontext_addr): Return correct address for entire + signal trampoline. + * vax-tdep.c (vax_frame_num_args): Use get_frame_base_address instead of get_frame_base. diff --git a/gdb/amd64obsd-tdep.c b/gdb/amd64obsd-tdep.c index af110b3447c..f9e0f69fe6e 100644 --- a/gdb/amd64obsd-tdep.c +++ b/gdb/amd64obsd-tdep.c @@ -109,7 +109,7 @@ amd64obsd_sigtramp_p (struct frame_info *next_frame) /* If we can't read the instructions at START_PC, return zero. */ buf = alloca (sizeof sigreturn); - if (target_read_memory (start_pc + 0x7, buf, sizeof sigreturn)) + if (target_read_memory (start_pc + 7, buf, sizeof sigreturn)) return 0; /* Check for sigreturn(2). */ @@ -125,9 +125,25 @@ amd64obsd_sigtramp_p (struct frame_info *next_frame) static CORE_ADDR amd64obsd_sigcontext_addr (struct frame_info *next_frame) { + CORE_ADDR pc = frame_pc_unwind (next_frame); + ULONGEST offset = (pc & (amd64obsd_page_size - 1)); + /* The %rsp register points at `struct sigcontext' upon entry of a - signal trampoline. */ - return frame_unwind_register_unsigned (next_frame, AMD64_RSP_REGNUM); + signal trampoline. The relevant part of the trampoline is + + call *%rax + movq %rsp, %rdi + pushq %rdi + movq $SYS_sigreturn,%rax + int $0x80 + + (see /usr/src/sys/arch/amd64/amd64/locore.S). The `pushq' + instruction clobbers %rsp, but its value is saved in `%rdi'. */ + + if (offset > 6) + return frame_unwind_register_unsigned (next_frame, AMD64_RDI_REGNUM); + else + return frame_unwind_register_unsigned (next_frame, AMD64_RSP_REGNUM); } /* OpenBSD 3.5 or later. */ -- 2.30.2