This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFC/i385newframe] Fix sigtramp unwinder.
- From: Michal Ludvig <mludvig at suse dot cz>
- To: Mark Kettenis <kettenis at chello dot nl>
- Cc: GDB Patches <gdb-patches at sources dot redhat dot com>
- Date: Wed, 28 May 2003 16:39:23 +0200
- Subject: [RFC/i385newframe] Fix sigtramp unwinder.
- Organization: SuSE CR, s.r.o.
Hi,
this patch fixes x86_64_linux_sigcontext_addr() which returned wrong
address, and consequently enables unwinding from signal handlers.
Detailed explanation of this change is in the comment in the patch.
OK to apply?
Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz
2003-05-28 Michal Ludvig <mludvig@suse.cz>
* x86-64-linux-tdep.c (x86_64_linux_sigcontext_addr):
Correctly determine sigcontext address.
Index: x86-64-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-tdep.c,v
retrieving revision 1.17.18.1
diff -u -p -c -r1.17.18.1 x86-64-linux-tdep.c
*** x86-64-linux-tdep.c 17 May 2003 15:09:15 -0000 1.17.18.1
--- x86-64-linux-tdep.c 28 May 2003 14:32:12 -0000
*************** x86_64_linux_sigcontext_addr (struct fra
*** 110,124 ****
CORE_ADDR sp, ucontext_addr;
char buf[8];
frame_unwind_register (next_frame, SP_REGNUM, buf);
sp = extract_unsigned_integer (buf, 8);
! /* The sigcontext structure is part of the user context. A pointer
! to the user context is passed as the third argument to the signal
! handler. */
! read_memory (sp + 16, buf, 8);
! ucontext_addr = extract_unsigned_integer (buf, 8);
! return ucontext_addr + X86_64_LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
}
--- 110,126 ----
CORE_ADDR sp, ucontext_addr;
char buf[8];
+ /* The sigcontext structure is part of the user context. A pointer
+ to the user context is passed as the third argument to the signal
+ handler, i.e. in register RDX. Unfortunately RDX isn't a callee
+ saved register and so it's unwound value isn't reliable.
+ Fortunately struct ucontext is right above the return address from
+ the signal handler, i.e. also unwound RSP points to the user context
+ and we can use it instead of RDX. */
frame_unwind_register (next_frame, SP_REGNUM, buf);
sp = extract_unsigned_integer (buf, 8);
! return sp + X86_64_LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
}