From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/debug_8h-source.html | 405 ++++++++++++++++++++++++++++++++++ 1 file changed, 405 insertions(+) create mode 100644 docs/doxygen/nel/debug_8h-source.html (limited to 'docs/doxygen/nel/debug_8h-source.html') diff --git a/docs/doxygen/nel/debug_8h-source.html b/docs/doxygen/nel/debug_8h-source.html new file mode 100644 index 00000000..43f8cd13 --- /dev/null +++ b/docs/doxygen/nel/debug_8h-source.html @@ -0,0 +1,405 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

debug.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #ifndef NL_DEBUG_H
+00027 #define NL_DEBUG_H
+00028 #include <stdio.h>
+00029 
+00030 #include "nel/misc/common.h"
+00031 #include "nel/misc/log.h"
+00032 #include "nel/misc/mutex.h"
+00033 #include "nel/misc/mem_displayer.h"
+00034 #include "nel/misc/displayer.h"
+00035 
+00036 namespace NLMISC
+00037 {
+00038 
+00039 //
+00040 // Externals
+00041 //
+00042 
+00043 extern CLog *ErrorLog;
+00044 extern CLog *WarningLog;
+00045 extern CLog *InfoLog;
+00046 extern CLog *DebugLog;
+00047 extern CLog *AssertLog;
+00048 
+00049 extern CMemDisplayer *DefaultMemDisplayer;
+00050 extern CMsgBoxDisplayer *DefaultMsgBoxDisplayer;
+00051 
+00052 //
+00053 // Functions
+00054 //
+00055 
+00057 void nlFatalError (const char *format, ...);
+00058 
+00060 void nlError (const char *format, ...);
+00061 
+00062 // internal use only
+00063 void createDebug (const char *logPath = NULL, bool logInFile = true);
+00064 
+00065 // internal breakpoint window
+00066 void enterBreakpoint (const char *message);
+00067 
+00068 // Need a breakpoint in the assert / verify macro
+00069 extern bool DebugNeedAssert;
+00070 
+00071 // Macros
+00072 
+00073 
+00087 #define nldebug NLMISC::createDebug (), NLMISC::DebugLog->setPosition( __LINE__, __FILE__ ), NLMISC::DebugLog->displayNL
+00088 
+00089 
+00094 #define nlinfo NLMISC::createDebug (), NLMISC::InfoLog->setPosition( __LINE__, __FILE__ ), NLMISC::InfoLog->displayNL
+00095 
+00096 
+00114 #define nlwarning NLMISC::createDebug (), NLMISC::WarningLog->setPosition( __LINE__, __FILE__ ), NLMISC::WarningLog->displayNL
+00115 
+00116 
+00133 #define nlerror NLMISC::createDebug (), NLMISC::ErrorLog->setPosition( __LINE__, __FILE__ ), NLMISC::nlFatalError
+00134 
+00135 
+00141 #define nlerrornoex NLMISC::createDebug (), NLMISC::ErrorLog->setPosition( __LINE__, __FILE__ ), NLMISC::nlError
+00142 
+00143 
+00245 // removed because we always check assert (even in release mode) #if defined (NL_OS_WINDOWS) && defined (NL_DEBUG)
+00246 #if defined (NL_OS_WINDOWS)
+00247 #define NLMISC_BREAKPOINT _asm { int 3 }
+00248 #else
+00249 #define NLMISC_BREAKPOINT abort()
+00250 #endif
+00251 
+00252 // removed because we always check assert (even in release mode) #if defined(NL_DEBUG)
+00253 
+00254 #define nlassert(exp) \
+00255 { \
+00256         static bool ignoreNextTime = false; \
+00257         if (!ignoreNextTime && !(exp)) { \
+00258                 NLMISC::DebugNeedAssert = false; \
+00259                 NLMISC::createDebug (); \
+00260                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00261                         NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime = ignoreNextTime; \
+00262                 else \
+00263                         NLMISC::DebugNeedAssert = true; \
+00264                 NLMISC::AssertLog->setPosition (__LINE__, __FILE__); \
+00265                 NLMISC::AssertLog->displayNL ("\"%s\" ", #exp); \
+00266                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00267                         ignoreNextTime = NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime; \
+00268                 if (NLMISC::DebugNeedAssert) \
+00269                         NLMISC_BREAKPOINT; \
+00270         } \
+00271 }
+00272 
+00273 #define nlassertonce(exp) \
+00274 { \
+00275         static bool ignoreNextTime = false; \
+00276         if (!ignoreNextTime && !(exp)) { \
+00277                 ignoreNextTime = true; \
+00278                 NLMISC::DebugNeedAssert = false; \
+00279                 NLMISC::createDebug (); \
+00280                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00281                         NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime = ignoreNextTime; \
+00282                 else \
+00283                         NLMISC::DebugNeedAssert = true; \
+00284                 NLMISC::AssertLog->setPosition (__LINE__, __FILE__); \
+00285                 NLMISC::AssertLog->displayNL ("\"%s\" ", #exp); \
+00286                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00287                         ignoreNextTime = NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime; \
+00288                 if (NLMISC::DebugNeedAssert) \
+00289                         NLMISC_BREAKPOINT; \
+00290         } \
+00291 }
+00292 
+00293 #define nlassertex(exp, str) \
+00294 { \
+00295         static bool ignoreNextTime = false; \
+00296         if (!ignoreNextTime && !(exp)) { \
+00297                 NLMISC::DebugNeedAssert = false; \
+00298                 NLMISC::createDebug (); \
+00299                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00300                         NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime = ignoreNextTime; \
+00301                 else \
+00302                         NLMISC::DebugNeedAssert = true; \
+00303                 NLMISC::AssertLog->setPosition (__LINE__, __FILE__); \
+00304                 NLMISC::AssertLog->display ("\"%s\" ", #exp); \
+00305                 NLMISC::AssertLog->displayRawNL str; \
+00306                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00307                         ignoreNextTime = NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime; \
+00308                 if (NLMISC::DebugNeedAssert) \
+00309                         NLMISC_BREAKPOINT; \
+00310         } \
+00311 }
+00312 
+00313 #define nlverify(exp) \
+00314 { \
+00315         static bool ignoreNextTime = false; \
+00316         if (!ignoreNextTime && !(exp)) { \
+00317                 NLMISC::DebugNeedAssert = false; \
+00318                 NLMISC::createDebug (); \
+00319                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00320                         NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime = ignoreNextTime; \
+00321                 else \
+00322                         NLMISC::DebugNeedAssert = true; \
+00323                 NLMISC::AssertLog->setPosition (__LINE__, __FILE__); \
+00324                 NLMISC::AssertLog->displayNL ("\"%s\" ", #exp); \
+00325                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00326                         ignoreNextTime = NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime; \
+00327                 if (NLMISC::DebugNeedAssert) \
+00328                         NLMISC_BREAKPOINT; \
+00329         } \
+00330 }
+00331 
+00332 #define nlverifyonce(exp) \
+00333 { \
+00334         static bool ignoreNextTime = false; \
+00335         if (!ignoreNextTime && !(exp)) { \
+00336                 ignoreNextTime = true; \
+00337                 NLMISC::DebugNeedAssert = false; \
+00338                 NLMISC::createDebug (); \
+00339                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00340                         NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime = ignoreNextTime; \
+00341                 else \
+00342                         NLMISC::DebugNeedAssert = true; \
+00343                 NLMISC::AssertLog->setPosition (__LINE__, __FILE__); \
+00344                 NLMISC::AssertLog->displayNL ("\"%s\" ", #exp); \
+00345                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00346                         ignoreNextTime = NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime; \
+00347                 if (NLMISC::DebugNeedAssert) \
+00348                         NLMISC_BREAKPOINT; \
+00349         } \
+00350 }
+00351 
+00352 #define nlverifyex(exp, str) \
+00353 { \
+00354         static bool ignoreNextTime = false; \
+00355         if (!ignoreNextTime && !(exp)) { \
+00356                 NLMISC::DebugNeedAssert = false; \
+00357                 NLMISC::createDebug (); \
+00358                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00359                         NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime = ignoreNextTime; \
+00360                 else \
+00361                         NLMISC::DebugNeedAssert = true; \
+00362                 NLMISC::AssertLog->setPosition (__LINE__, __FILE__); \
+00363                 NLMISC::AssertLog->display ("\"%s\" ", #exp); \
+00364                 NLMISC::AssertLog->displayRawNL str; \
+00365                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00366                         ignoreNextTime = NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime; \
+00367                 if (NLMISC::DebugNeedAssert) \
+00368                         NLMISC_BREAKPOINT; \
+00369         } \
+00370 }
+00371 
+00372 
+00373 
+00374 #define nlstop \
+00375 { \
+00376         static bool ignoreNextTime = false; \
+00377         if (!ignoreNextTime) { \
+00378                 NLMISC::DebugNeedAssert = false; \
+00379                 NLMISC::createDebug (); \
+00380                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00381                         NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime = ignoreNextTime; \
+00382                 else \
+00383                         NLMISC::DebugNeedAssert = true; \
+00384                 NLMISC::AssertLog->setPosition (__LINE__, __FILE__); \
+00385                 NLMISC::AssertLog->displayNL ("STOP"); \
+00386                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00387                         ignoreNextTime = NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime; \
+00388                 if (NLMISC::DebugNeedAssert) \
+00389                         NLMISC_BREAKPOINT; \
+00390         } \
+00391 }
+00392 
+00393 #define nlstoponce \
+00394 { \
+00395         static bool ignoreNextTime = false; \
+00396         if (!ignoreNextTime) { \
+00397                 ignoreNextTime = true; \
+00398                 NLMISC::DebugNeedAssert = false; \
+00399                 NLMISC::createDebug (); \
+00400                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00401                         NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime = ignoreNextTime; \
+00402                 else \
+00403                         NLMISC::DebugNeedAssert = true; \
+00404                 NLMISC::AssertLog->setPosition (__LINE__, __FILE__); \
+00405                 NLMISC::AssertLog->displayNL ("STOP"); \
+00406                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00407                         ignoreNextTime = NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime; \
+00408                 if (NLMISC::DebugNeedAssert) \
+00409                         NLMISC_BREAKPOINT; \
+00410         } \
+00411 }
+00412 
+00413 
+00414 #define nlstopex(str) \
+00415 { \
+00416         static bool ignoreNextTime = false; \
+00417         if (!ignoreNextTime) { \
+00418                 NLMISC::DebugNeedAssert = false; \
+00419                 NLMISC::createDebug (); \
+00420                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00421                         NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime = ignoreNextTime; \
+00422                 else \
+00423                         NLMISC::DebugNeedAssert = true; \
+00424                 NLMISC::AssertLog->setPosition (__LINE__, __FILE__); \
+00425                 NLMISC::AssertLog->display ("STOP "); \
+00426                 NLMISC::AssertLog->displayRawNL str; \
+00427                 if (NLMISC::DefaultMsgBoxDisplayer) \
+00428                         ignoreNextTime = NLMISC::DefaultMsgBoxDisplayer->IgnoreNextTime; \
+00429                 if (NLMISC::DebugNeedAssert) \
+00430                         NLMISC_BREAKPOINT; \
+00431         } \
+00432 }
+00433 
+00434 
+00435 /* removed because we always check assert (even in release mode) 
+00436 #else // NL_DEBUG
+00437 
+00438 #define nlassert(exp) \
+00439 NULL
+00440 #define nlassertonce(exp) \
+00441 NULL
+00442 #define nlassertex(exp, str) \
+00443 NULL
+00444 #define nlverify(exp) \
+00445 { exp; }
+00446 #define nlverifyonce(exp) \
+00447 { exp; }
+00448 #define nlverifyex(exp, str) \
+00449 { exp; }
+00450 #define nlstop \
+00451 NULL
+00452 #define nlstoponce \
+00453 NULL
+00454 #define nlstopex(str) \
+00455 NULL
+00456 
+00457 #endif // NL_DEBUG
+00458 */
+00459 
+00460 struct EFatalError : public Exception
+00461 {
+00462         EFatalError() : Exception( "nlerror() called" ) {}
+00463 };
+00464 
+00465 class ETrapDebug : public Exception
+00466 {
+00467 };
+00468 
+00469 // undef default assert to force people to use nlassert() instead of assert()
+00470 #ifdef assert
+00471 #undef assert
+00472 #endif
+00473 #define assert(a) you_must_not_use_assert___use_nl_assert___read_debug_h_file
+00474 
+00475 
+00477 void getCallStackAndLog (std::string &result, sint skipNFirst = 0);
+00478 
+00483 template<class T, class U>      inline T        safe_cast(U o)
+00484 {
+00485         // NB: must check debug because assert may still be here in release
+00486 #ifdef  NL_DEBUG
+00487         nlassert(dynamic_cast<T>(o));
+00488 #endif
+00489         return static_cast<T>(o);
+00490 }
+00491 
+00494 #define nlctassert(cond) sizeof(uint[(cond) ? 1 : 0]);
+00495 
+00496 } // NLMISC
+00497 
+00498 
+00499 #endif // NL_DEBUG_H
+00500 
+00501 /* End of debug.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1