From e6446885f44866668ba7c5649c09386876e92a57 Mon Sep 17 00:00:00 2001 From: "hp.com!davidm" Date: Tue, 3 May 2005 09:13:17 +0000 Subject: [PATCH] Initial revision --- src/hppa/Gis_signal_frame.c | 74 ------------------ src/hppa/Gresume.c | 145 ------------------------------------ src/hppa/getcontext.S | 70 ----------------- src/hppa/offsets.h | 17 ----- src/hppa/regname.c | 50 ------------- src/hppa/setcontext.S | 73 ------------------ src/ptrace/_UPT_elf.c | 5 -- src/x86_64/longjmp.S | 33 -------- src/x86_64/setcontext.S | 4 - 9 files changed, 471 deletions(-) diff --git a/src/hppa/Gis_signal_frame.c b/src/hppa/Gis_signal_frame.c index 202b5703..e69de29b 100644 --- a/src/hppa/Gis_signal_frame.c +++ b/src/hppa/Gis_signal_frame.c @@ -1,74 +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_is_signal_frame (unw_cursor_t *cursor) -{ -#ifdef __linux__ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, w1, w2, w3, 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 IP points at sigreturn() sequence. On Linux, this normally is: - - rt_sigreturn: - 0x34190000 ldi 0, %r25 - 0x3414015a ldi __NR_rt_sigreturn,%r20 - 0xe4008200 be,l 0x100(%sr2,%r0),%sr0,%r31 - 0x08000240 nop - - When a signal interrupts a system call, the first word is instead: - - 0x34190002 ldi 1, %r25 - */ - ip = c->dwarf.ip; - if (!ip) - return 0; - if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0 - || (ret = (*a->access_mem) (as, ip + 4, &w1, 0, arg)) < 0 - || (ret = (*a->access_mem) (as, ip + 8, &w2, 0, arg)) < 0 - || (ret = (*a->access_mem) (as, ip + 12, &w3, 0, arg)) < 0) - { - Debug (1, "failed to read sigreturn code (ret=%d)\n", ret); - return ret; - } - ret = ((w0 == 0x34190000 || w0 == 0x34190002) - && w1 == 0x3414015a && w2 == 0xe4008200 && w3 == 0x08000240); - Debug (1, "(cursor=%p, ip=0x%08lx) -> %d\n", c, (unsigned) ip, ret); - return ret; -#else - printf ("%s: implement me\n", __FUNCTION__); -#endif - return -UNW_ENOINFO; -} diff --git a/src/hppa/Gresume.c b/src/hppa/Gresume.c index 92d506dc..e69de29b 100644 --- a/src/hppa/Gresume.c +++ b/src/hppa/Gresume.c @@ -1,145 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 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" - -#ifndef UNW_REMOTE_ONLY - -#if defined(__linux) - -# include - -static NORETURN inline long -my_rt_sigreturn (void *new_sp, int in_syscall) -{ - register unsigned long r25 __asm__ ("r25") = (in_syscall != 0); - register unsigned long r20 __asm__ ("r20") = SYS_rt_sigreturn; - - __asm__ __volatile__ ("copy %0, %%sp\n" - "be,l 0x100(%%sr2,%%r0),%%sr0,%%r31\n" - "nop" - : - : "r"(new_sp), "r"(r20), "r"(r25) - : "memory"); - abort (); -} - -#endif /* __linux */ - -HIDDEN inline int -hppa_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ -#if defined(__linux) - struct cursor *c = (struct cursor *) cursor; - ucontext_t *uc = c->dwarf.as_arg; - - /* Ensure c->pi is up-to-date. On PA-RISC, 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 != HPPA_SCF_NONE)) - { - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - - Debug (8, "resuming at ip=%x via sigreturn(%p)\n", c->dwarf.ip, sc); - my_rt_sigreturn (sc, (sc->sc_flags & PARISC_SC_FLAG_IN_SYSCALL) != 0); - } - else - { - Debug (8, "resuming at ip=%x via setcontext()\n", c->dwarf.ip); - setcontext (uc); - } -#else -# warning Implement me! -#endif - return -UNW_EINVAL; -} - -#endif /* !UNW_REMOTE_ONLY */ - -/* 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 (!c->dwarf.ip) - { - /* This can happen easily when the frame-chain gets truncated - due to bad or missing unwind-info. */ - Debug (1, "refusing to resume execution at address 0\n"); - return -UNW_EINVAL; - } - - 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/src/hppa/getcontext.S b/src/hppa/getcontext.S index ae485373..e69de29b 100644 --- a/src/hppa/getcontext.S +++ b/src/hppa/getcontext.S @@ -1,70 +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. */ - -#define SPILL(n) stw %r##n, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_GR_OFF+4*(n))(%r26) - -#include "offsets.h" - - .align 4 - .protected _Uhppa_getcontext - .global _Uhppa_getcontext - .proc - .callinfo -_Uhppa_getcontext: - SPILL (2) /* return-pointer */ - SPILL (3) /* frame pointer */ - SPILL (4) /* 2nd-ary frame pointer */ - SPILL (5) /* preserved register */ - SPILL (6) /* preserved register */ - SPILL (7) /* preserved register */ - SPILL (8) /* preserved register */ - SPILL (9) /* preserved register */ - SPILL (10) /* preserved register */ - SPILL (11) /* preserved register */ - SPILL (12) /* preserved register */ - SPILL (13) /* preserved register */ - SPILL (14) /* preserved register */ - SPILL (15) /* preserved register */ - SPILL (16) /* preserved register */ - SPILL (17) /* preserved register */ - SPILL (18) /* preserved register */ - SPILL (19) /* linkage-table register */ - SPILL (27) /* global-data pointer */ - SPILL (30) /* stack pointer */ - - ldo (LINUX_UC_MCONTEXT_OFF+LINUX_SC_FR_OFF)(%r26), %r29 - fstds,ma %fr12, 8(%r29) - fstds,ma %fr13, 8(%r29) - fstds,ma %fr14, 8(%r29) - fstds,ma %fr15, 8(%r29) - fstds,ma %fr16, 8(%r29) - fstds,ma %fr17, 8(%r29) - fstds,ma %fr18, 8(%r29) - fstds,ma %fr19, 8(%r29) - fstds,ma %fr20, 8(%r29) - fstds %fr21, 8(%r29) - - bv,n %r0(%rp) - .procend diff --git a/src/hppa/offsets.h b/src/hppa/offsets.h index d824770b..e69de29b 100644 --- a/src/hppa/offsets.h +++ b/src/hppa/offsets.h @@ -1,17 +0,0 @@ -#define LINUX_UC_FLAGS_OFF 0x000 -#define LINUX_UC_LINK_OFF 0x004 -#define LINUX_UC_STACK_OFF 0x008 -#define LINUX_UC_MCONTEXT_OFF 0x018 -#define LINUX_UC_SIGMASK_OFF 0x1b8 - -#define LINUX_SC_FLAGS_OFF 0x000 -#define LINUX_SC_GR_OFF 0x004 -#define LINUX_SC_FR_OFF 0x088 -#define LINUX_SC_IASQ_OFF 0x188 -#define LINUX_SC_IAOQ_OFF 0x190 -#define LINUX_SC_SAR_OFF 0x198 - -/* The signal frame contains 4 words of space for the sigreturn - trampoline, the siginfo structure, and then the sigcontext - structure. See include/asm-parisc/compat_rt_sigframe.h. */ -#define LINUX_RT_SIGFRAME_UC_OFF 0xac diff --git a/src/hppa/regname.c b/src/hppa/regname.c index 07cae8ed..e69de29b 100644 --- a/src/hppa/regname.c +++ b/src/hppa/regname.c @@ -1,50 +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 "unwind_i.h" - -static const char *regname[] = - { - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", - "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", - "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", - "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", - "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", - "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23", - "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31", - "ip", - "eh0", "eh1", "eh2", "eh3", - "cfa" - }; - -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/src/hppa/setcontext.S b/src/hppa/setcontext.S index 4eba4cd8..e69de29b 100644 --- a/src/hppa/setcontext.S +++ b/src/hppa/setcontext.S @@ -1,73 +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. */ - -/* The setcontext() in glibc is a no-op (as of 4 Dec 2004), so we have - to implement something useful on our own here. */ - -#define FILL(n) ldw (LINUX_UC_MCONTEXT_OFF+LINUX_SC_GR_OFF+4*(n))(%r26),%r##n - -#include "offsets.h" - - .align 4 - .global _Uhppa_setcontext - .protected _Uhppa_setcontext - .proc - .callinfo -_Uhppa_setcontext: - FILL (2) /* return-pointer */ - FILL (3) /* frame pointer */ - FILL (4) /* 2nd-ary frame pointer */ - FILL (5) /* preserved register */ - FILL (6) /* preserved register */ - FILL (7) /* preserved register */ - FILL (8) /* preserved register */ - FILL (9) /* preserved register */ - FILL (10) /* preserved register */ - FILL (11) /* preserved register */ - FILL (12) /* preserved register */ - FILL (13) /* preserved register */ - FILL (14) /* preserved register */ - FILL (15) /* preserved register */ - FILL (16) /* preserved register */ - FILL (17) /* preserved register */ - FILL (18) /* preserved register */ - FILL (19) /* linkage-table register */ - FILL (27) /* global-data pointer */ - FILL (30) /* stack pointer */ - - ldo (LINUX_UC_MCONTEXT_OFF+LINUX_SC_FR_OFF)(%r26), %r29 - fldds,ma 8(%r29), %fr12 - fldds,ma 8(%r29), %fr13 - fldds,ma 8(%r29), %fr14 - fldds,ma 8(%r29), %fr15 - fldds,ma 8(%r29), %fr16 - fldds,ma 8(%r29), %fr17 - fldds,ma 8(%r29), %fr18 - fldds,ma 8(%r29), %fr19 - fldds,ma 8(%r29), %fr20 - fldds 8(%r29), %fr21 - - bv,n %r0(%rp) - .procend diff --git a/src/ptrace/_UPT_elf.c b/src/ptrace/_UPT_elf.c index fb01c7c9..e69de29b 100644 --- a/src/ptrace/_UPT_elf.c +++ b/src/ptrace/_UPT_elf.c @@ -1,5 +0,0 @@ -/* We need to get a separate copy of the ELF-code into - libunwind-ptrace since it cannot (and must not) have any ELF - dependencies on libunwind. */ -#include "tdep.h" /* get ELFCLASS defined */ -#include "../elf64.c" diff --git a/src/x86_64/longjmp.S b/src/x86_64/longjmp.S index 192b8bc3..e69de29b 100644 --- a/src/x86_64/longjmp.S +++ b/src/x86_64/longjmp.S @@ -1,33 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004-2005 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: - push %rax /* push target IP as return address */ - mov %rdx, %rax /* set up return-value */ - retq - .size _UI_longjmp_cont, .-_UI_longjmp_cont diff --git a/src/x86_64/setcontext.S b/src/x86_64/setcontext.S index d164d8db..e69de29b 100644 --- a/src/x86_64/setcontext.S +++ b/src/x86_64/setcontext.S @@ -1,4 +0,0 @@ - .global _UI_setcontext - -_UI_setcontext: - retq