00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (01 2010) 00022 **=======================================================================*/ 00023 00024 #if !defined(SO_ERROR_STACK_H) 00025 #define SO_ERROR_STACK_H 00026 00027 #include <Inventor/errors/SoError.h> 00028 00047 class SoErrorStack : public SoError 00048 { 00049 public: 00050 00054 struct StackFrame 00055 { 00056 int frameIndex; // Index of this frame in the callstack, 0 is top one. 00057 00058 SbString functionName; // Function reached in this frame. 00059 int lineNumber; // Line number in the frame. 00060 00061 SbString moduleName; // Module which contains the function. 00062 SbString moduleDescription; // More information about the module (Type, fullpath...) 00063 }; 00064 00071 static void setHandlerCallback(SoErrorCB *cb, void *data); 00072 00079 static SoErrorCB *getHandlerCallback(); 00080 00087 static void* getHandlerData(); 00088 00092 static SoType getClassTypeId(); 00093 00097 virtual SoType getTypeId() const; 00098 00103 static void post(); 00104 00113 std::vector< SoErrorStack::StackFrame > getStackFrames() const; 00114 00120 SbString getStack() const; 00121 00122 private: 00123 00124 // Initializes SoErrorStack class 00125 static void initClass(); 00126 static void exitClass(); 00127 00128 private: 00129 00130 SoErrorStack(); 00131 virtual ~SoErrorStack(); 00132 00133 // Signals handler. 00134 static void signalHandler(int signo); 00135 00136 static SoType s_classTypeId; // Type id of SoDebugError class 00137 static SoErrorCB* s_handlerCB; // Handler callback for class 00138 static void* s_cbData; // User data for callback 00139 00140 typedef void (*tHandler)(int); 00141 00142 // We keep the old handlers in case of, if they are not null we'll call them 00143 // in the handler. 00144 static tHandler s_handlerSIGINT; 00145 static tHandler s_handlerSIGILL; 00146 static tHandler s_handlerSIGFPE; 00147 static tHandler s_handlerSIGSEGV; 00148 static tHandler s_handlerSIGTERM; 00149 static tHandler s_handlerSIGABRT; 00150 00151 // Data for the custom callbacks. 00152 std::vector< SoErrorStack::StackFrame > m_stack; 00153 SbString m_decodedStack; 00154 }; 00155 00156 00157 #endif // SO_ERROR_STACK_H 00158 00159