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 //===----------------------------------------------------------------------===//
21 #include <Availability.h>
23 #define LIBUNWIND_AVAIL __attribute__((unavailable))
25 #define LIBUNWIND_AVAIL __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0)
28 #define LIBUNWIND_AVAIL
33 UNW_ESUCCESS = 0, /* no error */
34 UNW_EUNSPEC = -6540, /* unspecified (general) error */
35 UNW_ENOMEM = -6541, /* out of memory */
36 UNW_EBADREG = -6542, /* bad register number */
37 UNW_EREADONLYREG = -6543, /* attempt to write read-only register */
38 UNW_ESTOPUNWIND = -6544, /* stop unwinding */
39 UNW_EINVALIDIP = -6545, /* invalid IP */
40 UNW_EBADFRAME = -6546, /* bad frame */
41 UNW_EINVAL = -6547, /* unsupported operation or bad value */
42 UNW_EBADVERSION = -6548, /* unwind info has unsupported version */
43 UNW_ENOINFO = -6549 /* no unwind info found */
46 struct unw_context_t {
49 typedef struct unw_context_t unw_context_t;
54 typedef struct unw_cursor_t unw_cursor_t;
56 typedef struct unw_addr_space *unw_addr_space_t;
58 typedef int unw_regnum_t;
59 typedef uint64_t unw_word_t;
60 typedef double unw_fpreg_t;
62 struct unw_proc_info_t {
63 unw_word_t start_ip; /* start address of function */
64 unw_word_t end_ip; /* address after end of function */
65 unw_word_t lsda; /* address of language specific data area, */
66 /* or zero if not used */
67 unw_word_t handler; /* personality routine, or zero if not used */
68 unw_word_t gp; /* not used */
69 unw_word_t flags; /* not used */
70 uint32_t format; /* compact unwind encoding, or zero if none */
71 uint32_t unwind_info_size; /* size of dwarf unwind info, or zero if none */
72 unw_word_t unwind_info; /* address of dwarf unwind info, or zero */
73 unw_word_t extra; /* mach_header of mach-o image containing func */
75 typedef struct unw_proc_info_t unw_proc_info_t;
81 extern int unw_getcontext(unw_context_t *) LIBUNWIND_AVAIL;
82 extern int unw_init_local(unw_cursor_t *, unw_context_t *) LIBUNWIND_AVAIL;
83 extern int unw_step(unw_cursor_t *) LIBUNWIND_AVAIL;
84 extern int unw_get_reg(unw_cursor_t *, unw_regnum_t, unw_word_t *) LIBUNWIND_AVAIL;
85 extern int unw_get_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t *) LIBUNWIND_AVAIL;
86 extern int unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t) LIBUNWIND_AVAIL;
87 extern int unw_set_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t) LIBUNWIND_AVAIL;
88 extern int unw_resume(unw_cursor_t *) LIBUNWIND_AVAIL;
90 extern const char *unw_regname(unw_cursor_t *, unw_regnum_t) LIBUNWIND_AVAIL;
91 extern int unw_get_proc_info(unw_cursor_t *, unw_proc_info_t *) LIBUNWIND_AVAIL;
92 extern int unw_is_fpreg(unw_cursor_t *, unw_regnum_t) LIBUNWIND_AVAIL;
93 extern int unw_is_signal_frame(unw_cursor_t *) LIBUNWIND_AVAIL;
94 extern int unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *) LIBUNWIND_AVAIL;
95 //extern int unw_get_save_loc(unw_cursor_t*, int, unw_save_loc_t*);
99 * Mac OS X "remote" API for unwinding other processes on same machine
102 extern unw_addr_space_t unw_local_addr_space;
103 extern unw_addr_space_t unw_create_addr_space_for_task(task_t);
104 extern void unw_destroy_addr_space(unw_addr_space_t);
105 extern int unw_init_remote_thread(unw_cursor_t *, unw_addr_space_t, thread_t *);
109 * traditional libuwind "remote" API
110 * NOT IMPLEMENTED on Mac OS X
112 * extern int unw_init_remote(unw_cursor_t*, unw_addr_space_t,
114 * extern unw_accessors_t unw_get_accessors(unw_addr_space_t);
115 * extern unw_addr_space_t unw_create_addr_space(unw_accessors_t, int);
116 * extern void unw_flush_cache(unw_addr_space_t, unw_word_t,
118 * extern int unw_set_caching_policy(unw_addr_space_t,
119 * unw_caching_policy_t);
120 * extern void _U_dyn_register(unw_dyn_info_t*);
121 * extern void _U_dyn_cancel(unw_dyn_info_t*);
128 // architecture independent register numbers
130 UNW_REG_IP = -1, // instruction pointer
131 UNW_REG_SP = -2, // stack pointer
134 // 32-bit x86 registers
146 // 64-bit x86_64 registers
167 // 32-bit ppc register numbers
278 UNW_PPC_VRSAVE = 109,
280 UNW_PPC_SPE_ACC = 111,
281 UNW_PPC_SPEFSCR = 112
284 // 64-bit ARM64 registers
356 // 32-bit ARM registers. Numbers match DWARF for ARM spec #3.1 Table 1.
357 // Naming scheme uses recommendations given in Note 4 for VFP-v2 and VFP-v3.
358 // In this scheme, even though the 64-bit floating point registers D0-D31
359 // overlap physically with the 32-bit floating pointer registers S0-S31,
360 // they are given a non-overlapping range of register numbers.
362 // Commented out ranges are not preserved during unwinding.
377 UNW_ARM_SP = 13, // Logical alias for UNW_REG_SP
381 UNW_ARM_IP = 15, // Logical alias for UNW_REG_IP
383 // 16-63 -- OBSOLETE. Used in VFP1 to represent both S0-S31 and D0-D31.
416 // 96-103 -- OBSOLETE. F0-F7. Used by the FPA system. Superseded by VFP.
417 // 104-111 -- wCGR0-wCGR7, ACC0-ACC7 (Intel wireless MMX)
434 // 128-133 -- SPSR, SPSR_{FIQ|IRQ|ABT|UND|SVC}
435 // 134-143 -- Reserved
436 // 144-150 -- R8_USR–R14_USR
437 // 151-157 -- R8_FIQ–R14_FIQ
438 // 158-159 -- R13_IRQ–R14_IRQ
439 // 160-161 -- R13_ABT–R14_ABT
440 // 162-163 -- R13_UND–R14_UND
441 // 164-165 -- R13_SVC–R14_SVC
442 // 166-191 -- Reserved
447 // 196-199 -- wC4-wC7 (Intel wireless MMX control)
448 // 200-255 -- Reserved
481 // 288-319 -- Reserved for VFP/Neon
482 // 320-8191 -- Reserved
483 // 8192-16383 -- Unspecified vendor co-processor register.