diff options
author | 2016-01-12 22:49:09 +0000 | |
---|---|---|
committer | 2024-02-23 16:16:18 +0000 | |
commit | ff4e23032673f78177d5d47e7e9812238eaa6553 (patch) | |
tree | 591f322cb442f6fc8143dd1e52b42a6da092a048 /gdb/windows-tdep.h | |
parent | x86: rename vec_encoding and vex_encoding_* (diff) | |
download | binutils-gdb-ff4e23032673f78177d5d47e7e9812238eaa6553.tar.gz binutils-gdb-ff4e23032673f78177d5d47e7e9812238eaa6553.tar.bz2 binutils-gdb-ff4e23032673f78177d5d47e7e9812238eaa6553.zip |
Teach gdb how to unwind cygwin _sigbe and sigdelayed frames
The majority of functions in the cygwin DLL are wrapped by routines
which use an an alternate stack to return via a signal handler if a
signal occured while inside the function. (See [1],[2])
At present, these frames cannot be correctly unwound by gdb. There
doesn't seem to currently be a way to correctly describe these frames
using DWARF CFI.
So instead, write a custom unwinder for _sigbe and sigdelayed frames,
which gets the return address from the alternate stack.
The offset of tls::stackptr from TIB.stacktop is determined by analyzing
the code in _sigbe or sigdelayed.
This can backtrace from _sigbe and from a sighandler through sigdelayed.
Implemented for amd64 and i386
Issues:
1. We should detect if we are in the wrapper after the return address
has been popped off the alternate stack, and if so, fetch the return
address from the register it's been popped into.
2. If there are multiple _sigbe or sigdelayed stack frames to be
unwound, this only unwinds the first one correctly, because we don't
unwind the value of the alternate stack pointer itself.
This is no worse than currently, when we can't even unwind one of
these frame correctly, but isn't quite correct.
I guess this could be handled by defining a pseudo-register to track
its value as we unwind the stack.
[1] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/gendef
[2] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/how-signals-work.txt
Co-Authored-By: Pedro Alves <pedro@palves.net>
Change-Id: I4a0d02c1b85d0aadaab2de3abd584eb4bda5b5cc
Diffstat (limited to 'gdb/windows-tdep.h')
-rw-r--r-- | gdb/windows-tdep.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/windows-tdep.h b/gdb/windows-tdep.h index e786a1d3eb9..f122f7aaa61 100644 --- a/gdb/windows-tdep.h +++ b/gdb/windows-tdep.h @@ -18,6 +18,8 @@ #ifndef WINDOWS_TDEP_H #define WINDOWS_TDEP_H +#include "frame-unwind.h" + struct gdbarch; extern struct cmd_list_element *info_w32_cmdlist; @@ -55,4 +57,22 @@ extern void cygwin_init_abi (struct gdbarch_info info, extern bool is_linked_with_cygwin_dll (bfd *abfd); +/* Cygwin sigwapper unwinder. Unwinds signal frames over + sigbe/sigdelayed. */ + +struct cygwin_sigwrapper_frame_unwind : public frame_unwind +{ + explicit cygwin_sigwrapper_frame_unwind + (gdb::array_view<const gdb::array_view<const gdb_byte>> patterns_list); + + /* Architecture-specific list of instruction patterns to match. + It's a list of patterns instead of single pattern because some + architectures want to match more than one function + (sigbe/sigdelayed & friends). Each potential instruction + sequence is assumed to be followed by 4 bytes for tls::stackptr. + If any pattern in the list matches, then the frame is assumed to + be a sigwrapper frame. */ + gdb::array_view<const gdb::array_view<const gdb_byte>> patterns_list; +}; + #endif |