1 //===---------------------------- libunwind.h -----------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
9 // Compatible with libuwind API documented at:
10 // http://www.nongnu.org/libunwind/man/libunwind(3).html
12 //===----------------------------------------------------------------------===//
20 // FIXME: This is also in unwind.h and cxxabi.h, can we consolidate?
21 #if !defined(__USING_SJLJ_EXCEPTIONS__) && defined(__arm__) && \
22 !defined(__ARM_DWARF_EH__) && !defined(__APPLE__)
23 #define LIBCXXABI_ARM_EHABI 1
25 #define LIBCXXABI_ARM_EHABI 0
29 #include <Availability.h>
31 #define LIBUNWIND_AVAIL __attribute__((unavailable))
33 #define LIBUNWIND_AVAIL __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0)
36 #define LIBUNWIND_AVAIL
41 UNW_ESUCCESS = 0, /* no error */
42 UNW_EUNSPEC = -6540, /* unspecified (general) error */
43 UNW_ENOMEM = -6541, /* out of memory */
44 UNW_EBADREG = -6542, /* bad register number */
45 UNW_EREADONLYREG = -6543, /* attempt to write read-only register */
46 UNW_ESTOPUNWIND = -6544, /* stop unwinding */
47 UNW_EINVALIDIP = -6545, /* invalid IP */
48 UNW_EBADFRAME = -6546, /* bad frame */
49 UNW_EINVAL = -6547, /* unsupported operation or bad value */
50 UNW_EBADVERSION = -6548, /* unwind info has unsupported version */
51 UNW_ENOINFO = -6549 /* no unwind info found */
54 struct unw_context_t {
57 typedef struct unw_context_t unw_context_t;
62 typedef struct unw_cursor_t unw_cursor_t;
64 typedef struct unw_addr_space *unw_addr_space_t;
66 typedef int unw_regnum_t;
67 #if LIBCXXABI_ARM_EHABI
68 typedef uint32_t unw_word_t;
69 typedef uint64_t unw_fpreg_t;
71 typedef uint64_t unw_word_t;
72 typedef double unw_fpreg_t;
75 struct unw_proc_info_t {
76 unw_word_t start_ip; /* start address of function */
77 unw_word_t end_ip; /* address after end of function */
78 unw_word_t lsda; /* address of language specific data area, */
79 /* or zero if not used */
80 unw_word_t handler; /* personality routine, or zero if not used */
81 unw_word_t gp; /* not used */
82 unw_word_t flags; /* not used */
83 uint32_t format; /* compact unwind encoding, or zero if none */
84 uint32_t unwind_info_size; /* size of dwarf unwind info, or zero if none */
85 unw_word_t unwind_info; /* address of dwarf unwind info, or zero */
86 unw_word_t extra; /* mach_header of mach-o image containing func */
88 typedef struct unw_proc_info_t unw_proc_info_t;
94 extern int unw_getcontext(unw_context_t *) LIBUNWIND_AVAIL;
95 extern int unw_init_local(unw_cursor_t *, unw_context_t *) LIBUNWIND_AVAIL;
96 extern int unw_step(unw_cursor_t *) LIBUNWIND_AVAIL;
97 extern int unw_get_reg(unw_cursor_t *, unw_regnum_t, unw_word_t *) LIBUNWIND_AVAIL;
98 extern int unw_get_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t *) LIBUNWIND_AVAIL;
99 extern int unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t) LIBUNWIND_AVAIL;
100 extern int unw_set_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t) LIBUNWIND_AVAIL;
101 extern int unw_resume(unw_cursor_t *) LIBUNWIND_AVAIL;
104 /* Save VFP registers in FSTMX format (instead of FSTMD). */
105 extern void unw_save_vfp_as_X(unw_cursor_t *) LIBUNWIND_AVAIL;
109 extern const char *unw_regname(unw_cursor_t *, unw_regnum_t) LIBUNWIND_AVAIL;
110 extern int unw_get_proc_info(unw_cursor_t *, unw_proc_info_t *) LIBUNWIND_AVAIL;
111 extern int unw_is_fpreg(unw_cursor_t *, unw_regnum_t) LIBUNWIND_AVAIL;
112 extern int unw_is_signal_frame(unw_cursor_t *) LIBUNWIND_AVAIL;
113 extern int unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *) LIBUNWIND_AVAIL;
114 //extern int unw_get_save_loc(unw_cursor_t*, int, unw_save_loc_t*);
118 * Mac OS X "remote" API for unwinding other processes on same machine
121 extern unw_addr_space_t unw_local_addr_space;
122 extern unw_addr_space_t unw_create_addr_space_for_task(task_t);
123 extern void unw_destroy_addr_space(unw_addr_space_t);
124 extern int unw_init_remote_thread(unw_cursor_t *, unw_addr_space_t, thread_t *);
128 * traditional libuwind "remote" API
129 * NOT IMPLEMENTED on Mac OS X
131 * extern int unw_init_remote(unw_cursor_t*, unw_addr_space_t,
133 * extern unw_accessors_t unw_get_accessors(unw_addr_space_t);
134 * extern unw_addr_space_t unw_create_addr_space(unw_accessors_t, int);
135 * extern void unw_flush_cache(unw_addr_space_t, unw_word_t,
137 * extern int unw_set_caching_policy(unw_addr_space_t,
138 * unw_caching_policy_t);
139 * extern void _U_dyn_register(unw_dyn_info_t*);
140 * extern void _U_dyn_cancel(unw_dyn_info_t*);
147 // architecture independent register numbers
149 UNW_REG_IP = -1, // instruction pointer
150 UNW_REG_SP = -2, // stack pointer
153 // 32-bit x86 registers
165 // 64-bit x86_64 registers
186 // 32-bit ppc register numbers
297 UNW_PPC_VRSAVE = 109,
299 UNW_PPC_SPE_ACC = 111,
300 UNW_PPC_SPEFSCR = 112
303 // 64-bit ARM64 registers
375 // 32-bit ARM registers. Numbers match DWARF for ARM spec #3.1 Table 1.
376 // Naming scheme uses recommendations given in Note 4 for VFP-v2 and VFP-v3.
377 // In this scheme, even though the 64-bit floating point registers D0-D31
378 // overlap physically with the 32-bit floating pointer registers S0-S31,
379 // they are given a non-overlapping range of register numbers.
381 // Commented out ranges are not preserved during unwinding.
396 UNW_ARM_SP = 13, // Logical alias for UNW_REG_SP
400 UNW_ARM_IP = 15, // Logical alias for UNW_REG_IP
402 // 16-63 -- OBSOLETE. Used in VFP1 to represent both S0-S31 and D0-D31.
435 // 96-103 -- OBSOLETE. F0-F7. Used by the FPA system. Superseded by VFP.
436 // 104-111 -- wCGR0-wCGR7, ACC0-ACC7 (Intel wireless MMX)
453 // 128-133 -- SPSR, SPSR_{FIQ|IRQ|ABT|UND|SVC}
454 // 134-143 -- Reserved
455 // 144-150 -- R8_USR–R14_USR
456 // 151-157 -- R8_FIQ–R14_FIQ
457 // 158-159 -- R13_IRQ–R14_IRQ
458 // 160-161 -- R13_ABT–R14_ABT
459 // 162-163 -- R13_UND–R14_UND
460 // 164-165 -- R13_SVC–R14_SVC
461 // 166-191 -- Reserved
466 // 196-199 -- wC4-wC7 (Intel wireless MMX control)
467 // 200-255 -- Reserved
500 // 288-319 -- Reserved for VFP/Neon
501 // 320-8191 -- Reserved
502 // 8192-16383 -- Unspecified vendor co-processor register.