unwind.h revision ab0fdbbb4ce951d3c5f39f9412fb0542487879f0
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
29ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#ifdef __cplusplus
30ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern "C" {
31ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#endif
32ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
33ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Minimal interface as per C++ ABI draft standard:
34ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
35ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm	http://www.codesourcery.com/cxx-abi/abi-eh.html */
36ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
37ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmtypedef enum
38ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm  {
39ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_NO_REASON = 0,
40ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
41ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_FATAL_PHASE2_ERROR = 2,
42ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_FATAL_PHASE1_ERROR = 3,
43ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_NORMAL_STOP = 4,
44ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_END_OF_STACK = 5,
45ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_HANDLER_FOUND = 6,
46ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_INSTALL_CONTEXT = 7,
47ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _URC_CONTINUE_UNWIND = 8
48ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm  }
49ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm_Unwind_Reason_Code;
50ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
51ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmtypedef int _Unwind_Action;
52ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
53ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#define _UA_SEARCH_PHASE	1
54ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#define _UA_CLEANUP_PHASE	2
55ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#define _UA_HANDLER_FRAME	4
56ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#define _UA_FORCE_UNWIND	8
57ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
58ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmstruct _Unwind_Context;		/* opaque data-structure */
59ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmstruct _Unwind_Exception;	/* forward-declaration */
60ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
61ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmtypedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
62ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm					      struct _Unwind_Exception *);
63ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
64ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmtypedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) (int, _Unwind_Action,
65ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm						unsigned long,
66ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm						struct _Unwind_Exception *,
67ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm						struct _Unwind_Context *,
68ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm						void *);
69ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
70ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* The C++ ABI requires exception_class, private_1, and private_2 to
71ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   be of type uint64 and the entire structure to be
72ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   double-word-aligned, but that seems a bit overly IA-64-specific.
73ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   Using "unsigned long" instead should give us the desired effect on
74ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   IA-64, while being more general.  */
75ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmstruct _Unwind_Exception
76ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm  {
77ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    unsigned long exception_class;
78ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    _Unwind_Exception_Cleanup_Fn exception_cleanup;
79ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    unsigned long private_1;
80ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    unsigned long private_2;
81ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm  };
82ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
83ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
84ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
85ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm						 _Unwind_Stop_Fn, void *);
86ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern void _Unwind_Resume (struct _Unwind_Exception *);
87ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern void _Unwind_DeleteException (struct _Unwind_Exception *);
88ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetGR (struct _Unwind_Context *, int);
89ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern void _Unwind_SetGR (struct _Unwind_Context *, int, unsigned long);
90ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetIP (struct _Unwind_Context *);
91ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern void _Unwind_SetIP (struct _Unwind_Context *, unsigned long);
92ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetLanguageSpecificData (struct _Unwind_Context*);
93ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetRegionStart (struct _Unwind_Context *);
94ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
95ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#ifdef _GNU_SOURCE
96ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
97ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Callback for _Unwind_Backtrace().  The backtrace stops immediately
98ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   if the callback returns any value other than _URC_NO_REASON. */
99ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmtypedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (struct _Unwind_Context *,
100ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm						 void *);
101ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
102ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* See http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00082.html for why
103ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   _UA_END_OF_STACK exists.  */
104ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm# define _UA_END_OF_STACK	16
105ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
106ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* If the unwind was initiated due to a forced unwind, resume that
107ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   operation, else re-raise the exception.  This is used by
108ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   __cxa_rethrow().  */
109ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern _Unwind_Reason_Code
110ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm	  _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *);
111ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
112ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* See http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00154.html for why
113ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   _Unwind_GetBSP() exists.  */
114ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetBSP (struct _Unwind_Context *);
115ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
116ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Return the "canonical frame address" for the given context.
117ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   This is used by NPTL... */
118ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetCFA (struct _Unwind_Context *);
119ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
120ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Return the base-address for data references.  */
121ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetDataRelBase (struct _Unwind_Context *);
122ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
123ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Return the base-address for text references.  */
124ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern unsigned long _Unwind_GetTextRelBase (struct _Unwind_Context *);
125ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
126ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Call _Unwind_Trace_Fn once for each stack-frame, without doing any
127ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   cleanup.  The first frame for which the callback is invoked is the
128ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   one for the caller of _Unwind_Backtrace().  _Unwind_Backtrace()
129ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   returns _URC_END_OF_STACK when the backtrace stopped due to
130ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   reaching the end of the call-chain or _URC_FATAL_PHASE1_ERROR if it
131ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   stops for any other reason.  */
132ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
133ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
134ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* Find the start-address of the procedure containing the specified IP
135ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   or NULL if it cannot be found (e.g., because the function has no
136ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   unwind info).  Note: there is not necessarily a one-to-one
137ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   correspondence between source-level functions and procedures: some
138ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   functions don't have unwind-info and others are split into multiple
139ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm   procedures.  */
140ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidmextern void *_Unwind_FindEnclosingFunction (void *);
141ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
142ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm/* See also Linux Standard Base Spec:
143ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm    http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/libgcc-s.html */
144ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
145ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#endif /* _GNU_SOURCE */
146ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
147ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#ifdef __cplusplus
148ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm};
149ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#endif
150ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm
151ab0fdbbb4ce951d3c5f39f9412fb0542487879f0hp.com!davidm#endif /* _UNWIND_H */
152