From d35574abac364ff210ab77eb290155d4e48f89df Mon Sep 17 00:00:00 2001 From: Krystof Vasa Date: Mon, 12 Aug 2013 11:00:32 +0100 Subject: [PATCH] Prepping x86_64 compilation --- ...reate_addr_space.c => Gcreate_addr_space.c | 0 x86_64/Gget_proc_info.c => Gget_proc_info.c | 0 x86_64/Gget_save_loc.c => Gget_save_loc.c | 0 x86_64/Gglobal.c => Gglobal.c | 0 x86_64/Ginit.c => Ginit.c | 0 x86_64/Ginit_local.c => Ginit_local.c | 0 x86_64/Gos-freebsd.c => Gos-freebsd.c | 0 x86_64/Gregs.c => Gregs.c | 0 x86_64/Gresume.c => Gresume.c | 0 x86_64/Gstash_frame.c => Gstash_frame.c | 0 x86_64/Gstep.c => Gstep.c | 0 x86_64/Gtrace.c => Gtrace.c | 0 ...reate_addr_space.c => Lcreate_addr_space.c | 0 x86/Lget_proc_info.c => Lget_proc_info.c | 0 x86/Lget_save_loc.c => Lget_save_loc.c | 0 x86_64/Lglobal.c => Lglobal.c | 0 x86/Linit.c => Linit.c | 0 x86/Linit_local.c => Linit_local.c | 0 x86/Linit_remote.c => Linit_remote.c | 0 x86/Los-freebsd.c => Los-freebsd.c | 0 x86/Los-linux.c => Los-linux.c | 0 x86/Lregs.c => Lregs.c | 0 x86/Lresume.c => Lresume.c | 0 x86_64/Lstash_frame.c => Lstash_frame.c | 0 x86/Lstep.c => Lstep.c | 0 x86_64/Ltrace.c => Ltrace.c | 0 Makefile | 36 +- x86_64/getcontext.S => getcontext.S | 0 x86_64/init.h => init.h | 0 x86_64/is_fpreg.c => is_fpreg.c | 0 x86_64/longjmp.S => longjmp.S | 0 x86_64/offsets.h => offsets.h | 0 x86_64/regname.c => regname.c | 0 x86_64/setcontext.S => setcontext.S | 0 x86_64/siglongjmp.S => siglongjmp.S | 0 x86_64/ucontext_i.h => ucontext_i.h | 0 x86_64/unwind_i.h => unwind_i.h | 0 x86/Gcreate_addr_space.c | 58 --- x86/Gget_proc_info.c | 45 --- x86/Gget_save_loc.c | 133 ------- x86/Gglobal.c | 67 ---- x86/Ginit.c | 243 ------------ x86/Ginit_local.c | 56 --- x86/Ginit_remote.c | 56 --- x86/Gos-freebsd.c | 364 ------------------ x86/Gos-linux.c | 307 --------------- x86/Gregs.c | 178 --------- x86/Gresume.c | 82 ---- x86/Gstep.c | 115 ------ x86/Lglobal.c | 5 - x86/getcontext-freebsd.S | 112 ------ x86/getcontext-linux.S | 74 ---- x86/init.h | 70 ---- x86/is_fpreg.c | 34 -- x86/longjmp.S | 39 -- x86/offsets.h | 140 ------- x86/regname.c | 27 -- x86/siglongjmp.S | 92 ----- x86/unwind_i.h | 63 --- x86_64/Ginit_remote.c | 57 --- x86_64/Gos-linux.c | 154 -------- x86_64/Lcreate_addr_space.c | 5 - x86_64/Lget_proc_info.c | 5 - x86_64/Lget_save_loc.c | 5 - x86_64/Linit.c | 5 - x86_64/Linit_local.c | 5 - x86_64/Linit_remote.c | 5 - x86_64/Los-freebsd.c | 5 - x86_64/Los-linux.c | 5 - x86_64/Lregs.c | 5 - x86_64/Lresume.c | 5 - x86_64/Lstep.c | 5 - 72 files changed, 35 insertions(+), 2627 deletions(-) rename x86_64/Gcreate_addr_space.c => Gcreate_addr_space.c (100%) rename x86_64/Gget_proc_info.c => Gget_proc_info.c (100%) rename x86_64/Gget_save_loc.c => Gget_save_loc.c (100%) rename x86_64/Gglobal.c => Gglobal.c (100%) rename x86_64/Ginit.c => Ginit.c (100%) rename x86_64/Ginit_local.c => Ginit_local.c (100%) rename x86_64/Gos-freebsd.c => Gos-freebsd.c (100%) rename x86_64/Gregs.c => Gregs.c (100%) rename x86_64/Gresume.c => Gresume.c (100%) rename x86_64/Gstash_frame.c => Gstash_frame.c (100%) rename x86_64/Gstep.c => Gstep.c (100%) rename x86_64/Gtrace.c => Gtrace.c (100%) rename x86/Lcreate_addr_space.c => Lcreate_addr_space.c (100%) rename x86/Lget_proc_info.c => Lget_proc_info.c (100%) rename x86/Lget_save_loc.c => Lget_save_loc.c (100%) rename x86_64/Lglobal.c => Lglobal.c (100%) rename x86/Linit.c => Linit.c (100%) rename x86/Linit_local.c => Linit_local.c (100%) rename x86/Linit_remote.c => Linit_remote.c (100%) rename x86/Los-freebsd.c => Los-freebsd.c (100%) rename x86/Los-linux.c => Los-linux.c (100%) rename x86/Lregs.c => Lregs.c (100%) rename x86/Lresume.c => Lresume.c (100%) rename x86_64/Lstash_frame.c => Lstash_frame.c (100%) rename x86/Lstep.c => Lstep.c (100%) rename x86_64/Ltrace.c => Ltrace.c (100%) rename x86_64/getcontext.S => getcontext.S (100%) rename x86_64/init.h => init.h (100%) rename x86_64/is_fpreg.c => is_fpreg.c (100%) rename x86_64/longjmp.S => longjmp.S (100%) rename x86_64/offsets.h => offsets.h (100%) rename x86_64/regname.c => regname.c (100%) rename x86_64/setcontext.S => setcontext.S (100%) rename x86_64/siglongjmp.S => siglongjmp.S (100%) rename x86_64/ucontext_i.h => ucontext_i.h (100%) rename x86_64/unwind_i.h => unwind_i.h (100%) delete mode 100644 x86/Gcreate_addr_space.c delete mode 100644 x86/Gget_proc_info.c delete mode 100644 x86/Gget_save_loc.c delete mode 100644 x86/Gglobal.c delete mode 100644 x86/Ginit.c delete mode 100644 x86/Ginit_local.c delete mode 100644 x86/Ginit_remote.c delete mode 100644 x86/Gos-freebsd.c delete mode 100644 x86/Gos-linux.c delete mode 100644 x86/Gregs.c delete mode 100644 x86/Gresume.c delete mode 100644 x86/Gstep.c delete mode 100644 x86/Lglobal.c delete mode 100644 x86/getcontext-freebsd.S delete mode 100644 x86/getcontext-linux.S delete mode 100644 x86/init.h delete mode 100644 x86/is_fpreg.c delete mode 100644 x86/longjmp.S delete mode 100644 x86/offsets.h delete mode 100644 x86/regname.c delete mode 100644 x86/siglongjmp.S delete mode 100644 x86/unwind_i.h delete mode 100644 x86_64/Ginit_remote.c delete mode 100644 x86_64/Gos-linux.c delete mode 100644 x86_64/Lcreate_addr_space.c delete mode 100644 x86_64/Lget_proc_info.c delete mode 100644 x86_64/Lget_save_loc.c delete mode 100644 x86_64/Linit.c delete mode 100644 x86_64/Linit_local.c delete mode 100644 x86_64/Linit_remote.c delete mode 100644 x86_64/Los-freebsd.c delete mode 100644 x86_64/Los-linux.c delete mode 100644 x86_64/Lregs.c delete mode 100644 x86_64/Lresume.c delete mode 100644 x86_64/Lstep.c diff --git a/x86_64/Gcreate_addr_space.c b/Gcreate_addr_space.c similarity index 100% rename from x86_64/Gcreate_addr_space.c rename to Gcreate_addr_space.c diff --git a/x86_64/Gget_proc_info.c b/Gget_proc_info.c similarity index 100% rename from x86_64/Gget_proc_info.c rename to Gget_proc_info.c diff --git a/x86_64/Gget_save_loc.c b/Gget_save_loc.c similarity index 100% rename from x86_64/Gget_save_loc.c rename to Gget_save_loc.c diff --git a/x86_64/Gglobal.c b/Gglobal.c similarity index 100% rename from x86_64/Gglobal.c rename to Gglobal.c diff --git a/x86_64/Ginit.c b/Ginit.c similarity index 100% rename from x86_64/Ginit.c rename to Ginit.c diff --git a/x86_64/Ginit_local.c b/Ginit_local.c similarity index 100% rename from x86_64/Ginit_local.c rename to Ginit_local.c diff --git a/x86_64/Gos-freebsd.c b/Gos-freebsd.c similarity index 100% rename from x86_64/Gos-freebsd.c rename to Gos-freebsd.c diff --git a/x86_64/Gregs.c b/Gregs.c similarity index 100% rename from x86_64/Gregs.c rename to Gregs.c diff --git a/x86_64/Gresume.c b/Gresume.c similarity index 100% rename from x86_64/Gresume.c rename to Gresume.c diff --git a/x86_64/Gstash_frame.c b/Gstash_frame.c similarity index 100% rename from x86_64/Gstash_frame.c rename to Gstash_frame.c diff --git a/x86_64/Gstep.c b/Gstep.c similarity index 100% rename from x86_64/Gstep.c rename to Gstep.c diff --git a/x86_64/Gtrace.c b/Gtrace.c similarity index 100% rename from x86_64/Gtrace.c rename to Gtrace.c diff --git a/x86/Lcreate_addr_space.c b/Lcreate_addr_space.c similarity index 100% rename from x86/Lcreate_addr_space.c rename to Lcreate_addr_space.c diff --git a/x86/Lget_proc_info.c b/Lget_proc_info.c similarity index 100% rename from x86/Lget_proc_info.c rename to Lget_proc_info.c diff --git a/x86/Lget_save_loc.c b/Lget_save_loc.c similarity index 100% rename from x86/Lget_save_loc.c rename to Lget_save_loc.c diff --git a/x86_64/Lglobal.c b/Lglobal.c similarity index 100% rename from x86_64/Lglobal.c rename to Lglobal.c diff --git a/x86/Linit.c b/Linit.c similarity index 100% rename from x86/Linit.c rename to Linit.c diff --git a/x86/Linit_local.c b/Linit_local.c similarity index 100% rename from x86/Linit_local.c rename to Linit_local.c diff --git a/x86/Linit_remote.c b/Linit_remote.c similarity index 100% rename from x86/Linit_remote.c rename to Linit_remote.c diff --git a/x86/Los-freebsd.c b/Los-freebsd.c similarity index 100% rename from x86/Los-freebsd.c rename to Los-freebsd.c diff --git a/x86/Los-linux.c b/Los-linux.c similarity index 100% rename from x86/Los-linux.c rename to Los-linux.c diff --git a/x86/Lregs.c b/Lregs.c similarity index 100% rename from x86/Lregs.c rename to Lregs.c diff --git a/x86/Lresume.c b/Lresume.c similarity index 100% rename from x86/Lresume.c rename to Lresume.c diff --git a/x86_64/Lstash_frame.c b/Lstash_frame.c similarity index 100% rename from x86_64/Lstash_frame.c rename to Lstash_frame.c diff --git a/x86/Lstep.c b/Lstep.c similarity index 100% rename from x86/Lstep.c rename to Lstep.c diff --git a/x86_64/Ltrace.c b/Ltrace.c similarity index 100% rename from x86_64/Ltrace.c rename to Ltrace.c diff --git a/Makefile b/Makefile index 6addeca..d7fb3c1 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,39 @@ KMOD = libunwind SRCS = libunwind.c \ - Unwind.c + Unwind.c \ + Gcreate_addr_space.c \ + getcontext.S \ + Gget_proc_info.c \ + Gget_save_loc.c \ + Gglobal.c \ + Ginit_local.c \ + Ginit.c \ + Gos-freebsd.c \ + Gregs.c \ + Gresume.c \ + Gstash_frame.c \ + Gstep.c \ + Gtrace.c \ + init.h \ + is_fpreg.c \ + Lcreate_addr_space.c \ + Lget_proc_info.c \ + Lget_save_loc.c \ + Lglobal.c \ + Linit_local.c \ + Linit_remote.c \ + Linit.c \ + longjmp.S \ + Los-freebsd.c \ + Los-linux.c \ + Lregs.c \ + Lresume.c \ + Lstash_frame.c \ + Lstep.c \ + Ltrace.c \ + offsets.h \ + regname.c \ + setcontext.S \ + siglongjmp.S .include diff --git a/x86_64/getcontext.S b/getcontext.S similarity index 100% rename from x86_64/getcontext.S rename to getcontext.S diff --git a/x86_64/init.h b/init.h similarity index 100% rename from x86_64/init.h rename to init.h diff --git a/x86_64/is_fpreg.c b/is_fpreg.c similarity index 100% rename from x86_64/is_fpreg.c rename to is_fpreg.c diff --git a/x86_64/longjmp.S b/longjmp.S similarity index 100% rename from x86_64/longjmp.S rename to longjmp.S diff --git a/x86_64/offsets.h b/offsets.h similarity index 100% rename from x86_64/offsets.h rename to offsets.h diff --git a/x86_64/regname.c b/regname.c similarity index 100% rename from x86_64/regname.c rename to regname.c diff --git a/x86_64/setcontext.S b/setcontext.S similarity index 100% rename from x86_64/setcontext.S rename to setcontext.S diff --git a/x86_64/siglongjmp.S b/siglongjmp.S similarity index 100% rename from x86_64/siglongjmp.S rename to siglongjmp.S diff --git a/x86_64/ucontext_i.h b/ucontext_i.h similarity index 100% rename from x86_64/ucontext_i.h rename to ucontext_i.h diff --git a/x86_64/unwind_i.h b/unwind_i.h similarity index 100% rename from x86_64/unwind_i.h rename to unwind_i.h diff --git a/x86/Gcreate_addr_space.c b/x86/Gcreate_addr_space.c deleted file mode 100644 index 5b07940..0000000 --- a/x86/Gcreate_addr_space.c +++ /dev/null @@ -1,58 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include - -#include "unwind_i.h" - -#if defined(_LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN) -#define __LITTLE_ENDIAN _LITTLE_ENDIAN -#endif - -PROTECTED unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as; - - /* - * x86 supports only little-endian. - */ - if (byte_order != 0 && byte_order != __LITTLE_ENDIAN) - return NULL; - - as = malloc (sizeof (*as)); - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - return as; -#endif -} diff --git a/x86/Gget_proc_info.c b/x86/Gget_proc_info.c deleted file mode 100644 index a533483..0000000 --- a/x86/Gget_proc_info.c +++ /dev/null @@ -1,45 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "unwind_i.h" - -PROTECTED int -unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) -{ - struct cursor *c = (struct cursor *) cursor; - - if (dwarf_make_proc_info (&c->dwarf) < 0) - { - /* On x86, it's relatively common to be missing DWARF unwind - info. We don't want to fail in that case, because the - frame-chain still would let us do a backtrace at least. */ - memset (pi, 0, sizeof (*pi)); - pi->start_ip = c->dwarf.ip; - pi->end_ip = c->dwarf.ip + 1; - return 0; - } - *pi = c->dwarf.pi; - return 0; -} diff --git a/x86/Gget_save_loc.c b/x86/Gget_save_loc.c deleted file mode 100644 index e8cc79e..0000000 --- a/x86/Gget_save_loc.c +++ /dev/null @@ -1,133 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "unwind_i.h" - -PROTECTED int -unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) -{ - struct cursor *c = (struct cursor *) cursor; - dwarf_loc_t loc; - - loc = DWARF_NULL_LOC; /* default to "not saved" */ - - switch (reg) - { - case UNW_X86_EIP: loc = c->dwarf.loc[EIP]; break; - case UNW_X86_CFA: break; - case UNW_X86_EAX: loc = c->dwarf.loc[EAX]; break; - case UNW_X86_ECX: loc = c->dwarf.loc[ECX]; break; - case UNW_X86_EDX: loc = c->dwarf.loc[EDX]; break; - case UNW_X86_EBX: loc = c->dwarf.loc[EBX]; break; - case UNW_X86_ESP: loc = c->dwarf.loc[ESP]; break; - case UNW_X86_EBP: loc = c->dwarf.loc[EBP]; break; - case UNW_X86_ESI: loc = c->dwarf.loc[ESI]; break; - case UNW_X86_EDI: loc = c->dwarf.loc[EDI]; break; - case UNW_X86_EFLAGS: loc = c->dwarf.loc[EFLAGS]; break; - case UNW_X86_TRAPNO: loc = c->dwarf.loc[TRAPNO]; break; - case UNW_X86_ST0: loc = c->dwarf.loc[ST0]; break; - - case UNW_X86_FCW: - case UNW_X86_FSW: - case UNW_X86_FTW: - case UNW_X86_FOP: - case UNW_X86_FCS: - case UNW_X86_FIP: - case UNW_X86_FEA: - case UNW_X86_FDS: - case UNW_X86_MXCSR: - case UNW_X86_GS: - case UNW_X86_FS: - case UNW_X86_ES: - case UNW_X86_DS: - case UNW_X86_SS: - case UNW_X86_CS: - case UNW_X86_TSS: - case UNW_X86_LDT: - loc = x86_scratch_loc (c, reg); - break; - - /* stacked fp registers */ - case UNW_X86_ST1: - case UNW_X86_ST2: - case UNW_X86_ST3: - case UNW_X86_ST4: - case UNW_X86_ST5: - case UNW_X86_ST6: - case UNW_X86_ST7: - /* SSE fp registers */ - case UNW_X86_XMM0_lo: - case UNW_X86_XMM0_hi: - case UNW_X86_XMM1_lo: - case UNW_X86_XMM1_hi: - case UNW_X86_XMM2_lo: - case UNW_X86_XMM2_hi: - case UNW_X86_XMM3_lo: - case UNW_X86_XMM3_hi: - case UNW_X86_XMM4_lo: - case UNW_X86_XMM4_hi: - case UNW_X86_XMM5_lo: - case UNW_X86_XMM5_hi: - case UNW_X86_XMM6_lo: - case UNW_X86_XMM6_hi: - case UNW_X86_XMM7_lo: - case UNW_X86_XMM7_hi: - case UNW_X86_XMM0: - case UNW_X86_XMM1: - case UNW_X86_XMM2: - case UNW_X86_XMM3: - case UNW_X86_XMM4: - case UNW_X86_XMM5: - case UNW_X86_XMM6: - case UNW_X86_XMM7: - loc = x86_scratch_loc (c, reg); - break; - - default: - break; - } - - memset (sloc, 0, sizeof (*sloc)); - - if (DWARF_IS_NULL_LOC (loc)) - { - sloc->type = UNW_SLT_NONE; - return 0; - } - -#if !defined(UNW_LOCAL_ONLY) - if (DWARF_IS_REG_LOC (loc)) - { - sloc->type = UNW_SLT_REG; - sloc->u.regnum = DWARF_GET_LOC (loc); - } - else -#endif - { - sloc->type = UNW_SLT_MEMORY; - sloc->u.addr = DWARF_GET_LOC (loc); - } - return 0; -} diff --git a/x86/Gglobal.c b/x86/Gglobal.c deleted file mode 100644 index 033a788..0000000 --- a/x86/Gglobal.c +++ /dev/null @@ -1,67 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "unwind_i.h" -#include "dwarf_i.h" - -HIDDEN define_lock (x86_lock); -HIDDEN int tdep_init_done; - -/* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c. */ - -HIDDEN const uint8_t dwarf_to_unw_regnum_map[19] = - { - UNW_X86_EAX, UNW_X86_ECX, UNW_X86_EDX, UNW_X86_EBX, - UNW_X86_ESP, UNW_X86_EBP, UNW_X86_ESI, UNW_X86_EDI, - UNW_X86_EIP, UNW_X86_EFLAGS, UNW_X86_TRAPNO, - UNW_X86_ST0, UNW_X86_ST1, UNW_X86_ST2, UNW_X86_ST3, - UNW_X86_ST4, UNW_X86_ST5, UNW_X86_ST6, UNW_X86_ST7 - }; - -HIDDEN void -tdep_init (void) -{ - intrmask_t saved_mask; - - sigfillset (&unwi_full_mask); - - lock_acquire (&x86_lock, saved_mask); - { - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - mi_init (); - - dwarf_init (); - -#ifndef UNW_REMOTE_ONLY - x86_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - } - out: - lock_release (&x86_lock, saved_mask); -} diff --git a/x86/Ginit.c b/x86/Ginit.c deleted file mode 100644 index b8890a3..0000000 --- a/x86/Ginit.c +++ /dev/null @@ -1,243 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -PROTECTED unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -PROTECTED unw_addr_space_t unw_local_addr_space = &local_addr_space; - -# ifdef UNW_LOCAL_ONLY - -HIDDEN void * -tdep_uc_addr (ucontext_t *uc, int reg) -{ - return x86_r_uc_addr (uc, reg); -} - -# endif /* UNW_LOCAL_ONLY */ - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - -/* XXX fix me: there is currently no way to locate the dyn-info list - by a remote unwinder. On ia64, this is done via a special - unwind-table entry. Perhaps something similar can be done with - DWARF2 unwind info. */ - -static void -put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list; - return 0; -} - -#define PAGE_SIZE 4096 -#define PAGE_START(a) ((a) & ~(PAGE_SIZE-1)) - -/* Cache of already validated addresses */ -#define NLGA 4 -static unw_word_t last_good_addr[NLGA]; -static int lga_victim; - -static int -validate_mem (unw_word_t addr) -{ - int i, victim; -#ifdef HAVE_MINCORE - unsigned char mvec[2]; /* Unaligned access may cross page boundary */ -#endif - size_t len; - - if (PAGE_START(addr + sizeof (unw_word_t) - 1) == PAGE_START(addr)) - len = PAGE_SIZE; - else - len = PAGE_SIZE * 2; - - addr = PAGE_START(addr); - - if (addr == 0) - return -1; - - for (i = 0; i < NLGA; i++) - { - if (last_good_addr[i] && (addr == last_good_addr[i])) - return 0; - } - -#ifdef HAVE_MINCORE - if (mincore ((void *) addr, len, mvec) == -1) -#else - if (msync ((void *) addr, len, MS_ASYNC) == -1) -#endif - return -1; - - victim = lga_victim; - for (i = 0; i < NLGA; i++) { - if (!last_good_addr[victim]) { - last_good_addr[victim++] = addr; - return 0; - } - victim = (victim + 1) % NLGA; - } - - /* All slots full. Evict the victim. */ - last_good_addr[victim] = addr; - victim = (victim + 1) % NLGA; - lga_victim = victim; - - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - if (write) - { - Debug (16, "mem[%x] <- %x\n", addr, *val); - *(unw_word_t *) addr = *val; - } - else - { - /* validate address */ - const struct cursor *c = (const struct cursor *)arg; - if (c && c->validate && validate_mem(addr)) - return -1; - *val = *(unw_word_t *) addr; - Debug (16, "mem[%x] -> %x\n", addr, *val); - } - return 0; -} - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write, - void *arg) -{ - unw_word_t *addr; - ucontext_t *uc = ((struct cursor *)arg)->uc; - - if (unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = x86_r_uc_addr (uc, reg))) - goto badreg; - - if (write) - { - *(unw_word_t *) addr = *val; - Debug (12, "%s <- %x\n", unw_regname (reg), *val); - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "%s -> %x\n", unw_regname (reg), *val); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - ucontext_t *uc = ((struct cursor *)arg)->uc; - unw_fpreg_t *addr; - - if (!unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = x86_r_uc_addr (uc, reg))) - goto badreg; - - if (write) - { - Debug (12, "%s <- %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - *(unw_fpreg_t *) addr = *val; - } - else - { - *val = *(unw_fpreg_t *) addr; - Debug (12, "%s -> %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - /* attempt to access a non-preserved register */ - return -UNW_EBADREG; -} - -static int -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) -{ - return _Uelf32_get_proc_name (as, getpid (), ip, buf, buf_len, offp); -} - -HIDDEN void -x86_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.caching_policy = UNW_CACHE_GLOBAL; - local_addr_space.acc.find_proc_info = dwarf_find_proc_info; - local_addr_space.acc.put_unwind_info = put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = access_fpreg; - local_addr_space.acc.resume = x86_local_resume; - local_addr_space.acc.get_proc_name = get_static_proc_name; - unw_flush_cache (&local_addr_space, 0, 0); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/x86/Ginit_local.c b/x86/Ginit_local.c deleted file mode 100644 index 412663b..0000000 --- a/x86/Ginit_local.c +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "unwind_i.h" -#include "init.h" - -#ifdef UNW_REMOTE_ONLY - -PROTECTED int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - return -UNW_EINVAL; -} - -#else /* !UNW_REMOTE_ONLY */ - -PROTECTED int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = unw_local_addr_space; - c->dwarf.as_arg = c; - c->uc = uc; - c->validate = 0; - return common_init (c, 1); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/x86/Ginit_remote.c b/x86/Ginit_remote.c deleted file mode 100644 index c889905..0000000 --- a/x86/Ginit_remote.c +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "init.h" -#include "unwind_i.h" - -PROTECTED int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = as; - c->dwarf.as_arg = as_arg; - if (as == unw_local_addr_space) - { - c->dwarf.as_arg = c; - c->uc = as_arg; - } - else - { - c->dwarf.as_arg = as_arg; - c->uc = 0; - } - return common_init (c, 0); -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/x86/Gos-freebsd.c b/x86/Gos-freebsd.c deleted file mode 100644 index 247c35f..0000000 --- a/x86/Gos-freebsd.c +++ /dev/null @@ -1,364 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include - -#include "unwind_i.h" -#include "offsets.h" - -PROTECTED int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, w1, w2, w3, w4, w5, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors (as); - arg = c->dwarf.as_arg; - - /* Check if EIP points at sigreturn() sequence. It can be: -sigcode+4: from amd64 freebsd32 environment -8d 44 24 20 lea 0x20(%esp),%eax -50 push %eax -b8 a1 01 00 00 mov $0x1a1,%eax -50 push %eax -cd 80 int $0x80 - -sigcode+4: from real i386 -8d 44 24 20 lea 0x20(%esp),%eax -50 push %eax -f7 40 54 00 02 00 testl $0x20000,0x54(%eax) -75 03 jne sigcode+21 -8e 68 14 mov 0x14(%eax),%gs -b8 a1 01 00 00 mov $0x1a1,%eax -50 push %eax -cd 80 int $0x80 - -freebsd4_sigcode+4: -XXX -osigcode: -XXX - */ - ip = c->dwarf.ip; - ret = X86_SCF_NONE; - c->sigcontext_format = ret; - if ((*a->access_mem) (as, ip, &w0, 0, arg) < 0 || - (*a->access_mem) (as, ip + 4, &w1, 0, arg) < 0 || - (*a->access_mem) (as, ip + 8, &w2, 0, arg) < 0 || - (*a->access_mem) (as, ip + 12, &w3, 0, arg) < 0) - return ret; - if (w0 == 0x2024448d && w1 == 0x01a1b850 && w2 == 0xcd500000 && - (w3 & 0xff) == 0x80) - ret = X86_SCF_FREEBSD_SIGFRAME; - else { - if ((*a->access_mem) (as, ip + 16, &w4, 0, arg) < 0 || - (*a->access_mem) (as, ip + 20, &w5, 0, arg) < 0) - return ret; - if (w0 == 0x2024448d && w1 == 0x5440f750 && w2 == 0x75000200 && - w3 == 0x14688e03 && w4 == 0x0001a1b8 && w5 == 0x80cd5000) - ret = X86_SCF_FREEBSD_SIGFRAME; - } - Debug (16, "returning %d\n", ret); - c->sigcontext_format = ret; - return (ret); -} - -PROTECTED int -unw_handle_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - if (c->sigcontext_format == X86_SCF_FREEBSD_SIGFRAME) { - struct sigframe *sf; - uintptr_t uc_addr; - struct dwarf_loc esp_loc; - - sf = (struct sigframe *)c->dwarf.cfa; - uc_addr = (uintptr_t)&(sf->sf_uc); - 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); - if (ret < 0) - { - Debug (2, "returning 0\n"); - return 0; - } - - c->dwarf.loc[EIP] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EIP_OFF, 0); - c->dwarf.loc[ESP] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_ESP_OFF, 0); - c->dwarf.loc[EAX] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EAX_OFF, 0); - c->dwarf.loc[ECX] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_ECX_OFF, 0); - c->dwarf.loc[EDX] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EDX_OFF, 0); - c->dwarf.loc[EBX] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EBX_OFF, 0); - c->dwarf.loc[EBP] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EBP_OFF, 0); - c->dwarf.loc[ESI] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_ESI_OFF, 0); - c->dwarf.loc[EDI] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EDI_OFF, 0); - c->dwarf.loc[EFLAGS] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EFLAGS_OFF, 0); - c->dwarf.loc[TRAPNO] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_TRAPNO_OFF, 0); - c->dwarf.loc[ST0] = DWARF_NULL_LOC; - } else { - Debug (8, "Gstep: not handling frame format %d\n", c->sigcontext_format); - abort(); - } - return 0; -} - -HIDDEN dwarf_loc_t -x86_get_scratch_loc (struct cursor *c, unw_regnum_t reg) -{ - unw_word_t addr = c->sigcontext_addr, off, xmm_off; - unw_word_t fpstate, fpformat; - int ret, is_fpstate = 0, is_xmmstate = 0; - - switch (c->sigcontext_format) - { - case X86_SCF_NONE: - return DWARF_REG_LOC (&c->dwarf, reg); - - case X86_SCF_FREEBSD_SIGFRAME: - addr += offsetof(struct sigframe, sf_uc) + FREEBSD_UC_MCONTEXT_OFF; - break; - - case X86_SCF_FREEBSD_SIGFRAME4: - abort(); - break; - - case X86_SCF_FREEBSD_OSIGFRAME: - /* XXXKIB */ - abort(); - break; - - case X86_SCF_FREEBSD_SYSCALL: - /* XXXKIB */ - abort(); - break; - - default: - /* XXXKIB */ - abort(); - break; - } - - off = 0; /* shut gcc warning */ - switch (reg) - { - case UNW_X86_GS: off = FREEBSD_UC_MCONTEXT_GS_OFF; break; - case UNW_X86_FS: off = FREEBSD_UC_MCONTEXT_FS_OFF; break; - case UNW_X86_ES: off = FREEBSD_UC_MCONTEXT_ES_OFF; break; - case UNW_X86_DS: off = FREEBSD_UC_MCONTEXT_SS_OFF; break; - case UNW_X86_EDI: off = FREEBSD_UC_MCONTEXT_EDI_OFF; break; - case UNW_X86_ESI: off = FREEBSD_UC_MCONTEXT_ESI_OFF; break; - case UNW_X86_EBP: off = FREEBSD_UC_MCONTEXT_EBP_OFF; break; - case UNW_X86_ESP: off = FREEBSD_UC_MCONTEXT_ESP_OFF; break; - case UNW_X86_EBX: off = FREEBSD_UC_MCONTEXT_EBX_OFF; break; - case UNW_X86_EDX: off = FREEBSD_UC_MCONTEXT_EDX_OFF; break; - case UNW_X86_ECX: off = FREEBSD_UC_MCONTEXT_ECX_OFF; break; - case UNW_X86_EAX: off = FREEBSD_UC_MCONTEXT_EAX_OFF; break; - case UNW_X86_TRAPNO: off = FREEBSD_UC_MCONTEXT_TRAPNO_OFF; break; - case UNW_X86_EIP: off = FREEBSD_UC_MCONTEXT_EIP_OFF; break; - case UNW_X86_CS: off = FREEBSD_UC_MCONTEXT_CS_OFF; break; - case UNW_X86_EFLAGS: off = FREEBSD_UC_MCONTEXT_EFLAGS_OFF; break; - case UNW_X86_SS: off = FREEBSD_UC_MCONTEXT_SS_OFF; break; - - case UNW_X86_FCW: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_CW_OFF; - xmm_off = FREEBSD_UC_MCONTEXT_CW_XMM_OFF; - break; - case UNW_X86_FSW: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_SW_OFF; - xmm_off = FREEBSD_UC_MCONTEXT_SW_XMM_OFF; - break; - case UNW_X86_FTW: - is_fpstate = 1; - xmm_off = FREEBSD_UC_MCONTEXT_TAG_XMM_OFF; - off = FREEBSD_UC_MCONTEXT_TAG_OFF; - break; - case UNW_X86_FCS: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_CSSEL_OFF; - xmm_off = FREEBSD_UC_MCONTEXT_CSSEL_XMM_OFF; - break; - case UNW_X86_FIP: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_IPOFF_OFF; - xmm_off = FREEBSD_UC_MCONTEXT_IPOFF_XMM_OFF; - break; - case UNW_X86_FEA: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_DATAOFF_OFF; - xmm_off = FREEBSD_UC_MCONTEXT_DATAOFF_XMM_OFF; - break; - case UNW_X86_FDS: - is_fpstate = 1; - off = FREEBSD_US_MCONTEXT_DATASEL_OFF; - xmm_off = FREEBSD_US_MCONTEXT_DATASEL_XMM_OFF; - break; - case UNW_X86_MXCSR: - is_fpstate = 1; - is_xmmstate = 1; - xmm_off = FREEBSD_UC_MCONTEXT_MXCSR_XMM_OFF; - break; - - /* stacked fp registers */ - case UNW_X86_ST0: case UNW_X86_ST1: case UNW_X86_ST2: case UNW_X86_ST3: - case UNW_X86_ST4: case UNW_X86_ST5: case UNW_X86_ST6: case UNW_X86_ST7: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_ST0_OFF + 10*(reg - UNW_X86_ST0); - xmm_off = FREEBSD_UC_MCONTEXT_ST0_XMM_OFF + 10*(reg - UNW_X86_ST0); - break; - - /* SSE fp registers */ - case UNW_X86_XMM0_lo: case UNW_X86_XMM0_hi: - case UNW_X86_XMM1_lo: case UNW_X86_XMM1_hi: - case UNW_X86_XMM2_lo: case UNW_X86_XMM2_hi: - case UNW_X86_XMM3_lo: case UNW_X86_XMM3_hi: - case UNW_X86_XMM4_lo: case UNW_X86_XMM4_hi: - case UNW_X86_XMM5_lo: case UNW_X86_XMM5_hi: - case UNW_X86_XMM6_lo: case UNW_X86_XMM6_hi: - case UNW_X86_XMM7_lo: case UNW_X86_XMM7_hi: - is_fpstate = 1; - is_xmmstate = 1; - xmm_off = FREEBSD_UC_MCONTEXT_XMM0_OFF + 8*(reg - UNW_X86_XMM0_lo); - break; - case UNW_X86_XMM0: - case UNW_X86_XMM1: - case UNW_X86_XMM2: - case UNW_X86_XMM3: - case UNW_X86_XMM4: - case UNW_X86_XMM5: - case UNW_X86_XMM6: - case UNW_X86_XMM7: - is_fpstate = 1; - is_xmmstate = 1; - xmm_off = FREEBSD_UC_MCONTEXT_XMM0_OFF + 16*(reg - UNW_X86_XMM0); - break; - - case UNW_X86_FOP: - case UNW_X86_TSS: - case UNW_X86_LDT: - default: - return DWARF_REG_LOC (&c->dwarf, reg); - } - - if (is_fpstate) - { - if ((ret = dwarf_get (&c->dwarf, - DWARF_MEM_LOC (&c->dwarf, addr + FREEBSD_UC_MCONTEXT_FPSTATE_OFF), - &fpstate)) < 0) - return DWARF_NULL_LOC; - if (fpstate == FREEBSD_UC_MCONTEXT_FPOWNED_NONE) - return DWARF_NULL_LOC; - if ((ret = dwarf_get (&c->dwarf, - DWARF_MEM_LOC (&c->dwarf, addr + FREEBSD_UC_MCONTEXT_FPFORMAT_OFF), - &fpformat)) < 0) - return DWARF_NULL_LOC; - if (fpformat == FREEBSD_UC_MCONTEXT_FPFMT_NODEV || - (is_xmmstate && fpformat != FREEBSD_UC_MCONTEXT_FPFMT_XMM)) - return DWARF_NULL_LOC; - if (is_xmmstate) - off = xmm_off; - } - - return DWARF_MEM_LOC (c, addr + off); -} - -#ifndef UNW_REMOTE_ONLY -HIDDEN void * -x86_r_uc_addr (ucontext_t *uc, int reg) -{ - void *addr; - - switch (reg) - { - case UNW_X86_GS: addr = &uc->uc_mcontext.mc_gs; break; - case UNW_X86_FS: addr = &uc->uc_mcontext.mc_fs; break; - case UNW_X86_ES: addr = &uc->uc_mcontext.mc_es; break; - case UNW_X86_DS: addr = &uc->uc_mcontext.mc_ds; break; - case UNW_X86_EAX: addr = &uc->uc_mcontext.mc_eax; break; - case UNW_X86_EBX: addr = &uc->uc_mcontext.mc_ebx; break; - case UNW_X86_ECX: addr = &uc->uc_mcontext.mc_ecx; break; - case UNW_X86_EDX: addr = &uc->uc_mcontext.mc_edx; break; - case UNW_X86_ESI: addr = &uc->uc_mcontext.mc_esi; break; - case UNW_X86_EDI: addr = &uc->uc_mcontext.mc_edi; break; - case UNW_X86_EBP: addr = &uc->uc_mcontext.mc_ebp; break; - case UNW_X86_EIP: addr = &uc->uc_mcontext.mc_eip; break; - case UNW_X86_ESP: addr = &uc->uc_mcontext.mc_esp; break; - case UNW_X86_TRAPNO: addr = &uc->uc_mcontext.mc_trapno; break; - case UNW_X86_CS: addr = &uc->uc_mcontext.mc_cs; break; - case UNW_X86_EFLAGS: addr = &uc->uc_mcontext.mc_eflags; break; - case UNW_X86_SS: addr = &uc->uc_mcontext.mc_ss; break; - - default: - addr = NULL; - } - return addr; -} - -HIDDEN int -x86_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ - struct cursor *c = (struct cursor *) cursor; - ucontext_t *uc = c->uc; - - /* Ensure c->pi is up-to-date. On x86, it's relatively common to be - missing DWARF unwind info. We don't want to fail in that case, - because the frame-chain still would let us do a backtrace at - least. */ - dwarf_make_proc_info (&c->dwarf); - - if (c->sigcontext_format == X86_SCF_NONE) { - Debug (8, "resuming at ip=%x via setcontext()\n", c->dwarf.ip); - setcontext (uc); - abort(); - } else if (c->sigcontext_format == X86_SCF_FREEBSD_SIGFRAME) { - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - - Debug (8, "resuming at ip=%x via sigreturn(%p)\n", c->dwarf.ip, sc); - sigreturn((ucontext_t *)((const char *)sc + FREEBSD_SC_UCONTEXT_OFF)); - abort(); - } else { - Debug (8, "resuming at ip=%x for sigcontext format %d not implemented\n", - c->dwarf.ip, c->sigcontext_format); - abort(); - } - return -UNW_EINVAL; -} - -#endif diff --git a/x86/Gos-linux.c b/x86/Gos-linux.c deleted file mode 100644 index 31f83ba..0000000 --- a/x86/Gos-linux.c +++ /dev/null @@ -1,307 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "unwind_i.h" -#include "offsets.h" - -PROTECTED int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, w1, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors (as); - arg = c->dwarf.as_arg; - - /* Check if EIP points at sigreturn() sequence. On Linux, this is: - - __restore: - 0x58 pop %eax - 0xb8 0x77 0x00 0x00 0x00 movl 0x77,%eax - 0xcd 0x80 int 0x80 - - without SA_SIGINFO, and - - __restore_rt: - 0xb8 0xad 0x00 0x00 0x00 movl 0xad,%eax - 0xcd 0x80 int 0x80 - 0x00 - - if SA_SIGINFO is specified. - */ - ip = c->dwarf.ip; - if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0 - || (ret = (*a->access_mem) (as, ip + 4, &w1, 0, arg)) < 0) - return ret; - ret = ((w0 == 0x0077b858 && w1 == 0x80cd0000) - || (w0 == 0x0000adb8 && (w1 & 0xffffff) == 0x80cd00)); - Debug (16, "returning %d\n", ret); - return ret; -} - -PROTECTED int -unw_handle_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - /* c->esp points at the arguments to the handler. Without - SA_SIGINFO, the arguments consist of a signal number - followed by a struct sigcontext. With SA_SIGINFO, the - arguments consist a signal number, a siginfo *, and a - ucontext *. */ - unw_word_t sc_addr; - unw_word_t siginfo_ptr_addr = c->dwarf.cfa + 4; - unw_word_t sigcontext_ptr_addr = c->dwarf.cfa + 8; - unw_word_t siginfo_ptr, sigcontext_ptr; - struct dwarf_loc esp_loc, siginfo_ptr_loc, sigcontext_ptr_loc; - - siginfo_ptr_loc = DWARF_LOC (siginfo_ptr_addr, 0); - sigcontext_ptr_loc = DWARF_LOC (sigcontext_ptr_addr, 0); - ret = (dwarf_get (&c->dwarf, siginfo_ptr_loc, &siginfo_ptr) - | dwarf_get (&c->dwarf, sigcontext_ptr_loc, &sigcontext_ptr)); - if (ret < 0) - { - Debug (2, "returning 0\n"); - return 0; - } - if (siginfo_ptr < c->dwarf.cfa - || siginfo_ptr > c->dwarf.cfa + 256 - || sigcontext_ptr < c->dwarf.cfa - || sigcontext_ptr > c->dwarf.cfa + 256) - { - /* Not plausible for SA_SIGINFO signal */ - c->sigcontext_format = X86_SCF_LINUX_SIGFRAME; - c->sigcontext_addr = sc_addr = c->dwarf.cfa + 4; - } - else - { - /* If SA_SIGINFO were not specified, we actually read - various segment pointers instead. We believe that at - least fs and _fsh are always zero for linux, so it is - not just unlikely, but impossible that we would end - up here. */ - c->sigcontext_format = X86_SCF_LINUX_RT_SIGFRAME; - c->sigcontext_addr = sigcontext_ptr; - sc_addr = sigcontext_ptr + LINUX_UC_MCONTEXT_OFF; - } - esp_loc = DWARF_LOC (sc_addr + LINUX_SC_ESP_OFF, 0); - ret = dwarf_get (&c->dwarf, esp_loc, &c->dwarf.cfa); - if (ret < 0) - { - Debug (2, "returning 0\n"); - return 0; - } - - c->dwarf.loc[EAX] = DWARF_LOC (sc_addr + LINUX_SC_EAX_OFF, 0); - c->dwarf.loc[ECX] = DWARF_LOC (sc_addr + LINUX_SC_ECX_OFF, 0); - c->dwarf.loc[EDX] = DWARF_LOC (sc_addr + LINUX_SC_EDX_OFF, 0); - c->dwarf.loc[EBX] = DWARF_LOC (sc_addr + LINUX_SC_EBX_OFF, 0); - c->dwarf.loc[EBP] = DWARF_LOC (sc_addr + LINUX_SC_EBP_OFF, 0); - c->dwarf.loc[ESI] = DWARF_LOC (sc_addr + LINUX_SC_ESI_OFF, 0); - c->dwarf.loc[EDI] = DWARF_LOC (sc_addr + LINUX_SC_EDI_OFF, 0); - c->dwarf.loc[EFLAGS] = DWARF_NULL_LOC; - c->dwarf.loc[TRAPNO] = DWARF_NULL_LOC; - c->dwarf.loc[ST0] = DWARF_NULL_LOC; - c->dwarf.loc[EIP] = DWARF_LOC (sc_addr + LINUX_SC_EIP_OFF, 0); - c->dwarf.loc[ESP] = DWARF_LOC (sc_addr + LINUX_SC_ESP_OFF, 0); - - return 0; -} - -HIDDEN dwarf_loc_t -x86_get_scratch_loc (struct cursor *c, unw_regnum_t reg) -{ - unw_word_t addr = c->sigcontext_addr, fpstate_addr, off; - int ret, is_fpstate = 0; - - switch (c->sigcontext_format) - { - case X86_SCF_NONE: - return DWARF_REG_LOC (&c->dwarf, reg); - - case X86_SCF_LINUX_SIGFRAME: - break; - - case X86_SCF_LINUX_RT_SIGFRAME: - addr += LINUX_UC_MCONTEXT_OFF; - break; - - default: - return DWARF_NULL_LOC; - } - - switch (reg) - { - case UNW_X86_GS: off = LINUX_SC_GS_OFF; break; - case UNW_X86_FS: off = LINUX_SC_FS_OFF; break; - case UNW_X86_ES: off = LINUX_SC_ES_OFF; break; - case UNW_X86_DS: off = LINUX_SC_DS_OFF; break; - case UNW_X86_EDI: off = LINUX_SC_EDI_OFF; break; - case UNW_X86_ESI: off = LINUX_SC_ESI_OFF; break; - case UNW_X86_EBP: off = LINUX_SC_EBP_OFF; break; - case UNW_X86_ESP: off = LINUX_SC_ESP_OFF; break; - case UNW_X86_EBX: off = LINUX_SC_EBX_OFF; break; - case UNW_X86_EDX: off = LINUX_SC_EDX_OFF; break; - case UNW_X86_ECX: off = LINUX_SC_ECX_OFF; break; - case UNW_X86_EAX: off = LINUX_SC_EAX_OFF; break; - case UNW_X86_TRAPNO: off = LINUX_SC_TRAPNO_OFF; break; - case UNW_X86_EIP: off = LINUX_SC_EIP_OFF; break; - case UNW_X86_CS: off = LINUX_SC_CS_OFF; break; - case UNW_X86_EFLAGS: off = LINUX_SC_EFLAGS_OFF; break; - case UNW_X86_SS: off = LINUX_SC_SS_OFF; break; - - /* The following is probably not correct for all possible cases. - Somebody who understands this better should review this for - correctness. */ - - case UNW_X86_FCW: is_fpstate = 1; off = LINUX_FPSTATE_CW_OFF; break; - case UNW_X86_FSW: is_fpstate = 1; off = LINUX_FPSTATE_SW_OFF; break; - case UNW_X86_FTW: is_fpstate = 1; off = LINUX_FPSTATE_TAG_OFF; break; - case UNW_X86_FCS: is_fpstate = 1; off = LINUX_FPSTATE_CSSEL_OFF; break; - case UNW_X86_FIP: is_fpstate = 1; off = LINUX_FPSTATE_IPOFF_OFF; break; - case UNW_X86_FEA: is_fpstate = 1; off = LINUX_FPSTATE_DATAOFF_OFF; break; - case UNW_X86_FDS: is_fpstate = 1; off = LINUX_FPSTATE_DATASEL_OFF; break; - case UNW_X86_MXCSR: is_fpstate = 1; off = LINUX_FPSTATE_MXCSR_OFF; break; - - /* stacked fp registers */ - case UNW_X86_ST0: case UNW_X86_ST1: case UNW_X86_ST2: case UNW_X86_ST3: - case UNW_X86_ST4: case UNW_X86_ST5: case UNW_X86_ST6: case UNW_X86_ST7: - is_fpstate = 1; - off = LINUX_FPSTATE_ST0_OFF + 10*(reg - UNW_X86_ST0); - break; - - /* SSE fp registers */ - case UNW_X86_XMM0_lo: case UNW_X86_XMM0_hi: - case UNW_X86_XMM1_lo: case UNW_X86_XMM1_hi: - case UNW_X86_XMM2_lo: case UNW_X86_XMM2_hi: - case UNW_X86_XMM3_lo: case UNW_X86_XMM3_hi: - case UNW_X86_XMM4_lo: case UNW_X86_XMM4_hi: - case UNW_X86_XMM5_lo: case UNW_X86_XMM5_hi: - case UNW_X86_XMM6_lo: case UNW_X86_XMM6_hi: - case UNW_X86_XMM7_lo: case UNW_X86_XMM7_hi: - is_fpstate = 1; - off = LINUX_FPSTATE_XMM0_OFF + 8*(reg - UNW_X86_XMM0_lo); - break; - case UNW_X86_XMM0: - case UNW_X86_XMM1: - case UNW_X86_XMM2: - case UNW_X86_XMM3: - case UNW_X86_XMM4: - case UNW_X86_XMM5: - case UNW_X86_XMM6: - case UNW_X86_XMM7: - is_fpstate = 1; - off = LINUX_FPSTATE_XMM0_OFF + 16*(reg - UNW_X86_XMM0); - break; - - case UNW_X86_FOP: - case UNW_X86_TSS: - case UNW_X86_LDT: - default: - return DWARF_REG_LOC (&c->dwarf, reg); - } - - if (is_fpstate) - { - if ((ret = dwarf_get (&c->dwarf, - DWARF_MEM_LOC (&c->dwarf, - addr + LINUX_SC_FPSTATE_OFF), - &fpstate_addr)) < 0) - return DWARF_NULL_LOC; - - if (!fpstate_addr) - return DWARF_NULL_LOC; - - return DWARF_MEM_LOC (c, fpstate_addr + off); - } - else - return DWARF_MEM_LOC (c, addr + off); -} - -#ifndef UNW_REMOTE_ONLY -HIDDEN void * -x86_r_uc_addr (ucontext_t *uc, int reg) -{ - void *addr; - - switch (reg) - { - case UNW_X86_GS: addr = &uc->uc_mcontext.gregs[REG_GS]; break; - case UNW_X86_FS: addr = &uc->uc_mcontext.gregs[REG_FS]; break; - case UNW_X86_ES: addr = &uc->uc_mcontext.gregs[REG_ES]; break; - case UNW_X86_DS: addr = &uc->uc_mcontext.gregs[REG_DS]; break; - case UNW_X86_EAX: addr = &uc->uc_mcontext.gregs[REG_EAX]; break; - case UNW_X86_EBX: addr = &uc->uc_mcontext.gregs[REG_EBX]; break; - case UNW_X86_ECX: addr = &uc->uc_mcontext.gregs[REG_ECX]; break; - case UNW_X86_EDX: addr = &uc->uc_mcontext.gregs[REG_EDX]; break; - case UNW_X86_ESI: addr = &uc->uc_mcontext.gregs[REG_ESI]; break; - case UNW_X86_EDI: addr = &uc->uc_mcontext.gregs[REG_EDI]; break; - case UNW_X86_EBP: addr = &uc->uc_mcontext.gregs[REG_EBP]; break; - case UNW_X86_EIP: addr = &uc->uc_mcontext.gregs[REG_EIP]; break; - case UNW_X86_ESP: addr = &uc->uc_mcontext.gregs[REG_ESP]; break; - case UNW_X86_TRAPNO: addr = &uc->uc_mcontext.gregs[REG_TRAPNO]; break; - case UNW_X86_CS: addr = &uc->uc_mcontext.gregs[REG_CS]; break; - case UNW_X86_EFLAGS: addr = &uc->uc_mcontext.gregs[REG_EFL]; break; - case UNW_X86_SS: addr = &uc->uc_mcontext.gregs[REG_SS]; break; - - default: - addr = NULL; - } - return addr; -} - -HIDDEN int -x86_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ - struct cursor *c = (struct cursor *) cursor; - ucontext_t *uc = c->uc; - - /* Ensure c->pi is up-to-date. On x86, it's relatively common to be - missing DWARF unwind info. We don't want to fail in that case, - because the frame-chain still would let us do a backtrace at - least. */ - dwarf_make_proc_info (&c->dwarf); - - if (unlikely (c->sigcontext_format != X86_SCF_NONE)) - { - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - - Debug (8, "resuming at ip=%x via sigreturn(%p)\n", c->dwarf.ip, sc); - sigreturn (sc); - } - else - { - Debug (8, "resuming at ip=%x via setcontext()\n", c->dwarf.ip); - setcontext (uc); - } - return -UNW_EINVAL; -} -#endif diff --git a/x86/Gregs.c b/x86/Gregs.c deleted file mode 100644 index 05bc1a3..0000000 --- a/x86/Gregs.c +++ /dev/null @@ -1,178 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2004 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "offsets.h" -#include "unwind_i.h" - -HIDDEN dwarf_loc_t -x86_scratch_loc (struct cursor *c, unw_regnum_t reg) -{ - if (c->sigcontext_addr) - return x86_get_scratch_loc (c, reg); - else - return DWARF_REG_LOC (&c->dwarf, reg); -} - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - dwarf_loc_t loc = DWARF_NULL_LOC; - unsigned int mask; - int arg_num; - - switch (reg) - { - - case UNW_X86_EIP: - if (write) - c->dwarf.ip = *valp; /* also update the EIP cache */ - loc = c->dwarf.loc[EIP]; - break; - - case UNW_X86_CFA: - case UNW_X86_ESP: - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; - return 0; - - case UNW_X86_EAX: - case UNW_X86_EDX: - arg_num = reg - UNW_X86_EAX; - mask = (1 << arg_num); - if (write) - { - c->dwarf.eh_args[arg_num] = *valp; - c->dwarf.eh_valid_mask |= mask; - return 0; - } - else if ((c->dwarf.eh_valid_mask & mask) != 0) - { - *valp = c->dwarf.eh_args[arg_num]; - return 0; - } - else - loc = c->dwarf.loc[(reg == UNW_X86_EAX) ? EAX : EDX]; - break; - - case UNW_X86_ECX: loc = c->dwarf.loc[ECX]; break; - case UNW_X86_EBX: loc = c->dwarf.loc[EBX]; break; - - case UNW_X86_EBP: loc = c->dwarf.loc[EBP]; break; - case UNW_X86_ESI: loc = c->dwarf.loc[ESI]; break; - case UNW_X86_EDI: loc = c->dwarf.loc[EDI]; break; - case UNW_X86_EFLAGS: loc = c->dwarf.loc[EFLAGS]; break; - case UNW_X86_TRAPNO: loc = c->dwarf.loc[TRAPNO]; break; - - case UNW_X86_FCW: - case UNW_X86_FSW: - case UNW_X86_FTW: - case UNW_X86_FOP: - case UNW_X86_FCS: - case UNW_X86_FIP: - case UNW_X86_FEA: - case UNW_X86_FDS: - case UNW_X86_MXCSR: - case UNW_X86_GS: - case UNW_X86_FS: - case UNW_X86_ES: - case UNW_X86_DS: - case UNW_X86_SS: - case UNW_X86_CS: - case UNW_X86_TSS: - case UNW_X86_LDT: - loc = x86_scratch_loc (c, reg); - break; - - default: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; - } - - if (write) - return dwarf_put (&c->dwarf, loc, *valp); - else - return dwarf_get (&c->dwarf, loc, valp); -} - -HIDDEN int -tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, - int write) -{ - struct dwarf_loc loc = DWARF_NULL_LOC; - - switch (reg) - { - case UNW_X86_ST0: - loc = c->dwarf.loc[ST0]; - break; - - /* stacked fp registers */ - case UNW_X86_ST1: - case UNW_X86_ST2: - case UNW_X86_ST3: - case UNW_X86_ST4: - case UNW_X86_ST5: - case UNW_X86_ST6: - case UNW_X86_ST7: - /* SSE fp registers */ - case UNW_X86_XMM0: - case UNW_X86_XMM1: - case UNW_X86_XMM2: - case UNW_X86_XMM3: - case UNW_X86_XMM4: - case UNW_X86_XMM5: - case UNW_X86_XMM6: - case UNW_X86_XMM7: - case UNW_X86_XMM0_lo: - case UNW_X86_XMM0_hi: - case UNW_X86_XMM1_lo: - case UNW_X86_XMM1_hi: - case UNW_X86_XMM2_lo: - case UNW_X86_XMM2_hi: - case UNW_X86_XMM3_lo: - case UNW_X86_XMM3_hi: - case UNW_X86_XMM4_lo: - case UNW_X86_XMM4_hi: - case UNW_X86_XMM5_lo: - case UNW_X86_XMM5_hi: - case UNW_X86_XMM6_lo: - case UNW_X86_XMM6_hi: - case UNW_X86_XMM7_lo: - case UNW_X86_XMM7_hi: - loc = x86_scratch_loc (c, reg); - break; - - default: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; - } - - if (write) - return dwarf_putfp (&c->dwarf, loc, *valp); - else - return dwarf_getfp (&c->dwarf, loc, valp); -} diff --git a/x86/Gresume.c b/x86/Gresume.c deleted file mode 100644 index c39c588..0000000 --- a/x86/Gresume.c +++ /dev/null @@ -1,82 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2004 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include - -#include "unwind_i.h" -#include "offsets.h" - -/* This routine is responsible for copying the register values in - cursor C and establishing them as the current machine state. */ - -static inline int -establish_machine_state (struct cursor *c) -{ - int (*access_reg) (unw_addr_space_t, unw_regnum_t, unw_word_t *, - int write, void *); - int (*access_fpreg) (unw_addr_space_t, unw_regnum_t, unw_fpreg_t *, - int write, void *); - unw_addr_space_t as = c->dwarf.as; - void *arg = c->dwarf.as_arg; - unw_fpreg_t fpval; - unw_word_t val; - int reg; - - access_reg = as->acc.access_reg; - access_fpreg = as->acc.access_fpreg; - - Debug (8, "copying out cursor state\n"); - - for (reg = 0; reg <= UNW_REG_LAST; ++reg) - { - Debug (16, "copying %s %d\n", unw_regname (reg), reg); - if (unw_is_fpreg (reg)) - { - if (tdep_access_fpreg (c, reg, &fpval, 0) >= 0) - (*access_fpreg) (as, reg, &fpval, 1, arg); - } - else - { - if (tdep_access_reg (c, reg, &val, 0) >= 0) - (*access_reg) (as, reg, &val, 1, arg); - } - } - return 0; -} - -PROTECTED int -unw_resume (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - Debug (1, "(cursor=%p)\n", c); - - if ((ret = establish_machine_state (c)) < 0) - return ret; - - return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c, - c->dwarf.as_arg); -} diff --git a/x86/Gstep.c b/x86/Gstep.c deleted file mode 100644 index 0965db2..0000000 --- a/x86/Gstep.c +++ /dev/null @@ -1,115 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "unwind_i.h" -#include "offsets.h" - -PROTECTED int -unw_step (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret, i; - - Debug (1, "(cursor=%p, ip=0x%08x)\n", c, (unsigned) c->dwarf.ip); - - /* Try DWARF-based unwinding... */ - ret = dwarf_step (&c->dwarf); - - if (ret < 0 && ret != -UNW_ENOINFO) - { - Debug (2, "returning %d\n", ret); - return ret; - } - - if (unlikely (ret < 0)) - { - /* DWARF failed, let's see if we can follow the frame-chain - or skip over the signal trampoline. */ - struct dwarf_loc ebp_loc, eip_loc; - - /* We could get here because of missing/bad unwind information. - Validate all addresses before dereferencing. */ - c->validate = 1; - - Debug (13, "dwarf_step() failed (ret=%d), trying frame-chain\n", ret); - - if (unw_is_signal_frame (cursor)) - { - ret = unw_handle_signal_frame(cursor); - if (ret < 0) - { - Debug (2, "returning 0\n"); - return 0; - } - } - else - { - ret = dwarf_get (&c->dwarf, c->dwarf.loc[EBP], &c->dwarf.cfa); - if (ret < 0) - { - Debug (2, "returning %d\n", ret); - return ret; - } - - Debug (13, "[EBP=0x%x] = 0x%x\n", DWARF_GET_LOC (c->dwarf.loc[EBP]), - c->dwarf.cfa); - - ebp_loc = DWARF_LOC (c->dwarf.cfa, 0); - eip_loc = DWARF_LOC (c->dwarf.cfa + 4, 0); - c->dwarf.cfa += 8; - - /* Mark all registers unsaved, since we don't know where - they are saved (if at all), except for the EBP and - EIP. */ - for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; - - c->dwarf.loc[EBP] = ebp_loc; - c->dwarf.loc[EIP] = eip_loc; - } - c->dwarf.ret_addr_column = EIP; - - if (!DWARF_IS_NULL_LOC (c->dwarf.loc[EBP])) - { - ret = dwarf_get (&c->dwarf, c->dwarf.loc[EIP], &c->dwarf.ip); - if (ret < 0) - { - Debug (13, "dwarf_get([EIP=0x%x]) failed\n", DWARF_GET_LOC (c->dwarf.loc[EIP])); - Debug (2, "returning %d\n", ret); - return ret; - } - else - { - Debug (13, "[EIP=0x%x] = 0x%x\n", DWARF_GET_LOC (c->dwarf.loc[EIP]), - c->dwarf.ip); - } - } - else - c->dwarf.ip = 0; - } - ret = (c->dwarf.ip == 0) ? 0 : 1; - Debug (2, "returning %d\n", ret); - return ret; -} diff --git a/x86/Lglobal.c b/x86/Lglobal.c deleted file mode 100644 index 6d7b489..0000000 --- a/x86/Lglobal.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/x86/getcontext-freebsd.S b/x86/getcontext-freebsd.S deleted file mode 100644 index 670eff1..0000000 --- a/x86/getcontext-freebsd.S +++ /dev/null @@ -1,112 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "offsets.h" - - .global _Ux86_getcontext - .type _Ux86_getcontext, @function -_Ux86_getcontext: - .cfi_startproc - pushl %eax - .cfi_adjust_cfa_offset 4 - mov 8(%esp),%eax /* ucontext_t* */ - popl FREEBSD_UC_MCONTEXT_EAX_OFF(%eax) - .cfi_adjust_cfa_offset 4 - movl %ebx, FREEBSD_UC_MCONTEXT_EBX_OFF(%eax) - movl %ecx, FREEBSD_UC_MCONTEXT_ECX_OFF(%eax) - movl %edx, FREEBSD_UC_MCONTEXT_EDX_OFF(%eax) - movl %edi, FREEBSD_UC_MCONTEXT_EDI_OFF(%eax) - movl %esi, FREEBSD_UC_MCONTEXT_ESI_OFF(%eax) - movl %ebp, FREEBSD_UC_MCONTEXT_EBP_OFF(%eax) - - movl (%esp), %ecx - movl %ecx, FREEBSD_UC_MCONTEXT_EIP_OFF(%eax) - - leal 4(%esp), %ecx /* Exclude the return address. */ - movl %ecx, FREEBSD_UC_MCONTEXT_ESP_OFF(%eax) - - xorl %ecx, %ecx - movw %fs, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_FS_OFF(%eax) - movw %gs, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_GS_OFF(%eax) - movw %ds, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_DS_OFF(%eax) - movw %es, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_ES_OFF(%eax) - movw %ss, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_SS_OFF(%eax) - movw %cs, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_CS_OFF(%eax) - - pushfl - .cfi_adjust_cfa_offset 4 - popl FREEBSD_UC_MCONTEXT_EFLAGS_OFF(%eax) - .cfi_adjust_cfa_offset -4 - - movl $0, FREEBSD_UC_MCONTEXT_TRAPNO_OFF(%eax) - - movl $FREEBSD_UC_MCONTEXT_FPOWNED_FPU,\ - FREEBSD_UC_MCONTEXT_OWNEDFP_OFF(%eax) - movl $FREEBSD_UC_MCONTEXT_FPFMT_XMM,\ - FREEBSD_UC_MCONTEXT_FPFORMAT_OFF(%eax) - - /* - * Require CPU with fxsave implemented, and enabled by OS. - * - * If passed ucontext is not aligned to 16-byte boundary, - * save fpu context into temporary aligned location on stack - * and then copy. - */ - leal FREEBSD_UC_MCONTEXT_FPSTATE_OFF(%eax), %edx - testl $0xf, %edx - jne 2f - fxsave (%edx) /* fast path, passed ucontext save area was aligned */ -1: movl $FREEBSD_UC_MCONTEXT_MC_LEN_VAL,\ - FREEBSD_UC_MCONTEXT_MC_LEN_OFF(%eax) - - xorl %eax, %eax - ret - -2: movl %edx, %edi /* not aligned, do the dance */ - subl $512 + 16, %esp /* save area and 16 bytes for alignment */ - .cfi_adjust_cfa_offset 512 + 16 - movl %esp, %edx - orl $0xf, %edx /* align *%edx to 16-byte up */ - incl %edx - fxsave (%edx) - movl %edx, %esi /* copy to the final destination */ - movl $512/4,%ecx - rep; movsl - addl $512 + 16, %esp /* restore the stack */ - .cfi_adjust_cfa_offset -512 - 16 - movl FREEBSD_UC_MCONTEXT_ESI_OFF(%eax), %esi - movl FREEBSD_UC_MCONTEXT_EDI_OFF(%eax), %edi - jmp 1b - - .cfi_endproc - .size _Ux86_getcontext, . - _Ux86_getcontext - - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/x86/getcontext-linux.S b/x86/getcontext-linux.S deleted file mode 100644 index c469dad..0000000 --- a/x86/getcontext-linux.S +++ /dev/null @@ -1,74 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2009 Google, Inc - Contributed by Paul Pluzhnikov - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "offsets.h" - -/* int _Ux86_getcontext (ucontext_t *ucp) - - Saves the machine context in UCP necessary for libunwind. - Unlike the libc implementation, we don't save the signal mask - and hence avoid the cost of a system call per unwind. - -*/ - - .global _Ux86_getcontext - .type _Ux86_getcontext, @function -_Ux86_getcontext: - .cfi_startproc - mov 4(%esp),%eax /* ucontext_t* */ - - /* EAX is not preserved. */ - movl $0, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EAX_OFF)(%eax) - - movl %ebx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EBX_OFF)(%eax) - movl %ecx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_ECX_OFF)(%eax) - movl %edx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EDX_OFF)(%eax) - movl %edi, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EDI_OFF)(%eax) - movl %esi, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_ESI_OFF)(%eax) - movl %ebp, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EBP_OFF)(%eax) - - movl (%esp), %ecx - movl %ecx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EIP_OFF)(%eax) - - leal 4(%esp), %ecx /* Exclude the return address. */ - movl %ecx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_ESP_OFF)(%eax) - - /* glibc getcontext saves FS, but not GS */ - xorl %ecx, %ecx - movw %fs, %cx - movl %ecx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_FS_OFF)(%eax) - - leal LINUX_UC_FPREGS_MEM_OFF(%eax), %ecx - movl %ecx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_FPSTATE_OFF)(%eax) - fnstenv (%ecx) - fldenv (%ecx) - - xor %eax, %eax - ret - .cfi_endproc - .size _Ux86_getcontext, . - _Ux86_getcontext - - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/x86/init.h b/x86/init.h deleted file mode 100644 index f35387d..0000000 --- a/x86/init.h +++ /dev/null @@ -1,70 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "unwind_i.h" - -static inline int -common_init (struct cursor *c, unsigned use_prev_instr) -{ - int ret, i; - - c->dwarf.loc[EAX] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EAX); - c->dwarf.loc[ECX] = DWARF_REG_LOC (&c->dwarf, UNW_X86_ECX); - c->dwarf.loc[EDX] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EDX); - c->dwarf.loc[EBX] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EBX); - c->dwarf.loc[ESP] = DWARF_REG_LOC (&c->dwarf, UNW_X86_ESP); - c->dwarf.loc[EBP] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EBP); - c->dwarf.loc[ESI] = DWARF_REG_LOC (&c->dwarf, UNW_X86_ESI); - c->dwarf.loc[EDI] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EDI); - c->dwarf.loc[EIP] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EIP); - c->dwarf.loc[EFLAGS] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EFLAGS); - c->dwarf.loc[TRAPNO] = DWARF_REG_LOC (&c->dwarf, UNW_X86_TRAPNO); - c->dwarf.loc[ST0] = DWARF_REG_LOC (&c->dwarf, UNW_X86_ST0); - for (i = ST0 + 1; i < DWARF_NUM_PRESERVED_REGS; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[EIP], &c->dwarf.ip); - if (ret < 0) - return ret; - - ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_X86_ESP), - &c->dwarf.cfa); - if (ret < 0) - return ret; - - c->sigcontext_format = X86_SCF_NONE; - c->sigcontext_addr = 0; - - c->dwarf.args_size = 0; - c->dwarf.ret_addr_column = 0; - c->dwarf.stash_frames = 0; - c->dwarf.use_prev_instr = use_prev_instr; - c->dwarf.pi_valid = 0; - c->dwarf.pi_is_dynamic = 0; - c->dwarf.hint = 0; - c->dwarf.prev_rs = 0; - - return 0; -} diff --git a/x86/is_fpreg.c b/x86/is_fpreg.c deleted file mode 100644 index 8f1536d..0000000 --- a/x86/is_fpreg.c +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2004-2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "libunwind_i.h" - -PROTECTED int -unw_is_fpreg (int regnum) -{ - return ((regnum >= UNW_X86_ST0 && regnum <= UNW_X86_ST7) - || (regnum >= UNW_X86_XMM0_lo && regnum <= UNW_X86_XMM7_hi) - || (regnum >= UNW_X86_XMM0 && regnum <= UNW_X86_XMM7)); -} diff --git a/x86/longjmp.S b/x86/longjmp.S deleted file mode 100644 index 05173d0..0000000 --- a/x86/longjmp.S +++ /dev/null @@ -1,39 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - - .globl _UI_longjmp_cont - - .type _UI_longjmp_cont, @function -_UI_longjmp_cont: - .cfi_startproc - .cfi_register 8, 0 /* IP saved in EAX */ - push %eax /* push target IP as return address */ - .cfi_restore 8 - mov %edx, %eax /* set up return-value */ - ret - .cfi_endproc - .size _UI_siglongjmp_cont, .-_UI_longjmp_cont - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/x86/offsets.h b/x86/offsets.h deleted file mode 100644 index e8a255c..0000000 --- a/x86/offsets.h +++ /dev/null @@ -1,140 +0,0 @@ -/* Linux-specific definitions: */ - -/* Define various structure offsets to simplify cross-compilation. */ - -/* Offsets for x86 Linux "ucontext_t": */ - -#define LINUX_UC_FLAGS_OFF 0x00 -#define LINUX_UC_LINK_OFF 0x04 -#define LINUX_UC_STACK_OFF 0x08 -#define LINUX_UC_MCONTEXT_OFF 0x14 -#define LINUX_UC_SIGMASK_OFF 0x6c -#define LINUX_UC_FPREGS_MEM_OFF 0xec - -/* The struct sigcontext is located at an offset of 4 - from the stack pointer in the signal frame. */ - -/* Offsets for x86 Linux "struct sigcontext": */ - -#define LINUX_SC_GS_OFF 0x00 -#define LINUX_SC_GSH_OFF 0x02 -#define LINUX_SC_FS_OFF 0x04 -#define LINUX_SC_FSH_OFF 0x06 -#define LINUX_SC_ES_OFF 0x08 -#define LINUX_SC_ESH_OFF 0x0a -#define LINUX_SC_DS_OFF 0x0c -#define LINUX_SC_DSH_OFF 0x0e -#define LINUX_SC_EDI_OFF 0x10 -#define LINUX_SC_ESI_OFF 0x14 -#define LINUX_SC_EBP_OFF 0x18 -#define LINUX_SC_ESP_OFF 0x1c -#define LINUX_SC_EBX_OFF 0x20 -#define LINUX_SC_EDX_OFF 0x24 -#define LINUX_SC_ECX_OFF 0x28 -#define LINUX_SC_EAX_OFF 0x2c -#define LINUX_SC_TRAPNO_OFF 0x30 -#define LINUX_SC_ERR_OFF 0x34 -#define LINUX_SC_EIP_OFF 0x38 -#define LINUX_SC_CS_OFF 0x3c -#define LINUX_SC_CSH_OFF 0x3e -#define LINUX_SC_EFLAGS_OFF 0x40 -#define LINUX_SC_ESP_AT_SIGNAL_OFF 0x44 -#define LINUX_SC_SS_OFF 0x48 -#define LINUX_SC_SSH_OFF 0x4a -#define LINUX_SC_FPSTATE_OFF 0x4c -#define LINUX_SC_OLDMASK_OFF 0x50 -#define LINUX_SC_CR2_OFF 0x54 - -/* Offsets for x86 Linux "struct _fpstate": */ - -#define LINUX_FPSTATE_CW_OFF 0x000 -#define LINUX_FPSTATE_SW_OFF 0x004 -#define LINUX_FPSTATE_TAG_OFF 0x008 -#define LINUX_FPSTATE_IPOFF_OFF 0x00c -#define LINUX_FPSTATE_CSSEL_OFF 0x010 -#define LINUX_FPSTATE_DATAOFF_OFF 0x014 -#define LINUX_FPSTATE_DATASEL_OFF 0x018 -#define LINUX_FPSTATE_ST0_OFF 0x01c -#define LINUX_FPSTATE_ST1_OFF 0x026 -#define LINUX_FPSTATE_ST2_OFF 0x030 -#define LINUX_FPSTATE_ST3_OFF 0x03a -#define LINUX_FPSTATE_ST4_OFF 0x044 -#define LINUX_FPSTATE_ST5_OFF 0x04e -#define LINUX_FPSTATE_ST6_OFF 0x058 -#define LINUX_FPSTATE_ST7_OFF 0x062 -#define LINUX_FPSTATE_STATUS_OFF 0x06c -#define LINUX_FPSTATE_MAGIC_OFF 0x06e -#define LINUX_FPSTATE_FXSR_ENV_OFF 0x070 -#define LINUX_FPSTATE_MXCSR_OFF 0x088 -#define LINUX_FPSTATE_FXSR_ST0_OFF 0x090 -#define LINUX_FPSTATE_FXSR_ST1_OFF 0x0a0 -#define LINUX_FPSTATE_FXSR_ST2_OFF 0x0b0 -#define LINUX_FPSTATE_FXSR_ST3_OFF 0x0c0 -#define LINUX_FPSTATE_FXSR_ST4_OFF 0x0d0 -#define LINUX_FPSTATE_FXSR_ST5_OFF 0x0e0 -#define LINUX_FPSTATE_FXSR_ST6_OFF 0x0f0 -#define LINUX_FPSTATE_FXSR_ST7_OFF 0x100 -#define LINUX_FPSTATE_XMM0_OFF 0x110 -#define LINUX_FPSTATE_XMM1_OFF 0x120 -#define LINUX_FPSTATE_XMM2_OFF 0x130 -#define LINUX_FPSTATE_XMM3_OFF 0x140 -#define LINUX_FPSTATE_XMM4_OFF 0x150 -#define LINUX_FPSTATE_XMM5_OFF 0x160 -#define LINUX_FPSTATE_XMM6_OFF 0x170 -#define LINUX_FPSTATE_XMM7_OFF 0x180 - -/* FreeBSD-specific definitions: */ - -#define FREEBSD_SC_UCONTEXT_OFF 0x20 -#define FREEBSD_UC_MCONTEXT_OFF 0x10 - -#define FREEBSD_UC_MCONTEXT_GS_OFF 0x14 -#define FREEBSD_UC_MCONTEXT_FS_OFF 0x18 -#define FREEBSD_UC_MCONTEXT_ES_OFF 0x1c -#define FREEBSD_UC_MCONTEXT_DS_OFF 0x20 -#define FREEBSD_UC_MCONTEXT_EDI_OFF 0x24 -#define FREEBSD_UC_MCONTEXT_ESI_OFF 0x28 -#define FREEBSD_UC_MCONTEXT_EBP_OFF 0x2c -#define FREEBSD_UC_MCONTEXT_EBX_OFF 0x34 -#define FREEBSD_UC_MCONTEXT_EDX_OFF 0x38 -#define FREEBSD_UC_MCONTEXT_ECX_OFF 0x3c -#define FREEBSD_UC_MCONTEXT_EAX_OFF 0x40 -#define FREEBSD_UC_MCONTEXT_TRAPNO_OFF 0x44 -#define FREEBSD_UC_MCONTEXT_EIP_OFF 0x4c -#define FREEBSD_UC_MCONTEXT_ESP_OFF 0x58 -#define FREEBSD_UC_MCONTEXT_CS_OFF 0x50 -#define FREEBSD_UC_MCONTEXT_EFLAGS_OFF 0x54 -#define FREEBSD_UC_MCONTEXT_SS_OFF 0x5c -#define FREEBSD_UC_MCONTEXT_MC_LEN_OFF 0x60 -#define FREEBSD_UC_MCONTEXT_FPFORMAT_OFF 0x64 -#define FREEBSD_UC_MCONTEXT_OWNEDFP_OFF 0x68 -#define FREEBSD_UC_MCONTEXT_FPSTATE_OFF 0x70 - -#define FREEBSD_UC_MCONTEXT_CW_OFF 0x70 -#define FREEBSD_UC_MCONTEXT_SW_OFF 0x74 -#define FREEBSD_UC_MCONTEXT_TAG_OFF 0x78 -#define FREEBSD_UC_MCONTEXT_IPOFF_OFF 0x7c -#define FREEBSD_UC_MCONTEXT_CSSEL_OFF 0x80 -#define FREEBSD_UC_MCONTEXT_DATAOFF_OFF 0x84 -#define FREEBSD_US_MCONTEXT_DATASEL_OFF 0x88 -#define FREEBSD_UC_MCONTEXT_ST0_OFF 0x8c - -#define FREEBSD_UC_MCONTEXT_CW_XMM_OFF 0x70 -#define FREEBSD_UC_MCONTEXT_SW_XMM_OFF 0x72 -#define FREEBSD_UC_MCONTEXT_TAG_XMM_OFF 0x74 -#define FREEBSD_UC_MCONTEXT_IPOFF_XMM_OFF 0x78 -#define FREEBSD_UC_MCONTEXT_CSSEL_XMM_OFF 0x7c -#define FREEBSD_UC_MCONTEXT_DATAOFF_XMM_OFF 0x80 -#define FREEBSD_US_MCONTEXT_DATASEL_XMM_OFF 0x84 -#define FREEBSD_UC_MCONTEXT_MXCSR_XMM_OFF 0x88 -#define FREEBSD_UC_MCONTEXT_ST0_XMM_OFF 0x90 -#define FREEBSD_UC_MCONTEXT_XMM0_OFF 0x110 - -#define FREEBSD_UC_MCONTEXT_MC_LEN_VAL 0x280 -#define FREEBSD_UC_MCONTEXT_FPFMT_NODEV 0x10000 -#define FREEBSD_UC_MCONTEXT_FPFMT_387 0x10001 -#define FREEBSD_UC_MCONTEXT_FPFMT_XMM 0x10002 -#define FREEBSD_UC_MCONTEXT_FPOWNED_NONE 0x20000 -#define FREEBSD_UC_MCONTEXT_FPOWNED_FPU 0x20001 -#define FREEBSD_UC_MCONTEXT_FPOWNED_PCB 0x20002 - diff --git a/x86/regname.c b/x86/regname.c deleted file mode 100644 index 2228510..0000000 --- a/x86/regname.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "unwind_i.h" - -static const char *regname[] = - { - "eax", "edx", "ecx", "ebx", "esi", "edi", "ebp", "esp", "eip", - "eflags", "trapno", - "st0", "st1", "st2", "st3", "st4", "st5", "st6", "st7", - "fcw", "fsw", "ftw", "fop", "fcs", "fip", "fea", "fds", - "xmm0_lo", "xmm0_hi", "xmm1_lo", "xmm1_hi", - "xmm2_lo", "xmm2_hi", "xmm3_lo", "xmm3_hi", - "xmm4_lo", "xmm4_hi", "xmm5_lo", "xmm5_hi", - "xmm6_lo", "xmm6_hi", "xmm7_lo", "xmm7_hi", - "mxcsr", - "gs", "fs", "es", "ds", "ss", "cs", - "tss", "ldt", - "cfi", - "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", - }; - -PROTECTED const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) - return regname[reg]; - else - return "???"; -} diff --git a/x86/siglongjmp.S b/x86/siglongjmp.S deleted file mode 100644 index 32bba3b..0000000 --- a/x86/siglongjmp.S +++ /dev/null @@ -1,92 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2011 Konstantin Belousov - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - - .globl _UI_siglongjmp_cont - -#if defined(__linux__) -#define SIG_SETMASK 2 -#elif defined(__FreeBSD__) -#define SIG_SETMASK 3 -#endif - - /* Stack layout at this point: - - +------------+ <- original $esp (at time of setjmp() call) - | sigmask[1] | - +------------+ - | sigmask[0] | - +------------+ - */ - - .type _UI_siglongjmp_cont, @function -_UI_siglongjmp_cont: - .cfi_startproc -#ifdef __linux__ - .cfi_register 8, 0 /* IP saved in EAX */ - .cfi_def_cfa_offset 8 - mov %esp, %ecx /* pass address of signal mask in 3rd sc arg */ - push %eax /* save target IP */ - .cfi_adjust_cfa_offset 4 - .cfi_offset 8, -12 - push %edx /* save return value */ - .cfi_adjust_cfa_offset 4 - push %ebx /* save %ebx (preserved) */ - .cfi_adjust_cfa_offset 4 - .cfi_offset 3, -20 - mov $SIG_SETMASK, %ebx /* 1st syscall arg (how) */ - xor %edx, %edx /* pass NULL as 3rd syscall arg (old maskp) */ - int $0x80 - pop %ebx /* restore %ebx */ - .cfi_adjust_cfa_offset -4 - .cfi_restore 3 - pop %eax /* fetch return value */ - .cfi_adjust_cfa_offset -4 - pop %edx /* pop target IP */ - .cfi_adjust_cfa_offset -4 - .cfi_register 8, 2 /* saved IP is now n EDX */ - lea 8(%esp), %esp /* pop sigmask */ - .cfi_adjust_cfa_offset -4 - jmp *%edx -#elif defined(__FreeBSD__) - pushl %eax - pushl %edx - pushl $0 - pushl %ecx - pushl $SIG_SETMASK - movl $340,%eax - pushl %eax - int $0x80 - addl $16,%esp - popl %eax - popl %edx - jmp *%edx -#else -#error Port me -#endif - .cfi_endproc - .size _UI_siglongjmp_cont, .-_UI_siglongjmp_cont - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/x86/unwind_i.h b/x86/unwind_i.h deleted file mode 100644 index 1db2e98..0000000 --- a/x86/unwind_i.h +++ /dev/null @@ -1,63 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include - -#include - -#include "libunwind_i.h" - -/* DWARF column numbers: */ -#define EAX 0 -#define ECX 1 -#define EDX 2 -#define EBX 3 -#define ESP 4 -#define EBP 5 -#define ESI 6 -#define EDI 7 -#define EIP 8 -#define EFLAGS 9 -#define TRAPNO 10 -#define ST0 11 - -#define x86_lock UNW_OBJ(lock) -#define x86_local_resume UNW_OBJ(local_resume) -#define x86_local_addr_space_init UNW_OBJ(local_addr_space_init) -#define x86_scratch_loc UNW_OBJ(scratch_loc) -#define x86_get_scratch_loc UNW_OBJ(get_scratch_loc) -#define x86_r_uc_addr UNW_OBJ(r_uc_addr) - -extern void x86_local_addr_space_init (void); -extern int x86_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, - void *arg); -extern dwarf_loc_t x86_scratch_loc (struct cursor *c, unw_regnum_t reg); -extern dwarf_loc_t x86_get_scratch_loc (struct cursor *c, unw_regnum_t reg); -extern void *x86_r_uc_addr (ucontext_t *uc, int reg); - -#endif /* unwind_i_h */ diff --git a/x86_64/Ginit_remote.c b/x86_64/Ginit_remote.c deleted file mode 100644 index 4fd2092..0000000 --- a/x86_64/Ginit_remote.c +++ /dev/null @@ -1,57 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "init.h" -#include "unwind_i.h" - -PROTECTED int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = as; - if (as == unw_local_addr_space) - { - c->dwarf.as_arg = c; - c->uc = as_arg; - } - else - { - c->dwarf.as_arg = as_arg; - c->uc = NULL; - } - return common_init (c, 0); -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/x86_64/Gos-linux.c b/x86_64/Gos-linux.c deleted file mode 100644 index a0ecce2..0000000 --- a/x86_64/Gos-linux.c +++ /dev/null @@ -1,154 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "unwind_i.h" -#include "ucontext_i.h" - -#include - -HIDDEN void -tdep_fetch_frame (struct dwarf_cursor *dw, unw_word_t ip, int need_unwind_info) -{ - struct cursor *c = (struct cursor *) dw; - assert(! need_unwind_info || dw->pi_valid); - assert(! need_unwind_info || dw->pi.unwind_info); - if (dw->pi_valid - && dw->pi.unwind_info - && ((struct dwarf_cie_info *) dw->pi.unwind_info)->signal_frame) - c->sigcontext_format = X86_64_SCF_LINUX_RT_SIGFRAME; - else - c->sigcontext_format = X86_64_SCF_NONE; - - Debug(5, "fetch frame ip=0x%lx cfa=0x%lx format=%d\n", - dw->ip, dw->cfa, c->sigcontext_format); -} - -HIDDEN void -tdep_cache_frame (struct dwarf_cursor *dw, struct dwarf_reg_state *rs) -{ - struct cursor *c = (struct cursor *) dw; - rs->signal_frame = c->sigcontext_format; - - Debug(5, "cache frame ip=0x%lx cfa=0x%lx format=%d\n", - dw->ip, dw->cfa, c->sigcontext_format); -} - -HIDDEN void -tdep_reuse_frame (struct dwarf_cursor *dw, struct dwarf_reg_state *rs) -{ - struct cursor *c = (struct cursor *) dw; - c->sigcontext_format = rs->signal_frame; - if (c->sigcontext_format == X86_64_SCF_LINUX_RT_SIGFRAME) - { - c->frame_info.frame_type = UNW_X86_64_FRAME_SIGRETURN; - /* Offset from cfa to ucontext_t in signal frame. */ - c->frame_info.cfa_reg_offset = 0; - c->sigcontext_addr = dw->cfa; - } - else - c->sigcontext_addr = 0; - - Debug(5, "reuse frame ip=0x%lx cfa=0x%lx format=%d addr=0x%lx offset=%+d\n", - dw->ip, dw->cfa, c->sigcontext_format, c->sigcontext_addr, - (c->sigcontext_format == X86_64_SCF_LINUX_RT_SIGFRAME - ? c->frame_info.cfa_reg_offset : 0)); -} - -PROTECTED int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - return c->sigcontext_format != X86_64_SCF_NONE; -} - -PROTECTED int -unw_handle_signal_frame (unw_cursor_t *cursor) -{ -#if UNW_DEBUG /* To silence compiler warnings */ - /* Should not get here because we now use kernel-provided dwarf - information for the signal trampoline and dwarf_step() works. - Hence unw_step() should never call this function. Maybe - restore old non-dwarf signal handling here, but then the - gating on unw_is_signal_frame() needs to be removed. */ - struct cursor *c = (struct cursor *) cursor; - Debug(1, "old format signal frame? format=%d addr=0x%lx cfa=0x%lx\n", - c->sigcontext_format, c->sigcontext_addr, c->dwarf.cfa); -#endif - return -UNW_EBADFRAME; -} - -#ifndef UNW_REMOTE_ONLY -HIDDEN void * -x86_64_r_uc_addr (ucontext_t *uc, int reg) -{ - /* NOTE: common_init() in init.h inlines these for fast path access. */ - void *addr; - - switch (reg) - { - case UNW_X86_64_R8: addr = &uc->uc_mcontext.gregs[REG_R8]; break; - case UNW_X86_64_R9: addr = &uc->uc_mcontext.gregs[REG_R9]; break; - case UNW_X86_64_R10: addr = &uc->uc_mcontext.gregs[REG_R10]; break; - case UNW_X86_64_R11: addr = &uc->uc_mcontext.gregs[REG_R11]; break; - case UNW_X86_64_R12: addr = &uc->uc_mcontext.gregs[REG_R12]; break; - case UNW_X86_64_R13: addr = &uc->uc_mcontext.gregs[REG_R13]; break; - case UNW_X86_64_R14: addr = &uc->uc_mcontext.gregs[REG_R14]; break; - case UNW_X86_64_R15: addr = &uc->uc_mcontext.gregs[REG_R15]; break; - case UNW_X86_64_RDI: addr = &uc->uc_mcontext.gregs[REG_RDI]; break; - case UNW_X86_64_RSI: addr = &uc->uc_mcontext.gregs[REG_RSI]; break; - case UNW_X86_64_RBP: addr = &uc->uc_mcontext.gregs[REG_RBP]; break; - case UNW_X86_64_RBX: addr = &uc->uc_mcontext.gregs[REG_RBX]; break; - case UNW_X86_64_RDX: addr = &uc->uc_mcontext.gregs[REG_RDX]; break; - case UNW_X86_64_RAX: addr = &uc->uc_mcontext.gregs[REG_RAX]; break; - case UNW_X86_64_RCX: addr = &uc->uc_mcontext.gregs[REG_RCX]; break; - case UNW_X86_64_RSP: addr = &uc->uc_mcontext.gregs[REG_RSP]; break; - case UNW_X86_64_RIP: addr = &uc->uc_mcontext.gregs[REG_RIP]; break; - - default: - addr = NULL; - } - return addr; -} - -/* sigreturn() is a no-op on x86_64 glibc. */ -HIDDEN NORETURN void -x86_64_sigreturn (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - - Debug (8, "resuming at ip=%llx via sigreturn(%p)\n", - (unsigned long long) c->dwarf.ip, sc); - __asm__ __volatile__ ("mov %0, %%rsp;" - "mov %1, %%rax;" - "syscall" - :: "r"(sc), "i"(SYS_rt_sigreturn) - : "memory"); - abort(); -} - -#endif diff --git a/x86_64/Lcreate_addr_space.c b/x86_64/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6b..0000000 --- a/x86_64/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/x86_64/Lget_proc_info.c b/x86_64/Lget_proc_info.c deleted file mode 100644 index 69028b0..0000000 --- a/x86_64/Lget_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info.c" -#endif diff --git a/x86_64/Lget_save_loc.c b/x86_64/Lget_save_loc.c deleted file mode 100644 index 9ea048a..0000000 --- a/x86_64/Lget_save_loc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_save_loc.c" -#endif diff --git a/x86_64/Linit.c b/x86_64/Linit.c deleted file mode 100644 index e9abfdd..0000000 --- a/x86_64/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/x86_64/Linit_local.c b/x86_64/Linit_local.c deleted file mode 100644 index 68a1687..0000000 --- a/x86_64/Linit_local.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_local.c" -#endif diff --git a/x86_64/Linit_remote.c b/x86_64/Linit_remote.c deleted file mode 100644 index 58cb04a..0000000 --- a/x86_64/Linit_remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_remote.c" -#endif diff --git a/x86_64/Los-freebsd.c b/x86_64/Los-freebsd.c deleted file mode 100644 index a75a205..0000000 --- a/x86_64/Los-freebsd.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gos-freebsd.c" -#endif diff --git a/x86_64/Los-linux.c b/x86_64/Los-linux.c deleted file mode 100644 index 3cc18aa..0000000 --- a/x86_64/Los-linux.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gos-linux.c" -#endif diff --git a/x86_64/Lregs.c b/x86_64/Lregs.c deleted file mode 100644 index 2c9c75c..0000000 --- a/x86_64/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/x86_64/Lresume.c b/x86_64/Lresume.c deleted file mode 100644 index 41a8cf0..0000000 --- a/x86_64/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/x86_64/Lstep.c b/x86_64/Lstep.c deleted file mode 100644 index c1ac3c7..0000000 --- a/x86_64/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif