xref: /minix3/sys/lib/libunwind/unwind.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1472758f3SLionel Sambuc //===------------------------------- unwind.h -----------------------------===//
2472758f3SLionel Sambuc //
3472758f3SLionel Sambuc //                     The LLVM Compiler Infrastructure
4472758f3SLionel Sambuc //
5472758f3SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open
6472758f3SLionel Sambuc // Source Licenses. See LICENSE.TXT for details.
7472758f3SLionel Sambuc //
8472758f3SLionel Sambuc //
9472758f3SLionel Sambuc // C++ ABI Level 1 ABI documented at:
10472758f3SLionel Sambuc //   http://mentorembedded.github.io/cxx-abi/abi-eh.html
11472758f3SLionel Sambuc //
12472758f3SLionel Sambuc //===----------------------------------------------------------------------===//
13472758f3SLionel Sambuc 
14472758f3SLionel Sambuc #ifndef _UNWIND_H
15472758f3SLionel Sambuc #define _UNWIND_H
16472758f3SLionel Sambuc 
17472758f3SLionel Sambuc #include <stdint.h>
18472758f3SLionel Sambuc #include <stddef.h>
19472758f3SLionel Sambuc 
20472758f3SLionel Sambuc typedef enum {
21472758f3SLionel Sambuc   _URC_NO_REASON = 0,
22472758f3SLionel Sambuc   _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
23472758f3SLionel Sambuc   _URC_FATAL_PHASE2_ERROR = 2,
24472758f3SLionel Sambuc   _URC_FATAL_PHASE1_ERROR = 3,
25472758f3SLionel Sambuc   _URC_NORMAL_STOP = 4,
26472758f3SLionel Sambuc   _URC_END_OF_STACK = 5,
27472758f3SLionel Sambuc   _URC_HANDLER_FOUND = 6,
28472758f3SLionel Sambuc   _URC_INSTALL_CONTEXT = 7,
29472758f3SLionel Sambuc   _URC_CONTINUE_UNWIND = 8
30472758f3SLionel Sambuc } _Unwind_Reason_Code;
31472758f3SLionel Sambuc 
32472758f3SLionel Sambuc typedef enum {
33472758f3SLionel Sambuc   _UA_SEARCH_PHASE = 1,
34472758f3SLionel Sambuc   _UA_CLEANUP_PHASE = 2,
35472758f3SLionel Sambuc   _UA_HANDLER_FRAME = 4,
36472758f3SLionel Sambuc   _UA_FORCE_UNWIND = 8,
37472758f3SLionel Sambuc   _UA_END_OF_STACK = 16 /* GCC extension */
38472758f3SLionel Sambuc } _Unwind_Action;
39472758f3SLionel Sambuc 
40472758f3SLionel Sambuc struct _Unwind_Context;
41472758f3SLionel Sambuc 
42472758f3SLionel Sambuc struct _Unwind_Exception {
43472758f3SLionel Sambuc   uint64_t exception_class;
44472758f3SLionel Sambuc   void (*exception_cleanup)(_Unwind_Reason_Code, struct _Unwind_Exception *);
45472758f3SLionel Sambuc   uintptr_t private_1;
46472758f3SLionel Sambuc   uintptr_t private_2;
47472758f3SLionel Sambuc } __attribute__((__aligned__));
48472758f3SLionel Sambuc 
49472758f3SLionel Sambuc typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)(int, _Unwind_Action, uint64_t,
50472758f3SLionel Sambuc                                                struct _Unwind_Exception *,
51472758f3SLionel Sambuc                                                struct _Unwind_Context *,
52472758f3SLionel Sambuc                                                void *);
53472758f3SLionel Sambuc 
54472758f3SLionel Sambuc typedef _Unwind_Reason_Code (*__personality_routine)(int, _Unwind_Action,
55472758f3SLionel Sambuc                                                      uint64_t,
56472758f3SLionel Sambuc                                                      struct _Unwind_Exception *,
57472758f3SLionel Sambuc                                                      struct _Unwind_Context *);
58472758f3SLionel Sambuc 
59*0a6a1f1dSLionel Sambuc #ifdef _UNWIND_GCC_EXTENSIONS
60*0a6a1f1dSLionel Sambuc struct dwarf_eh_bases {
61*0a6a1f1dSLionel Sambuc   void *tbase;
62*0a6a1f1dSLionel Sambuc   void *dbase;
63*0a6a1f1dSLionel Sambuc   void *func;
64*0a6a1f1dSLionel Sambuc };
65*0a6a1f1dSLionel Sambuc #endif
66*0a6a1f1dSLionel Sambuc 
67472758f3SLionel Sambuc __BEGIN_DECLS
68472758f3SLionel Sambuc 
69472758f3SLionel Sambuc _Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *);
70472758f3SLionel Sambuc void _Unwind_Resume(struct _Unwind_Exception *) __dead;
71472758f3SLionel Sambuc _Unwind_Reason_Code _Unwind_Resume_or_Rethrow(struct _Unwind_Exception *);
72472758f3SLionel Sambuc _Unwind_Reason_Code _Unwind_ForcedUnwind(struct _Unwind_Exception *,
73472758f3SLionel Sambuc                                          _Unwind_Stop_Fn, void *);
74472758f3SLionel Sambuc void _Unwind_DeleteException(struct _Unwind_Exception *);
75472758f3SLionel Sambuc uintptr_t _Unwind_GetGR(struct _Unwind_Context *, int);
76472758f3SLionel Sambuc void _Unwind_SetGR(struct _Unwind_Context *, int, uintptr_t);
77472758f3SLionel Sambuc uintptr_t _Unwind_GetIP(struct _Unwind_Context *);
78b029fb59SBen Gras uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *, int *);
79472758f3SLionel Sambuc uintptr_t _Unwind_GetCFA(struct _Unwind_Context *);
80472758f3SLionel Sambuc void _Unwind_SetIP(struct _Unwind_Context *, uintptr_t);
81472758f3SLionel Sambuc uintptr_t _Unwind_GetRegionStart(struct _Unwind_Context *);
82472758f3SLionel Sambuc uintptr_t _Unwind_GetLanguageSpecificData(struct _Unwind_Context *);
83472758f3SLionel Sambuc uintptr_t _Unwind_GetDataRelBase(struct _Unwind_Context *);
84472758f3SLionel Sambuc uintptr_t _Unwind_GetTextRelBase(struct _Unwind_Context *);
85472758f3SLionel Sambuc 
86472758f3SLionel Sambuc typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context *,
87472758f3SLionel Sambuc                                                 void *);
88472758f3SLionel Sambuc _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void *);
89472758f3SLionel Sambuc void *_Unwind_FindEnclosingFunction(void *);
90472758f3SLionel Sambuc 
91472758f3SLionel Sambuc void __register_frame(const void *);
92472758f3SLionel Sambuc void __register_frame_info(const void *, void *);
93472758f3SLionel Sambuc void __deregister_frame(const void *);
94472758f3SLionel Sambuc void *__deregister_frame_info(const void *);
95472758f3SLionel Sambuc 
96*0a6a1f1dSLionel Sambuc #ifdef _UNWIND_GCC_EXTENSIONS
97*0a6a1f1dSLionel Sambuc void *_Unwind_Find_FDE(void *, struct dwarf_eh_bases *);
98*0a6a1f1dSLionel Sambuc #endif
99*0a6a1f1dSLionel Sambuc 
100472758f3SLionel Sambuc __END_DECLS
101472758f3SLionel Sambuc 
102472758f3SLionel Sambuc #endif // _UNWIND_H
103