From 5e67cfb2f65204da2a00353e60e937fb36c27c81 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Thu, 31 Jul 2003 22:32:45 +0000 Subject: [PATCH] Added Crash reporting on OS X --- stepmania/src/archutils/Darwin/Crash.cpp | 58 +++++++++++++++++++++ stepmania/src/archutils/Darwin/Crash.h | 19 +++++++ stepmania/src/archutils/Darwin/arch_setup.h | 2 + 3 files changed, 79 insertions(+) create mode 100644 stepmania/src/archutils/Darwin/Crash.cpp create mode 100644 stepmania/src/archutils/Darwin/Crash.h diff --git a/stepmania/src/archutils/Darwin/Crash.cpp b/stepmania/src/archutils/Darwin/Crash.cpp new file mode 100644 index 0000000000..8d3fc8e6eb --- /dev/null +++ b/stepmania/src/archutils/Darwin/Crash.cpp @@ -0,0 +1,58 @@ +/* + * Crash.cpp + * stepmania + * + * Created by Steve Checkoway on Thu Jul 31 2003. + * Copyright (c) 2003 Steve Checkoway. All rights reserved. + * + */ + +#include "Crash.h" +#include "archutils/Unix/CrashHandler.h" +#include + +static void *crashedFramePtr = NULL; + +OSStatus HandleException(ExceptionInformation *theException) +{ + crashedFramePtr = (void *)theException->registerImage->R1.lo; + if (!crashedFramePtr) { + write(fileno(stderr), + "***********************\n" + "It uses the high bytes!\n" + "***********************\n", 24*3); + crashedFramePtr = (void *)theException->registerImage->R1.hi; + } + CrashSignalHandler(theException->theKind); + return -1; +} + + +void *GetCrashedFramePtr() +{ + return crashedFramePtr; +} + +void InformUserOfCrash() +{ + CFStringRef error = CFStringCreateWithCString(NULL, + "StepMania has crashed. Debug information has been output to\n" + "\n" + " /tmp/crashinfo.txt\n" + "\n" + "Please report a bug at:\n" + "\n" + " http://sourceforge.net/tracker/?func=add&group_id=37892&atid=421366", + kCFStringEncodingASCII); + CFStringRef OK = CFStringCreateWithCString(NULL, "OK", kCFStringEncodingASCII); + struct AlertStdCFStringAlertParamRec params = {kStdCFStringAlertVersionOne, true, false, OK, NULL, NULL, + kAlertStdAlertOKButton, NULL, kWindowAlertPositionParentWindowScreen, NULL}; + DialogRef dialog; + SInt16 unused; + + CreateStandardAlert(kAlertStopAlert, error, NULL, ¶ms, &dialog); + AutoSizeDialog(dialog); + RunStandardAlert(dialog, NULL, &unused); + CFRelease(OK); + CFRelease(error); +} diff --git a/stepmania/src/archutils/Darwin/Crash.h b/stepmania/src/archutils/Darwin/Crash.h new file mode 100644 index 0000000000..c7aee0fc9a --- /dev/null +++ b/stepmania/src/archutils/Darwin/Crash.h @@ -0,0 +1,19 @@ +#ifndef DARWIN_CRASH_H +#define DARWIN_CRASH_H +/* + * Crash.h + * stepmania + * + * Created by Steve Checkoway on Thu Jul 31 2003. + * Copyright (c) 2003 Steve Checkoway. All rights reserved. + * + */ + +#include "global.h" +#include + +OSStatus HandleException(ExceptionInformation *theException); +void *GetCrashedFramePtr(); +void InformUserOfCrash(); + +#endif /* DARWIN_CRASH_H */ diff --git a/stepmania/src/archutils/Darwin/arch_setup.h b/stepmania/src/archutils/Darwin/arch_setup.h index 914b835bbd..82f0b1468e 100644 --- a/stepmania/src/archutils/Darwin/arch_setup.h +++ b/stepmania/src/archutils/Darwin/arch_setup.h @@ -6,3 +6,5 @@ #define NEED_COSF #define NEED_TANF #define NEED_ACOSF +#define BACKTRACE_LOOKUP_METHOD_ATOS +#define BACKTRACE_METHOD_POWERPC_DARWIN