From 83cacc48884c3d3eb3e479bac7708ad08334b78b Mon Sep 17 00:00:00 2001 From: Krystof Vasa Date: Mon, 19 Aug 2013 09:16:38 +0100 Subject: [PATCH] Trying to fix things --- Gglobal.c | 19 +++++++++++++++++++ Ginit.c | 5 ++--- Makefile | 1 + getcontext.S | 29 ----------------------------- init.h | 4 +++- 5 files changed, 25 insertions(+), 33 deletions(-) diff --git a/Gglobal.c b/Gglobal.c index f3b2413..24c5f33 100644 --- a/Gglobal.c +++ b/Gglobal.c @@ -52,6 +52,24 @@ HIDDEN const uint8_t dwarf_to_unw_regnum_map[DWARF_NUM_PRESERVED_REGS] = UNW_X86_64_R14, UNW_X86_64_R15, UNW_X86_64_RIP, +#ifdef CONFIG_MSABI_SUPPORT + UNW_X86_64_XMM0, + UNW_X86_64_XMM1, + UNW_X86_64_XMM2, + UNW_X86_64_XMM3, + UNW_X86_64_XMM4, + UNW_X86_64_XMM5, + UNW_X86_64_XMM6, + UNW_X86_64_XMM7, + UNW_X86_64_XMM8, + UNW_X86_64_XMM9, + UNW_X86_64_XMM10, + UNW_X86_64_XMM11, + UNW_X86_64_XMM12, + UNW_X86_64_XMM13, + UNW_X86_64_XMM14, + UNW_X86_64_XMM15 +#endif }; HIDDEN void @@ -69,6 +87,7 @@ tdep_init (void) mi_init (); dwarf_init (); tdep_init_mem_validate (); + x86_64_local_addr_space_init (); tdep_init_done = 1; /* signal that we're initialized... */ } diff --git a/Ginit.c b/Ginit.c index 7ad77f8..06c69c2 100644 --- a/Ginit.c +++ b/Ginit.c @@ -29,6 +29,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include +#include #include "unwind_i.h" @@ -238,9 +239,7 @@ get_static_proc_name (unw_addr_space_t as, unw_word_t ip, char *buf, size_t buf_len, unw_word_t *offp, void *arg) { - // TODO - return 0; -// return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp); + return linker_search_symbol_name((caddr_t)ip, buf, buf_len, offp); } HIDDEN void diff --git a/Makefile b/Makefile index 1f62618..65ee582 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ SRCS = libunwind.c \ _ReadULEB.c \ backtrace.c \ dyn-cancel.c \ + dyn-info-list.c \ dyn-register.c \ flush_cache.c \ init.c \ diff --git a/getcontext.S b/getcontext.S index efd800c..49c7ef3 100644 --- a/getcontext.S +++ b/getcontext.S @@ -57,35 +57,6 @@ _Ux86_64_getcontext: movq %rax, UC_MCONTEXT_GREGS_RAX(%rdi) movq %rcx, UC_MCONTEXT_GREGS_RCX(%rdi) -#if defined __linux__ - /* Save fp state (not needed, except for setcontext not - restoring garbage). */ - leaq UC_MCONTEXT_FPREGS_MEM(%rdi),%r8 - movq %r8, UC_MCONTEXT_FPREGS_PTR(%rdi) - fnstenv (%r8) - stmxcsr FPREGS_OFFSET_MXCSR(%r8) -#elif defined __FreeBSD__ - /* Save rflags and segment registers, so that sigreturn(2) - does not complain. */ - pushfq - .cfi_adjust_cfa_offset 8 - popq UC_MCONTEXT_RFLAGS(%rdi) - .cfi_adjust_cfa_offset -8 - movl $0, UC_MCONTEXT_FLAGS(%rdi) - movw %cs, UC_MCONTEXT_CS(%rdi) - movw %ss, UC_MCONTEXT_SS(%rdi) -#if 0 - /* Setting the flags to 0 above disables restore of segment - registers from the context */ - movw %ds, UC_MCONTEXT_DS(%rdi) - movw %es, UC_MCONTEXT_ES(%rdi) - movw %fs, UC_MCONTEXT_FS(%rdi) - movw %gs, UC_MCONTEXT_GS(%rdi) -#endif - movq $UC_MCONTEXT_MC_LEN_VAL, UC_MCONTEXT_MC_LEN(%rdi) -#else -#error Port me -#endif leaq 8(%rsp), %rax /* exclude this call. */ movq %rax, UC_MCONTEXT_GREGS_RSP(%rdi) diff --git a/init.h b/init.h index 906b95d..b9ed055 100644 --- a/init.h +++ b/init.h @@ -29,7 +29,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* Avoid a trip to x86_64_r_uc_addr() for purely local initialisation. */ # define REG_INIT_LOC(c, rlc, ruc) \ - DWARF_LOC ((unw_word_t) &c->uc->uc_mcontext.mc_ ## rlc, 0) + DWARF_REG_LOC (&c->dwarf, UNW_X86_64_ ## ruc) +// ? +// DWARF_LOC ((unw_word_t) &c->uc->uc_mcontext.mc_ ## rlc, 0) static inline int common_init (struct cursor *c, unsigned use_prev_instr)