diff options
| author | Nicholas Estelami <NEstelami@users.noreply.github.com> | 2020-05-07 04:03:48 -0400 |
|---|---|---|
| committer | Nicholas Estelami <NEstelami@users.noreply.github.com> | 2020-05-07 04:03:48 -0400 |
| commit | 50ab0b87f4fc7733d9aaffb83879e65e29e32021 (patch) | |
| tree | ce32d9d642620d1695e61cb3ef51e67bfedc7203 /ZAP2/Main.cpp | |
| parent | 35f498b4beeec6f75f8098b64a636c0d80c1dd20 (diff) | |
Added a fault handler for Linux builds. Fixed a few matching errors and undefined behavior.
Diffstat (limited to 'ZAP2/Main.cpp')
| -rw-r--r-- | ZAP2/Main.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ZAP2/Main.cpp b/ZAP2/Main.cpp index 9adf171..958a3c6 100644 --- a/ZAP2/Main.cpp +++ b/ZAP2/Main.cpp @@ -7,6 +7,12 @@ #include "File.h" #include "Globals.h" +#ifndef _MSC_VER +#include <execinfo.h> +#include <unistd.h> +#include <signal.h> +#endif + #include <string> #include "tinyxml2.h" @@ -20,8 +26,33 @@ void BuildAssetTexture(string pngFilePath, TextureType texType, string outPath); int OldMain(int argc, char* argv[]); int NewMain(int argc, char* argv[]); +#ifndef _MSC_VER +void ErrorHandler(int sig) +{ + void* array[4096]; + char** symbols; + size_t size; + size = backtrace(array, 4096); + symbols = backtrace_symbols(array, 4096); + + for (int i = 1; i < size; i++) + { + size_t len = strlen(symbols[i]); + cout << symbols[i] << "\n"; + } + + //cout << "Error: signal " << sig << ":\n"; + backtrace_symbols_fd(array, size, STDERR_FILENO); + exit(1); +} +#endif + int main(int argc, char* argv[]) { +#ifndef _MSC_VER + //signal(SIGSEGV, ErrorHandler); +#endif + Globals* g = new Globals(); // TEST TEST @@ -30,6 +61,8 @@ int main(int argc, char* argv[]) //return 0; #endif + + return OldMain(argc, argv); //return NewMain(argc, argv); |
