From 53095e6b3e4a6738e814c8f40cf546dca96a061f Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sun, 7 Mar 2010 23:43:07 +0200 Subject: [PATCH] Code for resume --- src/Makefile.am | 2 +- src/x86/offsets.h | 3 --- src/x86_64/Gresume.c | 15 ++++++++------- src/x86_64/offsets.h | 3 +++ 4 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 src/x86_64/offsets.h diff --git a/src/Makefile.am b/src/Makefile.am index 7cf0d662..0aff658d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -244,7 +244,7 @@ libunwind_x86_la_SOURCES_x86 = $(libunwind_la_SOURCES_x86_common) \ # The list of files that go both into libunwind and libunwind-x86_64: libunwind_la_SOURCES_x86_64_common = $(libunwind_la_SOURCES_common) \ $(dwarf_SOURCES_common) \ - elf64.c elf64.h \ + elf64.c elf64.h x86_64/offsets.h \ x86_64/init.h x86_64/unwind_i.h x86_64/ucontext_i.h \ x86_64/is_fpreg.c x86_64/regname.c diff --git a/src/x86/offsets.h b/src/x86/offsets.h index 63a28729..94307c12 100644 --- a/src/x86/offsets.h +++ b/src/x86/offsets.h @@ -82,6 +82,3 @@ #define LINUX_FPSTATE_XMM5_OFF 0x160 #define LINUX_FPSTATE_XMM6_OFF 0x170 #define LINUX_FPSTATE_XMM7_OFF 0x180 - -/* FreeBSD specific definitions */ -#define FREEBSD_UC_MCONTEXT_OFF 0x10 diff --git a/src/x86_64/Gresume.c b/src/x86_64/Gresume.c index 90207e11..a7822344 100644 --- a/src/x86_64/Gresume.c +++ b/src/x86_64/Gresume.c @@ -27,13 +27,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include +#include "offsets.h" #include "unwind_i.h" #ifndef UNW_REMOTE_ONLY #include -#if defined(__linux) +#if defined __linux /* sigreturn() is a no-op on x86_64 glibc. */ static NORETURN inline long @@ -51,7 +52,6 @@ my_rt_sigreturn (void *new_sp) HIDDEN inline int x86_64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) { -#if defined(__linux) struct cursor *c = (struct cursor *) cursor; ucontext_t *uc = c->uc; @@ -67,7 +67,13 @@ x86_64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) Debug (8, "resuming at ip=%llx via sigreturn(%p)\n", (unsigned long long) c->dwarf.ip, sc); +#if defined __linux__ my_rt_sigreturn (sc); +#elif defined __FreeBSD__ + sigreturn((char *)(c->uc) - FREEBSD_UC_MCONTEXT_OFF); +#else +#error Port me +#endif } else { @@ -75,11 +81,6 @@ x86_64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) (unsigned long long) c->dwarf.ip); setcontext (uc); } -#elif defined(__FreeBSD__) - /* XXXKIB */ -#else -# warning Implement me! -#endif return -UNW_EINVAL; } diff --git a/src/x86_64/offsets.h b/src/x86_64/offsets.h new file mode 100644 index 00000000..80cfe361 --- /dev/null +++ b/src/x86_64/offsets.h @@ -0,0 +1,3 @@ +/* FreeBSD specific definitions */ + +#define FREEBSD_UC_MCONTEXT_OFF 0x10