From a8af70cee1ee4aefa99b4d7ad6e949ad97d954c3 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 3 Jul 2012 00:19:23 +0000 Subject: [PATCH] - when disabling backtrace ensure console output only shows direct errors without backtrace --- source/glest_game/main/main.cpp | 1 + source/shared_lib/include/platform/sdl/platform_util.h | 1 + .../shared_lib/sources/platform/sdl/platform_util.cpp | 10 ++++++++-- .../sources/platform/win32/platform_util.cpp | 6 +++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index d74b8dd31..779572727 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -2986,6 +2986,7 @@ int glestMain(int argc, char** argv) { if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_DISABLE_BACKTRACE]) == true) { disableBacktrace = true; } + PlatformExceptionHandler::disableBacktrace= disableBacktrace; // UErrorCode status = U_ZERO_ERROR; // u_init(&status); diff --git a/source/shared_lib/include/platform/sdl/platform_util.h b/source/shared_lib/include/platform/sdl/platform_util.h index 2e773e68d..94a45ebfb 100644 --- a/source/shared_lib/include/platform/sdl/platform_util.h +++ b/source/shared_lib/include/platform/sdl/platform_util.h @@ -41,6 +41,7 @@ public: class PlatformExceptionHandler { public: static string application_binary; + static bool disableBacktrace; static string getStackTrace(); virtual ~PlatformExceptionHandler() {} diff --git a/source/shared_lib/sources/platform/sdl/platform_util.cpp b/source/shared_lib/sources/platform/sdl/platform_util.cpp index 66fea022d..d8d7ca42a 100644 --- a/source/shared_lib/sources/platform/sdl/platform_util.cpp +++ b/source/shared_lib/sources/platform/sdl/platform_util.cpp @@ -32,6 +32,7 @@ using namespace std; namespace Shared{ namespace Platform{ string PlatformExceptionHandler::application_binary=""; +bool PlatformExceptionHandler::disableBacktrace = false; // This was the simplest, most portable solution i could find in 5 mins for linux int MessageBox(int handle, const char *msg, const char *title, int buttons) { @@ -161,11 +162,16 @@ static int getFileAndLine(char *function, void *address, char *file, size_t flen #endif string PlatformExceptionHandler::getStackTrace() { - string errMsg = ""; + string errMsg = "\nStack Trace:\n"; + if(PlatformExceptionHandler::disableBacktrace == true) { + errMsg += "disabled..."; + return errMsg; + } + //#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD) #if defined(HAS_GCC_BACKTRACE) // if(disableBacktrace == false && sdl_quitCalled == false) { - errMsg = "\nStack Trace:\n"; + //errMsg = "\nStack Trace:\n"; //errMsg += "To find line #'s use:\n"; //errMsg += "readelf --debug-dump=decodedline %s | egrep 0xaddress-of-stack\n"; diff --git a/source/shared_lib/sources/platform/win32/platform_util.cpp b/source/shared_lib/sources/platform/win32/platform_util.cpp index 86d589aff..eaddbcffa 100644 --- a/source/shared_lib/sources/platform/win32/platform_util.cpp +++ b/source/shared_lib/sources/platform/win32/platform_util.cpp @@ -31,6 +31,7 @@ namespace Shared { namespace Platform { // class PlatformExceptionHandler // ===================================================== string PlatformExceptionHandler::application_binary=""; +bool PlatformExceptionHandler::disableBacktrace = false; PlatformExceptionHandler *PlatformExceptionHandler::thisPointer= NULL; // Constructs object and convert lpaszString to Unicode @@ -152,7 +153,10 @@ void PlatformExceptionHandler::install(string dumpFileName){ string PlatformExceptionHandler::getStackTrace() { string result = "\nStack Trace:\n"; - + if(PlatformExceptionHandler::disableBacktrace == true) { + result += "disabled..."; + return result; + } #ifndef __MINGW32__ /* unsigned int i;