blob: a99c8a1176179976e7c0c811c06dce647dc7cefb [file] [log] [blame]
Rafael Espindola18c79202011-12-08 05:01:39 +00001/*===---- unwind.h - Stack unwinding ----------------------------------------===
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 *
21 *===-----------------------------------------------------------------------===
22 */
23
24/* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/
25
Jeffrey Yasskina09e62a2012-02-21 16:20:12 +000026#if __has_include_next(<unwind.h>)
27/* Darwin and libunwind provide an unwind.h. If that's available, use
28 * it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE,
29 * so define that around the include.*/
30# ifndef _GNU_SOURCE
31# define _SHOULD_UNDEFINE_GNU_SOURCE
32# define _GNU_SOURCE
33# endif
34# include_next <unwind.h>
35# ifdef _SHOULD_UNDEFINE_GNU_SOURCE
36# undef _GNU_SOURCE
37# undef _SHOULD_UNDEFINE_GNU_SOURCE
38# endif
Rafael Espindola18c79202011-12-08 05:01:39 +000039#else
40
41#include <stdint.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
Rafael Espindola7a284b22011-12-09 00:08:01 +000047/* It is a bit strange for a header to play with the visibility of the
48 symbols it declares, but this matches gcc's behavior and some programs
49 depend on it */
50#pragma GCC visibility push(default)
51
Rafael Espindola18c79202011-12-08 05:01:39 +000052struct _Unwind_Context;
53typedef enum {
54 _URC_NO_REASON = 0,
55 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
56
57 _URC_FATAL_PHASE2_ERROR = 2,
58 _URC_FATAL_PHASE1_ERROR = 3,
59 _URC_NORMAL_STOP = 4,
60
61 _URC_END_OF_STACK = 5,
62 _URC_HANDLER_FOUND = 6,
63 _URC_INSTALL_CONTEXT = 7,
64 _URC_CONTINUE_UNWIND = 8
65} _Unwind_Reason_Code;
66
Evgeniy Stepanov5dfe9f22012-01-19 11:39:05 +000067
68#ifdef __arm__
69
70typedef enum {
71 _UVRSC_CORE = 0, /* integer register */
72 _UVRSC_VFP = 1, /* vfp */
73 _UVRSC_WMMXD = 3, /* Intel WMMX data register */
74 _UVRSC_WMMXC = 4 /* Intel WMMX control register */
75} _Unwind_VRS_RegClass;
76
77typedef enum {
78 _UVRSD_UINT32 = 0,
79 _UVRSD_VFPX = 1,
80 _UVRSD_UINT64 = 3,
81 _UVRSD_FLOAT = 4,
82 _UVRSD_DOUBLE = 5
83} _Unwind_VRS_DataRepresentation;
84
85typedef enum {
86 _UVRSR_OK = 0,
87 _UVRSR_NOT_IMPLEMENTED = 1,
88 _UVRSR_FAILED = 2
89} _Unwind_VRS_Result;
90
91_Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *context,
92 _Unwind_VRS_RegClass regclass,
93 uint32_t regno,
94 _Unwind_VRS_DataRepresentation representation,
95 void *valuep);
96
97#else
98
Rafael Espindola18c79202011-12-08 05:01:39 +000099uintptr_t _Unwind_GetIP(struct _Unwind_Context* context);
Evgeniy Stepanov5dfe9f22012-01-19 11:39:05 +0000100
101#endif
102
Rafael Espindola18c79202011-12-08 05:01:39 +0000103typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context*, void*);
104_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void*);
105
Rafael Espindola7a284b22011-12-09 00:08:01 +0000106#pragma GCC visibility pop
107
Rafael Espindola18c79202011-12-08 05:01:39 +0000108#ifdef __cplusplus
109}
110#endif
111
112#endif