1 /* libunwind - a platform-independent unwind library
2 Copyright (C) 2008 CodeSourcery
3 Copyright (C) 2014 Tilera Corp.
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. */
31 #include <sys/syscall.h>
34 # error "Only support Linux!"
37 #define MOVELI_R10_RT_SIGRETURN \
38 ( 0x000007e051483000ULL | \
39 ((unsigned long)__NR_rt_sigreturn << 43) | \
40 ((unsigned long)TREG_SYSCALL_NR << 31) )
41 #define SWINT1 0x286b180051485000ULL
44 unw_is_signal_frame (unw_cursor_t
*cursor
)
46 struct cursor
*c
= (struct cursor
*) cursor
;
47 unw_word_t w0
, w1
, ip
;
54 a
= unw_get_accessors (as
);
55 arg
= c
->dwarf
.as_arg
;
59 if (!ip
|| !a
->access_mem
|| (ip
& (sizeof(unw_word_t
) - 1)))
62 if ((ret
= (*a
->access_mem
) (as
, ip
, &w0
, 0, arg
)) < 0)
65 if ((ret
= (*a
->access_mem
) (as
, ip
+ 8, &w1
, 0, arg
)) < 0)
68 /* Return 1 if the IP points to a RT sigreturn sequence. */
69 if (w0
== MOVELI_R10_RT_SIGRETURN
&&
79 unw_handle_signal_frame (unw_cursor_t
*cursor
)
82 struct cursor
*c
= (struct cursor
*) cursor
;
83 unw_word_t sc_addr
, sp
, sp_addr
= c
->dwarf
.cfa
;
84 struct dwarf_loc sp_loc
= DWARF_LOC (sp_addr
, 0);
87 if ((ret
= dwarf_get (&c
->dwarf
, sp_loc
, &sp
)) < 0)
90 /* Save the SP and PC to be able to return execution at this point
91 later in time (unw_resume). */
92 c
->sigcontext_sp
= c
->dwarf
.cfa
;
93 c
->sigcontext_pc
= c
->dwarf
.ip
;
95 c
->sigcontext_addr
= sp_addr
+ sizeof (siginfo_t
) +
97 sc_addr
= c
->sigcontext_addr
+ LINUX_UC_MCONTEXT_OFF
;
99 /* Update the dwarf cursor.
100 Set the location of the registers to the corresponding addresses of the
101 uc_mcontext / sigcontext structure contents. */
103 #define SC_REG_OFFSET(X) (8 * X)
105 for (i
= UNW_TILEGX_R0
; i
<= UNW_TILEGX_R55
; i
++)
107 c
->dwarf
.loc
[i
] = DWARF_LOC (sc_addr
+ SC_REG_OFFSET(i
), 0);
110 /* Set SP/CFA and PC/IP. */
111 dwarf_get (&c
->dwarf
, c
->dwarf
.loc
[UNW_TILEGX_R54
], &c
->dwarf
.cfa
);
112 dwarf_get (&c
->dwarf
, c
->dwarf
.loc
[UNW_TILEGX_R55
], &c
->dwarf
.ip
);