From 0b13cba4eace866e87e9ccbefa0b673f922b5d93 Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 10 Dec 2018 20:03:03 -0500 Subject: [PATCH] add drmingw's exchndl support --- Makefile | 5 +++++ qb/config.libs.sh | 3 +++ qb/config.params.sh | 1 + retroarch.c | 18 ++++++++++++++++-- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 304bc4309f..fbc42d7c81 100644 --- a/Makefile +++ b/Makefile @@ -82,6 +82,11 @@ else OPTIMIZE_FLAG = -O3 -ffast-math endif +ifeq ($(HAVE_DRMINGW), 1) + CFLAGS += -DHAVE_DRMINGW + LDFLAGS += $(DRMINGW_LIBS) +endif + ifneq ($(findstring Win32,$(OS)),) LDFLAGS += -mwindows endif diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 6dbe6f41ef..1ae1e2bfc3 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -418,6 +418,9 @@ if [ "$HAVE_THREADS" = 'no' ] && [ "$HAVE_FFMPEG" != 'no' ]; then die : 'Notice: Threads are not available, FFmpeg will also be disabled.' fi +check_header DRMINGW exchndl.h +check_lib '' DRMINGW -lexchndl + if [ "$HAVE_FFMPEG" != 'no' ]; then check_pkgconf AVCODEC libavcodec 54 check_pkgconf AVFORMAT libavformat 54 diff --git a/qb/config.params.sh b/qb/config.params.sh index 0248eb8aa7..e73e273d39 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -134,3 +134,4 @@ HAVE_LANGEXTRA=yes # Multi-language support HAVE_OSMESA=no # Off-screen Mesa rendering HAVE_VIDEOPROCESSOR=auto # Enable video processor core HAVE_VIDEOCORE=auto # Broadcom Videocore 4 support +HAVE_DRMINGW=no # DrMingw exception handler diff --git a/retroarch.c b/retroarch.c index 3e0dc5cb1a..5e92fec952 100644 --- a/retroarch.c +++ b/retroarch.c @@ -23,6 +23,9 @@ #define WIN32_LEAN_AND_MEAN #include #endif +#if defined(DEBUG) && defined(HAVE_DRMINGW) +#include "exchndl.h" +#endif #endif #include @@ -1255,7 +1258,7 @@ static void retroarch_validate_cpu_features(void) static void retroarch_main_init_media(void) { - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); const char *fullpath = path_get(RARCH_PATH_CONTENT); bool builtin_imageviewer = false; bool builtin_mediaplayer = false; @@ -1316,6 +1319,10 @@ bool retroarch_main_init(int argc, char *argv[]) bool init_failed = false; global_t *global = global_get_ptr(); +#if defined(DEBUG) && defined(HAVE_DRMINGW) + char log_file_name[128]; +#endif + retroarch_init_state(); if (setjmp(error_sjlj_context) > 0) @@ -1334,7 +1341,6 @@ bool retroarch_main_init(int argc, char *argv[]) if (verbosity_is_enabled()) { char str[128]; - str[0] = '\0'; RARCH_LOG_OUTPUT("=== Build =======================================\n"); @@ -1348,6 +1354,14 @@ bool retroarch_main_init(int argc, char *argv[]) RARCH_LOG_OUTPUT("=================================================\n"); } +#if defined(DEBUG) && defined(HAVE_DRMINGW) + RARCH_LOG("Initializing Dr.MingW Exception handler\n"); + fill_str_dated_filename(log_file_name, "crash", + "log", sizeof(log_file_name)); + ExcHndlInit(); + ExcHndlSetLogFileNameA(log_file_name); +#endif + retroarch_validate_cpu_features(); rarch_ctl(RARCH_CTL_TASK_INIT, NULL);