clang API Documentation

unwind.h
Go to the documentation of this file.
00001 /*===---- unwind.h - Stack unwinding ----------------------------------------===
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining a copy
00004  * of this software and associated documentation files (the "Software"), to deal
00005  * in the Software without restriction, including without limitation the rights
00006  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00007  * copies of the Software, and to permit persons to whom the Software is
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The above copyright notice and this permission notice shall be included in
00011  * all copies or substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00014  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00015  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00016  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00017  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00018  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00019  * THE SOFTWARE.
00020  *
00021  *===-----------------------------------------------------------------------===
00022  */
00023 
00024 /* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/
00025 
00026 #if __has_include_next(<unwind.h>)
00027 /* Darwin and libunwind provide an unwind.h. If that's available, use
00028  * it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE,
00029  * so define that around the include.*/
00030 # ifndef _GNU_SOURCE
00031 #  define _SHOULD_UNDEFINE_GNU_SOURCE
00032 #  define _GNU_SOURCE
00033 # endif
00034 // libunwind's unwind.h reflects the current visibility.  However, Mozilla
00035 // builds with -fvisibility=hidden and relies on gcc's unwind.h to reset the
00036 // visibility to default and export its contents.  gcc also allows users to
00037 // override its override by #defining HIDE_EXPORTS (but note, this only obeys
00038 // the user's -fvisibility setting; it doesn't hide any exports on its own).  We
00039 // imitate gcc's header here:
00040 # ifdef HIDE_EXPORTS
00041 #  include_next <unwind.h>
00042 # else
00043 #  pragma GCC visibility push(default)
00044 #  include_next <unwind.h>
00045 #  pragma GCC visibility pop
00046 # endif
00047 # ifdef _SHOULD_UNDEFINE_GNU_SOURCE
00048 #  undef _GNU_SOURCE
00049 #  undef _SHOULD_UNDEFINE_GNU_SOURCE
00050 # endif
00051 #else
00052 
00053 #include <stdint.h>
00054 
00055 #ifdef __cplusplus
00056 extern "C" {
00057 #endif
00058 
00059 /* It is a bit strange for a header to play with the visibility of the
00060    symbols it declares, but this matches gcc's behavior and some programs
00061    depend on it */
00062 #pragma GCC visibility push(default)
00063 
00064 struct _Unwind_Context;
00065 typedef enum {
00066   _URC_NO_REASON = 0,
00067   _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
00068 
00069   _URC_FATAL_PHASE2_ERROR = 2,
00070   _URC_FATAL_PHASE1_ERROR = 3,
00071   _URC_NORMAL_STOP = 4,
00072 
00073   _URC_END_OF_STACK = 5,
00074   _URC_HANDLER_FOUND = 6,
00075   _URC_INSTALL_CONTEXT = 7,
00076   _URC_CONTINUE_UNWIND = 8
00077 } _Unwind_Reason_Code;
00078 
00079 
00080 #ifdef __arm__
00081 
00082 typedef enum { 
00083   _UVRSC_CORE = 0,        /* integer register */ 
00084   _UVRSC_VFP = 1,         /* vfp */ 
00085   _UVRSC_WMMXD = 3,       /* Intel WMMX data register */ 
00086   _UVRSC_WMMXC = 4        /* Intel WMMX control register */ 
00087 } _Unwind_VRS_RegClass; 
00088 
00089 typedef enum { 
00090   _UVRSD_UINT32 = 0,  
00091   _UVRSD_VFPX = 1,  
00092   _UVRSD_UINT64 = 3,  
00093   _UVRSD_FLOAT = 4,  
00094   _UVRSD_DOUBLE = 5 
00095 } _Unwind_VRS_DataRepresentation; 
00096 
00097 typedef enum { 
00098   _UVRSR_OK = 0,  
00099   _UVRSR_NOT_IMPLEMENTED = 1,  
00100   _UVRSR_FAILED = 2  
00101 } _Unwind_VRS_Result; 
00102 
00103 _Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *context,
00104   _Unwind_VRS_RegClass regclass,
00105   uint32_t regno,
00106   _Unwind_VRS_DataRepresentation representation,
00107   void *valuep);
00108 
00109 #else
00110 
00111 uintptr_t _Unwind_GetIP(struct _Unwind_Context* context);
00112 
00113 #endif
00114 
00115 typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context*, void*);
00116 _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void*);
00117 
00118 #pragma GCC visibility pop
00119 
00120 #ifdef __cplusplus
00121 }
00122 #endif
00123 
00124 #endif