1 /* libunwind - a platform-independent unwind library
2 Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
5 This file is part of libunwind.
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
30 #ifndef UNW_REMOTE_ONLY
34 # include <sys/syscall.h>
36 static NORETURN
inline long
37 my_rt_sigreturn (void *new_sp
, int in_syscall
)
39 register unsigned long r25
__asm__ ("r25") = (in_syscall
!= 0);
40 register unsigned long r20
__asm__ ("r20") = SYS_rt_sigreturn
;
42 __asm__
__volatile__ ("copy %0, %%sp\n"
43 "be,l 0x100(%%sr2,%%r0),%%sr0,%%r31\n"
46 : "r"(new_sp
), "r"(r20
), "r"(r25
)
54 hppa_local_resume (unw_addr_space_t as
, unw_cursor_t
*cursor
, void *arg
)
57 struct cursor
*c
= (struct cursor
*) cursor
;
58 ucontext_t
*uc
= c
->dwarf
.as_arg
;
60 /* Ensure c->pi is up-to-date. On PA-RISC, it's relatively common to be
61 missing DWARF unwind info. We don't want to fail in that case,
62 because the frame-chain still would let us do a backtrace at
64 dwarf_make_proc_info (&c
->dwarf
);
66 if (unlikely (c
->sigcontext_format
!= HPPA_SCF_NONE
))
68 struct sigcontext
*sc
= (struct sigcontext
*) c
->sigcontext_addr
;
70 Debug (8, "resuming at ip=%x via sigreturn(%p)\n", c
->dwarf
.ip
, sc
);
71 my_rt_sigreturn (sc
, (sc
->sc_flags
& PARISC_SC_FLAG_IN_SYSCALL
) != 0);
75 Debug (8, "resuming at ip=%x via setcontext()\n", c
->dwarf
.ip
);
79 # warning Implement me!
84 #endif /* !UNW_REMOTE_ONLY */
86 /* This routine is responsible for copying the register values in
87 cursor C and establishing them as the current machine state. */
90 establish_machine_state (struct cursor
*c
)
92 int (*access_reg
) (unw_addr_space_t
, unw_regnum_t
, unw_word_t
*,
94 int (*access_fpreg
) (unw_addr_space_t
, unw_regnum_t
, unw_fpreg_t
*,
96 unw_addr_space_t as
= c
->dwarf
.as
;
97 void *arg
= c
->dwarf
.as_arg
;
102 access_reg
= as
->acc
.access_reg
;
103 access_fpreg
= as
->acc
.access_fpreg
;
105 Debug (8, "copying out cursor state\n");
107 for (reg
= 0; reg
<= UNW_REG_LAST
; ++reg
)
109 Debug (16, "copying %s %d\n", unw_regname (reg
), reg
);
110 if (unw_is_fpreg (reg
))
112 if (tdep_access_fpreg (c
, reg
, &fpval
, 0) >= 0)
113 (*access_fpreg
) (as
, reg
, &fpval
, 1, arg
);
117 if (tdep_access_reg (c
, reg
, &val
, 0) >= 0)
118 (*access_reg
) (as
, reg
, &val
, 1, arg
);
125 unw_resume (unw_cursor_t
*cursor
)
127 struct cursor
*c
= (struct cursor
*) cursor
;
130 Debug (1, "(cursor=%p)\n", c
);
134 /* This can happen easily when the frame-chain gets truncated
135 due to bad or missing unwind-info. */
136 Debug (1, "refusing to resume execution at address 0\n");
140 if ((ret
= establish_machine_state (c
)) < 0)
143 return (*c
->dwarf
.as
->acc
.resume
) (c
->dwarf
.as
, (unw_cursor_t
*) c
,