blob: e94fd70900cc41cea3055a94997687cd1e1d4ebd [file] [log] [blame]
Rafael Espindolad85c1e92011-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
Benjamin Kramerccdb2a52013-01-09 19:54:57 +000026#ifndef __CLANG_UNWIND_H
27#define __CLANG_UNWIND_H
28
Jeffrey Yasskinf18a87b2012-02-21 16:20:12 +000029#if __has_include_next(<unwind.h>)
30/* Darwin and libunwind provide an unwind.h. If that's available, use
31 * it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE,
32 * so define that around the include.*/
33# ifndef _GNU_SOURCE
34# define _SHOULD_UNDEFINE_GNU_SOURCE
35# define _GNU_SOURCE
36# endif
Rafael Espindolabe5ff2f2012-03-29 03:37:17 +000037// libunwind's unwind.h reflects the current visibility. However, Mozilla
38// builds with -fvisibility=hidden and relies on gcc's unwind.h to reset the
39// visibility to default and export its contents. gcc also allows users to
40// override its override by #defining HIDE_EXPORTS (but note, this only obeys
41// the user's -fvisibility setting; it doesn't hide any exports on its own). We
42// imitate gcc's header here:
43# ifdef HIDE_EXPORTS
44# include_next <unwind.h>
45# else
46# pragma GCC visibility push(default)
47# include_next <unwind.h>
48# pragma GCC visibility pop
49# endif
Jeffrey Yasskinf18a87b2012-02-21 16:20:12 +000050# ifdef _SHOULD_UNDEFINE_GNU_SOURCE
51# undef _GNU_SOURCE
52# undef _SHOULD_UNDEFINE_GNU_SOURCE
53# endif
Rafael Espindolad85c1e92011-12-08 05:01:39 +000054#else
55
56#include <stdint.h>
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
Rafael Espindola9b7568d2011-12-09 00:08:01 +000062/* It is a bit strange for a header to play with the visibility of the
63 symbols it declares, but this matches gcc's behavior and some programs
64 depend on it */
Benjamin Kramerccdb2a52013-01-09 19:54:57 +000065#ifndef HIDE_EXPORTS
Rafael Espindola9b7568d2011-12-09 00:08:01 +000066#pragma GCC visibility push(default)
Benjamin Kramerccdb2a52013-01-09 19:54:57 +000067#endif
Rafael Espindola9b7568d2011-12-09 00:08:01 +000068
Rafael Espindolad85c1e92011-12-08 05:01:39 +000069struct _Unwind_Context;
70typedef enum {
71 _URC_NO_REASON = 0,
72 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
73
74 _URC_FATAL_PHASE2_ERROR = 2,
75 _URC_FATAL_PHASE1_ERROR = 3,
76 _URC_NORMAL_STOP = 4,
77
78 _URC_END_OF_STACK = 5,
79 _URC_HANDLER_FOUND = 6,
80 _URC_INSTALL_CONTEXT = 7,
81 _URC_CONTINUE_UNWIND = 8
82} _Unwind_Reason_Code;
83
Evgeniy Stepanovf5f18bf2012-01-19 11:39:05 +000084
85#ifdef __arm__
86
Logan Chien38c5d0a2012-11-14 06:33:58 +000087typedef enum {
88 _UVRSC_CORE = 0, /* integer register */
89 _UVRSC_VFP = 1, /* vfp */
90 _UVRSC_WMMXD = 3, /* Intel WMMX data register */
91 _UVRSC_WMMXC = 4 /* Intel WMMX control register */
92} _Unwind_VRS_RegClass;
Evgeniy Stepanovf5f18bf2012-01-19 11:39:05 +000093
Logan Chien38c5d0a2012-11-14 06:33:58 +000094typedef enum {
95 _UVRSD_UINT32 = 0,
96 _UVRSD_VFPX = 1,
97 _UVRSD_UINT64 = 3,
98 _UVRSD_FLOAT = 4,
99 _UVRSD_DOUBLE = 5
100} _Unwind_VRS_DataRepresentation;
Evgeniy Stepanovf5f18bf2012-01-19 11:39:05 +0000101
Logan Chien38c5d0a2012-11-14 06:33:58 +0000102typedef enum {
103 _UVRSR_OK = 0,
104 _UVRSR_NOT_IMPLEMENTED = 1,
105 _UVRSR_FAILED = 2
106} _Unwind_VRS_Result;
Evgeniy Stepanovf5f18bf2012-01-19 11:39:05 +0000107
David Blaikie4f918ae2013-01-16 23:08:36 +0000108_Unwind_VRS_Result _Unwind_VRS_Get(struct _Unwind_Context *__context,
109 _Unwind_VRS_RegClass __regclass,
110 uint32_t __regno,
111 _Unwind_VRS_DataRepresentation __representation,
112 void *__valuep);
Evgeniy Stepanovf5f18bf2012-01-19 11:39:05 +0000113
114#else
115
David Blaikie4f918ae2013-01-16 23:08:36 +0000116uintptr_t _Unwind_GetIP(struct _Unwind_Context* __context);
Evgeniy Stepanovf5f18bf2012-01-19 11:39:05 +0000117
118#endif
119
Rafael Espindolad85c1e92011-12-08 05:01:39 +0000120typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context*, void*);
121_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void*);
122
Benjamin Kramerccdb2a52013-01-09 19:54:57 +0000123#ifndef HIDE_EXPORTS
Rafael Espindola9b7568d2011-12-09 00:08:01 +0000124#pragma GCC visibility pop
Benjamin Kramerccdb2a52013-01-09 19:54:57 +0000125#endif
Rafael Espindola9b7568d2011-12-09 00:08:01 +0000126
Rafael Espindolad85c1e92011-12-08 05:01:39 +0000127#ifdef __cplusplus
128}
129#endif
130
131#endif
Benjamin Kramerccdb2a52013-01-09 19:54:57 +0000132
133#endif /* __CLANG_UNWIND_H */