Merge branch 'master' into freebsd
diff --git a/src/os-freebsd.c b/src/os-freebsd.c
index b3c292a..a88b908 100644
--- a/src/os-freebsd.c
+++ b/src/os-freebsd.c
@@ -29,7 +29,6 @@
#include <sys/mman.h>
#include <sys/sysctl.h>
#include <sys/user.h>
-#include <libutil.h>
#include <stdio.h>
#include "libunwind_i.h"
diff --git a/src/x86/Gos-freebsd.c b/src/x86/Gos-freebsd.c
index 2a2b8d1..e88b443 100644
--- a/src/x86/Gos-freebsd.c
+++ b/src/x86/Gos-freebsd.c
@@ -28,6 +28,7 @@
#include <sys/types.h>
#include <signal.h>
+#include <stddef.h>
#include <ucontext.h>
#include <machine/sigframe.h>
@@ -108,7 +109,7 @@
sf = (struct sigframe *)c->dwarf.cfa;
uc_addr = (uintptr_t)&(sf->sf_uc);
- c->uc = (ucontext_t *)uc_addr;
+ c->sigcontext_addr = c->dwarf.cfa;
esp_loc = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_ESP_OFF, 0);
ret = dwarf_get (&c->dwarf, esp_loc, &c->dwarf.cfa);
@@ -150,7 +151,7 @@
return DWARF_REG_LOC (&c->dwarf, reg);
case X86_SCF_FREEBSD_SIGFRAME:
- addr += FREEBSD_UC_MCONTEXT_OFF;
+ addr += offsetof(struct sigframe, sf_uc) + FREEBSD_UC_MCONTEXT_OFF;
break;
case X86_SCF_FREEBSD_SIGFRAME4:
diff --git a/src/x86_64/Gos-freebsd.c b/src/x86_64/Gos-freebsd.c
index dcbc492..0e33aa8 100644
--- a/src/x86_64/Gos-freebsd.c
+++ b/src/x86_64/Gos-freebsd.c
@@ -96,7 +96,7 @@
if (c->sigcontext_format == X86_64_SCF_FREEBSD_SIGFRAME)
{
ucontext = c->dwarf.cfa + offsetof(struct sigframe, sf_uc);
- c->uc = (ucontext_t *)ucontext;
+ c->sigcontext_addr = c->dwarf.cfa;
Debug(1, "signal frame, skip over trampoline\n");
struct dwarf_loc rsp_loc = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_RSP, 0);
@@ -186,7 +186,7 @@
x86_64_sigreturn (unw_cursor_t *cursor)
{
struct cursor *c = (struct cursor *) cursor;
- ucontext_t *uc = c->uc;
+ ucontext_t *uc = c->dwarf.cfa + offsetof(struct sigframe, sf_uc);
Debug (8, "resuming at ip=%llx via sigreturn(%p)\n",
(unsigned long long) c->dwarf.ip, uc);