medfall

A super great game engine
Log | Files | Refs

commit 5a66ded25c45343ecfaa5ad57b0519d59a5ffefd
parent 33bd1dce42775db46fb1eae240c4ea64f32c0224
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Sep  2 18:48:40 +0300

Put the abort in print_backtrace so we can do __debugbreak on Windows instead

Diffstat:
intrinsics.h | 3+--
log.h | 3+--
unix_backtrace.h | 4+++-
win32_backtrace.h | 4+++-
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/intrinsics.h b/intrinsics.h @@ -53,8 +53,7 @@ inline void assert_impl( const bool predicate, const char * message ) { puts( message ); int err = errno; printf( "errno(%d): %s\n", err, strerror( err ) ); - print_backtrace(); - abort(); + print_backtrace_and_abort(); } } diff --git a/log.h b/log.h @@ -38,6 +38,5 @@ const char * logger_get_logs_dir(); #define FATAL( form, ... ) \ do { \ logger_log( LOGLEVEL_FATAL, "[FATAL] " form, ##__VA_ARGS__ ); \ - print_backtrace(); \ - abort(); \ + print_backtrace_and_abort(); \ } while( 0 ) diff --git a/unix_backtrace.h b/unix_backtrace.h @@ -1,11 +1,13 @@ #pragma once #include <stdio.h> +#include <stdlib.h> #include <unistd.h> #include <execinfo.h> -inline void print_backtrace() { +inline void print_backtrace_and_abort() { void * stack[ 128 ]; const int stack_size = backtrace( stack, 128 ); backtrace_symbols_fd( stack, stack_size, STDERR_FILENO ); + abort(); } diff --git a/win32_backtrace.h b/win32_backtrace.h @@ -7,7 +7,7 @@ #include <dbghelp.h> #pragma warning( pop ) -inline void print_backtrace() { +inline void print_backtrace_and_abort() { const int max_symbol_len = 1024; HANDLE process = GetCurrentProcess(); @@ -37,4 +37,6 @@ inline void print_backtrace() { printf( "%s (0x%08I64x)\n", symbol->Name, symbol->Address ); } } + + __debugbreak(); }