1 /* libunwind - a platform-independent unwind library
2 Copyright (C) 2008 CodeSourcery
4 This file is part of libunwind.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 #if defined(__cplusplus) || defined(c_plusplus)
35 #define UNW_TARGET arm
36 #define UNW_TARGET_ARM 1
38 #define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
40 /* This needs to be big enough to accommodate "struct cursor", while
41 leaving some slack for future expansion. Changing this value will
42 require recompiling all users of this library. Stack allocation is
43 relatively cheap and unwind-state copying is relatively rare, so we
44 want to err on making it rather too big than too small. */
46 /* FIXME for ARM. Too big? What do other things use for similar tasks? */
47 #define UNW_TDEP_CURSOR_LEN 4096
49 typedef uint32_t unw_word_t
;
50 typedef int32_t unw_sword_t
;
52 typedef long double unw_tdep_fpreg_t
;
73 /* VFPv2 s0-s31 (obsolescent numberings). */
107 /* FPA register numberings. */
117 /* iWMMXt GR register numberings. */
127 /* iWMMXt register numberings. */
145 /* Two-byte encodings from here on. */
155 /* User mode registers. */
156 UNW_ARM_R8_USR
= 144,
165 UNW_ARM_R8_FIQ
= 151,
174 UNW_ARM_R13_IRQ
= 158,
178 UNW_ARM_R13_ABT
= 160,
182 UNW_ARM_R13_UND
= 162,
186 UNW_ARM_R13_SVC
= 164,
189 /* iWMMXt control registers. */
199 /* VFPv3/Neon 64-bit registers. */
233 /* For ARM, the CFA is the value of SP (r13) at the call site in the
237 UNW_TDEP_LAST_REG
= UNW_ARM_D31
,
239 UNW_TDEP_IP
= UNW_ARM_R14
, /* A little white lie. */
240 UNW_TDEP_SP
= UNW_ARM_R13
,
241 UNW_TDEP_EH
= UNW_ARM_R0
/* FIXME. */
245 #define UNW_TDEP_NUM_EH_REGS 2 /* FIXME for ARM. */
247 typedef struct unw_tdep_save_loc
249 /* Additional target-dependent info on a save location. */
253 /* On ARM, we define our own unw_tdep_context instead of using ucontext_t.
254 This allows us to support systems that don't support getcontext and
255 therefore do not define ucontext_t. */
256 typedef struct unw_tdep_context
258 unsigned long regs
[16];
262 /* There is no getcontext() on ARM. Use a stub version which only saves GP
263 registers. FIXME: Not ideal, may not be sufficient for all libunwind
264 use cases. Stores pc+8, which is only approximately correct, really. */
266 #define unw_tdep_getcontext(uc) (({ \
267 unw_tdep_context_t *unw_ctx = (uc); \
268 register unsigned long *unw_base asm ("r0") = unw_ctx->regs; \
269 __asm__ __volatile__ ( \
270 "stmia %[base], {r0-r15}" \
271 : : [base] "r" (unw_base) : "memory"); \
273 #else /* __thumb__ */
274 #define unw_tdep_getcontext(uc) (({ \
275 unw_tdep_context_t *unw_ctx = (uc); \
276 register unsigned long *unw_base asm ("r0") = unw_ctx->regs; \
277 __asm__ __volatile__ ( \
278 ".align 2\nbx pc\nnop\n.code 32\n" \
279 "stmia %[base], {r0-r15}\n" \
280 "orr %[base], pc, #1\nbx %[base]" \
281 : [base] "+r" (unw_base) : : "memory", "cc"); \
285 #include "libunwind-dynamic.h"
289 /* no arm-specific auxiliary proc-info */
291 unw_tdep_proc_info_t
;
293 #include "libunwind-common.h"
295 #define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
296 extern int unw_tdep_is_fpreg (int);
298 #if defined(__cplusplus) || defined(c_plusplus)
302 #endif /* LIBUNWIND_H */