1ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* libunwind - a platform-independent unwind library
2ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   Copyright (C) 2003 Hewlett-Packard Co
3ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm	Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
5ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmThis file is part of libunwind.
6ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
7ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmPermission is hereby granted, free of charge, to any person obtaining
8ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidma copy of this software and associated documentation files (the
9ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm"Software"), to deal in the Software without restriction, including
10ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmwithout limitation the rights to use, copy, modify, merge, publish,
11ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmdistribute, sublicense, and/or sell copies of the Software, and to
12ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmpermit persons to whom the Software is furnished to do so, subject to
13ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmthe following conditions:
14ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
15ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmThe above copyright notice and this permission notice shall be
16ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmincluded in all copies or substantial portions of the Software.
17ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
18ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
25ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
26ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#ifndef _UNWIND_H
27ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#define _UNWIND_H
28ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
29752076789fdeec16827ddd846485182d4c3cd11fStefan Demharter/* For uint64_t */
30752076789fdeec16827ddd846485182d4c3cd11fStefan Demharter#include <stdint.h>
31752076789fdeec16827ddd846485182d4c3cd11fStefan Demharter
32ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#ifdef __cplusplus
33ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern "C" {
34ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#endif
35ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
36ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Minimal interface as per C++ ABI draft standard:
37ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
38ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm	http://www.codesourcery.com/cxx-abi/abi-eh.html */
39ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
40ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmtypedef enum
41ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm  {
42ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_NO_REASON = 0,
43ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
44ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_FATAL_PHASE2_ERROR = 2,
45ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_FATAL_PHASE1_ERROR = 3,
46ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_NORMAL_STOP = 4,
47ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_END_OF_STACK = 5,
48ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_HANDLER_FOUND = 6,
49ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_INSTALL_CONTEXT = 7,
50ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_CONTINUE_UNWIND = 8
51ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm  }
52ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm_Unwind_Reason_Code;
53ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
54ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmtypedef int _Unwind_Action;
55ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
56ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#define _UA_SEARCH_PHASE	1
57ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#define _UA_CLEANUP_PHASE	2
58ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#define _UA_HANDLER_FRAME	4
59ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#define _UA_FORCE_UNWIND	8
60ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
61ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmstruct _Unwind_Context;		/* opaque data-structure */
62ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmstruct _Unwind_Exception;	/* forward-declaration */
63ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
64ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmtypedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
65ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm					      struct _Unwind_Exception *);
66ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
67ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmtypedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) (int, _Unwind_Action,
68752076789fdeec16827ddd846485182d4c3cd11fStefan Demharter						uint64_t,
69ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm						struct _Unwind_Exception *,
70ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm						struct _Unwind_Context *,
71ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm						void *);
72ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
73ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* The C++ ABI requires exception_class, private_1, and private_2 to
74ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   be of type uint64 and the entire structure to be
75752076789fdeec16827ddd846485182d4c3cd11fStefan Demharter   double-word-aligned. Please note that exception_class stays 64-bit
76752076789fdeec16827ddd846485182d4c3cd11fStefan Demharter   even on 32-bit machines for gcc compatibility.  */
77ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmstruct _Unwind_Exception
78ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm  {
79752076789fdeec16827ddd846485182d4c3cd11fStefan Demharter    uint64_t exception_class;
80ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _Unwind_Exception_Cleanup_Fn exception_cleanup;
81ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    unsigned long private_1;
82ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    unsigned long private_2;
83752076789fdeec16827ddd846485182d4c3cd11fStefan Demharter  } __attribute__((__aligned__));
84ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
85ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
86ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
87ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm						 _Unwind_Stop_Fn, void *);
88ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern void _Unwind_Resume (struct _Unwind_Exception *);
89ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern void _Unwind_DeleteException (struct _Unwind_Exception *);
90ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetGR (struct _Unwind_Context *, int);
91ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern void _Unwind_SetGR (struct _Unwind_Context *, int, unsigned long);
92ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetIP (struct _Unwind_Context *);
932fce54102cdb03aa2d3105c750685dc7cf2677b1Arun Sharmaextern unsigned long _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
94ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern void _Unwind_SetIP (struct _Unwind_Context *, unsigned long);
95ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetLanguageSpecificData (struct _Unwind_Context*);
96ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetRegionStart (struct _Unwind_Context *);
97ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
98ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#ifdef _GNU_SOURCE
99ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
100ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Callback for _Unwind_Backtrace().  The backtrace stops immediately
101ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   if the callback returns any value other than _URC_NO_REASON. */
102ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmtypedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (struct _Unwind_Context *,
103ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm						 void *);
104ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
105ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* See http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00082.html for why
106ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   _UA_END_OF_STACK exists.  */
107ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm# define _UA_END_OF_STACK	16
108ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
109ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* If the unwind was initiated due to a forced unwind, resume that
110ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   operation, else re-raise the exception.  This is used by
111ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   __cxa_rethrow().  */
112ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern _Unwind_Reason_Code
113ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm	  _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *);
114ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
115ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* See http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00154.html for why
116ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   _Unwind_GetBSP() exists.  */
117ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetBSP (struct _Unwind_Context *);
118ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
119ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Return the "canonical frame address" for the given context.
120ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   This is used by NPTL... */
121ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetCFA (struct _Unwind_Context *);
122ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
123ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Return the base-address for data references.  */
124ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetDataRelBase (struct _Unwind_Context *);
125ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
126ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Return the base-address for text references.  */
127ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetTextRelBase (struct _Unwind_Context *);
128ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
129ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Call _Unwind_Trace_Fn once for each stack-frame, without doing any
130ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   cleanup.  The first frame for which the callback is invoked is the
131ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   one for the caller of _Unwind_Backtrace().  _Unwind_Backtrace()
132ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   returns _URC_END_OF_STACK when the backtrace stopped due to
133ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   reaching the end of the call-chain or _URC_FATAL_PHASE1_ERROR if it
134ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   stops for any other reason.  */
135ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
136ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
137ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Find the start-address of the procedure containing the specified IP
138ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   or NULL if it cannot be found (e.g., because the function has no
139ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   unwind info).  Note: there is not necessarily a one-to-one
140ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   correspondence between source-level functions and procedures: some
141ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   functions don't have unwind-info and others are split into multiple
142ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   procedures.  */
143ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern void *_Unwind_FindEnclosingFunction (void *);
144ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
145ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* See also Linux Standard Base Spec:
146ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/libgcc-s.html */
147ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
148ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#endif /* _GNU_SOURCE */
149ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
150ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#ifdef __cplusplus
151ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm};
152ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#endif
153ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
154ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#endif /* _UNWIND_H */
155