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-2017 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 00046 class SoErrorStack : public SoError 00047 { 00048 public: 00049 00053 struct StackFrame 00054 { 00055 int frameIndex; // Index of this frame in the callstack, 0 is top one. 00056 00057 SbString functionName; // Function reached in this frame. 00058 int lineNumber; // Line number in the frame. 00059 00060 SbString moduleName; // Module which contains the function. 00061 SbString moduleDescription; // More information about the module (Type, fullpath...) 00062 }; 00063 00070 static void setHandlerCallback(SoErrorCB *cb, void *data); 00071 00078 static SoErrorCB *getHandlerCallback(); 00079 00086 static void* getHandlerData(); 00087 00091 static SoType getClassTypeId(); 00092 00096 virtual SoType getTypeId() const; 00097 00102 static void post(); 00103 00112 std::vector< SoErrorStack::StackFrame > getStackFrames() const; 00113 00119 SbString getStack() const; 00120 00121 private: 00122 00123 // Initializes SoErrorStack class 00124 static void initClass(); 00125 static void exitClass(); 00126 00127 private: 00128 00129 SoErrorStack(); 00130 virtual ~SoErrorStack(); 00131 00132 // Signals handler. 00133 static void signalHandler(int signo); 00134 00135 static SoType s_classTypeId; // Type id of SoDebugError class 00136 static SoErrorCB* s_handlerCB; // Handler callback for class 00137 static void* s_cbData; // User data for callback 00138 00139 typedef void (*tHandler)(int); 00140 00141 // We keep the old handlers in case of, if they are not null we'll call them 00142 // in the handler. 00143 static tHandler s_handlerSIGINT; 00144 static tHandler s_handlerSIGILL; 00145 static tHandler s_handlerSIGFPE; 00146 static tHandler s_handlerSIGSEGV; 00147 static tHandler s_handlerSIGTERM; 00148 static tHandler s_handlerSIGABRT; 00149 00150 // Data for the custom callbacks. 00151 std::vector< SoErrorStack::StackFrame > m_stack; 00152 SbString m_decodedStack; 00153 }; 00154 00155 00156 #endif // SO_ERROR_STACK_H 00157 00158