26 #ifndef G3D_DEBUGASSERT_H
27 #define G3D_DEBUGASSERT_H
36 # pragma warning (disable : 4127)
44 #include <X11/Xutil.h>
45 #include <X11/Xatom.h>
82 const char* _expression,
83 const std::string& message,
105 namespace _internal {
118 # if defined(_MSC_VER)
119 # define rawBreak() ::DebugBreak();
120 # elif defined(__i386__)
122 # define rawBreak() __asm__ __volatile__ ( "int $3" );
125 # define rawBreak() ::abort()
129 # define debugBreak() G3D::_internal::_releaseInputGrab_(); rawBreak(); G3D::_internal::_restoreInputGrab_();
130 # define debugAssert(exp) debugAssertM(exp, "Debug assertion failure")
132 #ifdef G3D_DEBUG_NOGUI
133 #define __debugPromptShowDialog__ false
135 #define __debugPromptShowDialog__ true
138 #define debugAssertM(exp, message) do { \
140 G3D::_internal::_releaseInputGrab_(); \
141 if ((G3D::_internal::_debugHook != NULL) && \
142 G3D::_internal::_debugHook((const char*)(#exp), message, __FILE__, __LINE__, __debugPromptShowDialog__)) { \
145 G3D::_internal::_restoreInputGrab_(); \
149 #define alwaysAssertM debugAssertM
152 #ifdef G3D_DEBUG_NOGUI
153 #define __debugPromptShowDialog__ false
155 #define __debugPromptShowDialog__ true
159 #define rawBreak() do {} while (0)
160 #define debugAssert(exp) do {} while (0)
161 #define debugAssertM(exp, message) do {} while (0)
162 #define debugBreak() do {} while (0)
165 #define alwaysAssertM(exp, message) { \
167 G3D::_internal::_releaseInputGrab_(); \
168 if ((G3D::_internal::_failureHook != NULL) && \
169 G3D::_internal::_failureHook(#exp, message, __FILE__, __LINE__, __debugPromptShowDialog__)) { \
172 G3D::_internal::_restoreInputGrab_(); \
180 namespace G3D {
namespace _internal {
190 extern Display* x11Display;
198 extern Window x11Window;
209 const char* expression,
210 const std::string& message,
211 const char* filename,
216 const char* expression,
217 const std::string& message,
218 const char* filename,
bool _handleErrorCheck_(const char *expression, const std::string &message, const char *filename, int lineNumber, bool useGuiPrompt)
Definition: debugAssert.cpp:191
AssertionHook _failureHook
Definition: debugAssert.cpp:37
void setFailureHook(AssertionHook hook)
Definition: debugAssert.cpp:315
void setAssertionHook(AssertionHook hook)
Definition: debugAssert.cpp:307
#define bool
Definition: CascPort.h:16
AssertionHook _debugHook
Definition: debugAssert.cpp:36
void _restoreInputGrab_()
Definition: debugAssert.cpp:279
void _releaseInputGrab_()
Definition: debugAssert.cpp:233
AssertionHook failureHook()
Definition: debugAssert.cpp:319
bool(* AssertionHook)(const char *_expression, const std::string &message, const char *filename, int lineNumber, bool useGuiPrompt)
Definition: debugAssert.h:81
AssertionHook assertionHook()
Definition: debugAssert.cpp:311
bool _handleDebugAssert_(const char *expression, const std::string &message, const char *filename, int lineNumber, bool useGuiPrompt)
Definition: debugAssert.cpp:136