Added DumpDebugInfo. Now excpet for a stack trace, the mac os x crash dump/info file looks almost exactly like the windows version.

This commit is contained in:
Steve Checkoway
2003-07-16 11:33:34 +00:00
parent e59b6788be
commit a788a10e60
2 changed files with 191 additions and 15 deletions
+190 -15
View File
@@ -14,19 +14,35 @@
#include "archutils/Unix/SignalHandler.h"
#include <Carbon/Carbon.h>
/* You would think that these would be defined somewhere. */
enum {
kMacOSX_10_2 = 0x1020,
kMacOSX_10_3 = 0x1030
};
void HandleSignal(int sig);
OSStatus HandleException(ExceptionInformation *theException);
void PrintSystemInformation(FILE *fp);
const unsigned maxLogMessages = 10; /* Follow the windows example */
static queue<CString> crashLog;
static vector<CString> staticLog;
static CString additionalLog;
static volatile unsigned handlingException;
ArchHooks_darwin::ArchHooks_darwin() {
long response;
CString error = "";
OSErr err = Gestalt(gestaltSystemVersion, &response);
if (err != noErr)
error = "Gestalt call failed.";
else if (response < kMacOSX_10_2)
error = "StepMania is not supported on any version of Mac OS X "
"other than OS X 10.2.x. This is not a bug.";
if (error != "") {
MessageBoxOK(error, "");
exit(0);
}
SignalHandler::OnClose(HandleSignal);
InstallExceptionHandler(HandleException);
}
@@ -45,6 +61,173 @@ void ArchHooks_darwin::AdditionalLog(CString str) {
additionalLog = str;
}
#define CASE_GESTALT_M(str,code,result) case gestalt##code: str = result; break
#define CASE_GESTALT(str,code) CASE_GESTALT_M(str, code, #code)
void ArchHooks_darwin::DumpDebugInfo() {
CString date = __DATE__;
CString systemVersion;
long ram;
long vRam;
long processorSpeed;
CString processor;
long numProcessors;
CString machine;
CString primaryDisplayDriver = "unknown";
CString dProvider = "";
CString dDescription = "";
CString dVersion = "";
CString dDate = "";
CString dDeviceID = "";
char *temp;
OSErr err = noErr;
long code;
/* Get system version */
err = Gestalt(gestaltSystemVersion, &code);
if (err == noErr) {
systemVersion = "Mac OS X ";
if (code >= kMacOSX_10_2 && code < kMacOSX_10_3) {
systemVersion += "10.2.";
asprintf(&temp, "%d", code - kMacOSX_10_2);
systemVersion += temp;
free(temp);
} else {
systemVersion += "10.3";
int ssv = code - kMacOSX_10_3;
if (ssv > 9)
systemVersion += "+";
else {
asprintf(&temp, ".%d", ssv);
systemVersion += temp;
free(temp);
}
}
} else
systemVersion = "Unknown system version";
/* Get memory */
err = Gestalt(gestaltLogicalRAMSize, &vRam);
if (err != noErr)
vRam = 0;
err = Gestalt(gestaltPhysicalRAMSize, &ram);
if (err == noErr) {
vRam -= ram;
if (vRam < 0)
vRam = 0;
ram /= 1048576; /* 1048576 = 1024*1024 */
vRam /= 1048576;
} else {
ram = 0;
vRam = 0;
}
/* Get processor */
numProcessors = MPProcessorsScheduled();
err = Gestalt(gestaltNativeCPUtype, &code);
if (err == noErr) {
switch (code) {
CASE_GESTALT_M(processor, CPU601, "601");
CASE_GESTALT_M(processor, CPU603, "603");
CASE_GESTALT_M(processor, CPU603e, "603e");
CASE_GESTALT_M(processor, CPU603ev, "603ev");
CASE_GESTALT_M(processor, CPU604, "604");
CASE_GESTALT_M(processor, CPU604e, "604e");
CASE_GESTALT_M(processor, CPU604ev, "604ev");
CASE_GESTALT_M(processor, CPU750, "G3");
CASE_GESTALT_M(processor, CPUG4, "G4");
CASE_GESTALT_M(processor, CPUG47450, "G4");
CASE_GESTALT_M(processor, CPUApollo, "G4 (Apollo)");
CASE_GESTALT_M(processor, CPU750FX, "G3 (Sahara)");
default:
asprintf(&temp, "%d", code);
processor = temp;
free(temp);
}
} else
processor = "unknown";
err = Gestalt(gestaltProcClkSpeed, &processorSpeed);
if (err != noErr)
processorSpeed = 0;
/* Get machine */
err = Gestalt(gestaltMachineType, &code);
if (err == noErr) {
switch (code) {
/* PowerMacs */
CASE_GESTALT(machine, PowerMac4400);
CASE_GESTALT(machine, PowerMac4400_160);
CASE_GESTALT(machine, PowerMac5200);
CASE_GESTALT(machine, PowerMac5400);
CASE_GESTALT(machine, PowerMac5500);
CASE_GESTALT(machine, PowerMac6100_60);
CASE_GESTALT(machine, PowerMac6100_66);
CASE_GESTALT(machine, PowerMac6200);
CASE_GESTALT(machine, PowerMac6400);
CASE_GESTALT(machine, PowerMac6500);
CASE_GESTALT(machine, PowerMac7100_66);
CASE_GESTALT(machine, PowerMac7100_80);
CASE_GESTALT(machine, PowerMac7200);
CASE_GESTALT(machine, PowerMac7300);
CASE_GESTALT(machine, PowerMac7500);
CASE_GESTALT(machine, PowerMac8100_80);
CASE_GESTALT(machine, PowerMac8100_100);
CASE_GESTALT(machine, PowerMac8100_110);
CASE_GESTALT(machine, PowerMac8500);
CASE_GESTALT(machine, PowerMac9500);
/* upgrade cards */
CASE_GESTALT(machine, PowerMacLC475);
CASE_GESTALT(machine, PowerMacLC575);
CASE_GESTALT(machine, PowerMacQuadra610);
CASE_GESTALT(machine, PowerMacQuadra630);
CASE_GESTALT(machine, PowerMacQuadra650);
CASE_GESTALT(machine, PowerMacQuadra700);
CASE_GESTALT(machine, PowerMacQuadra800);
CASE_GESTALT(machine, PowerMacQuadra900);
CASE_GESTALT(machine, PowerMacQuadra950);
CASE_GESTALT(machine, PowerMacCentris610);
CASE_GESTALT(machine, PowerMacCentris650);
/* PowerBooks */
CASE_GESTALT(machine, PowerBook1400);
CASE_GESTALT(machine, PowerBook2400);
CASE_GESTALT(machine, PowerBook3400);
CASE_GESTALT(machine, PowerBook500PPCUpgrade);
CASE_GESTALT(machine, PowerBookG3);
CASE_GESTALT(machine, PowerBookG3Series);
CASE_GESTALT(machine, PowerBookG3Series2);
/* NewWorld */
CASE_GESTALT(machine, PowerMacNewWorld);
CASE_GESTALT(machine, PowerMacG3);
default:
asprintf(&temp, "%d", code);
machine = temp;
free(temp);
}
} else if (err == gestaltUndefSelectorErr ) {
machine = "PowerMac";
machine += processor;
} else
machine = "unknown machine";
/* Get primary display driver */
/* TODO */
/* Send all of the information to the log */
LOG->Info("Complied %s", date.c_str());
LOG->Info(machine.c_str());
LOG->Info("Processor: %s (%d)", processor.c_str(), numProcessors);
LOG->Info("%s", systemVersion.c_str());
LOG->Info("Memory: %d MB total, %d MB swap", ram, vRam);
LOG->Info("Primary display driver: %s\n"
"Video Driver Information:\n"
"Provider :\t%s\n"
"Description :\t%s\n"
"Version :\t%s\n"
"Date :\t%s\n"
"DeviceID :\t%s\n", primaryDisplayDriver.c_str(), dProvider.c_str(),
dDescription.c_str(), dVersion.c_str(), dDate.c_str(), dDeviceID.c_str());
}
void ArchHooks_darwin::MessageBoxOK(CString sMessage, CString ID) {
bool allowHush = ID != "";
@@ -122,9 +305,8 @@ void HandleSignal(int sig) {
"StepMania crash report -- build unknown\n"
"---------------------------------------\n\n"
"Crash reason: Signal %d\n\n"
"All stack trace information in ~/Library/Logs/CrashReporter/\n\n"
"All stack trace information in ~/Library/Logs/CrashReporter/stepmania.crash.log\n\n"
"Static log:\n", sig);
PrintSystemInformation(fp); //not written yet
unsigned size = staticLog.size();
for (unsigned i=0; i<size; ++i)
fprintf(fp, "%s\n", staticLog[i].c_str());
@@ -141,9 +323,7 @@ void HandleSignal(int sig) {
#define CASE_CODE(code,addr) case k##code: strcpy((addr),#code); break
OSStatus HandleException(ExceptionInformation *theException) {
if (handlingException)
return noErr; /* Ignore it. */
handlingException = true;
InstallExceptionHandler(NULL); /* Remove this handler */
FILE *fp = fopen("crashinfo.txt", "w");
char code[31];
@@ -169,9 +349,8 @@ OSStatus HandleException(ExceptionInformation *theException) {
"StepMania crash report -- build unknown\n"
"---------------------------------------\n\n"
"Crash reason: %s\n\n"
"All stack trace information in ~/Library/Logs/CrashReporter/\n\n"
"All stack trace information in ~/Library/Logs/CrashReporter/stepmania.crash.log\n\n"
"Static log:\n", code);
PrintSystemInformation(fp); //not written yet
unsigned size = staticLog.size();
for (unsigned i=0; i<size; ++i)
fprintf(fp, "%s\n", staticLog[i].c_str());
@@ -185,8 +364,4 @@ OSStatus HandleException(ExceptionInformation *theException) {
fclose(fp);
_exit(-1);
return -1;
}
void PrintSystemInformation(FILE *fp) {
}
}
@@ -17,6 +17,7 @@ public:
ArchHooks_darwin();
void Log(CString str, bool important);
void AdditionalLog(CString str);
void DumpDebugInfo();
void MessageBoxOK(CString sMessage, CString ID = "");
MessageBoxResult MessageBoxAbortRetryIgnore(CString sMessage, CString ID = "");
};