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