From: José Fonseca Date: Tue, 23 Apr 2013 16:56:08 +0000 (+0100) Subject: os: Be more concise with the semantics of os::abort. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=e427adb8bab3dad6af1667febf9ed474cb011692;p=apitrace os: Be more concise with the semantics of os::abort. --- diff --git a/common/os.hpp b/common/os.hpp index 91c819f..985ff6b 100644 --- a/common/os.hpp +++ b/common/os.hpp @@ -73,6 +73,12 @@ void log(const char *format, ...) #endif #endif +/** + * Exit immediately. + * + * This should be called only from the wrappers, when there is no safe way of + * failing gracefully. + */ void abort(void); void setExceptionCallback(void (*callback)(void)); diff --git a/common/os_posix.cpp b/common/os_posix.cpp index 0d93b31..bd15bba 100644 --- a/common/os_posix.cpp +++ b/common/os_posix.cpp @@ -174,6 +174,7 @@ log(const char *format, ...) __android_log_vprint(ANDROID_LOG_DEBUG, "apitrace", format, ap); #else vfprintf(stderr, format, ap); + fflush(stderr); #endif va_end(ap); logging = false; @@ -186,7 +187,7 @@ long long timeFrequency = 0LL; void abort(void) { - exit(0); + _exit(1); } diff --git a/common/os_win32.cpp b/common/os_win32.cpp index e9306cd..f297a55 100644 --- a/common/os_win32.cpp +++ b/common/os_win32.cpp @@ -229,11 +229,7 @@ long long timeFrequency = 0LL; void abort(void) { -#ifndef NDEBUG - DebugBreak(); -#else - ExitProcess(0); -#endif + TerminateProcess(GetCurrentProcess(), 1); } @@ -299,7 +295,7 @@ unhandledExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo) static int recursion_count = 0; if (recursion_count) { - fprintf(stderr, "apitrace: warning: recursion handling exception\n"); + fputs("apitrace: warning: recursion handling exception\n", stderr); } else { if (gCallback) { ++recursion_count; diff --git a/retrace/glretrace_egl.cpp b/retrace/glretrace_egl.cpp index 4585564..42f7b38 100644 --- a/retrace/glretrace_egl.cpp +++ b/retrace/glretrace_egl.cpp @@ -188,7 +188,7 @@ static void retrace_eglCreateContext(trace::Call &call) { } retrace::warning(call) << "Failed to create " << name << " context.\n"; - os::abort(); + exit(1); } context_map[orig_context] = context;