Call OSFatal when the debug server crashes

This commit is contained in:
Yannik Marchand 2018-09-25 09:04:20 +02:00
parent 015b3228f8
commit 90cf855667
2 changed files with 26 additions and 15 deletions

View File

@ -560,7 +560,7 @@ void Debugger::handleBreakPoint(ExceptionState *state) {
stepper.handleBreakPoint(state);
if (!connected) {
handleFatalCrash(state);
handleFatalCrash(&state->context, state->type);
}
uint32_t addr = state->context.srr0;
@ -578,7 +578,7 @@ void Debugger::handleBreakPoint(ExceptionState *state) {
resumeBreakPoint(state);
}
void Debugger::handleFatalCrash(ExceptionState *state) {
void Debugger::handleCrash(ExceptionState *state) {
stepper.adjustAddress(state);
if (connected) {
OSMessage message;
@ -593,19 +593,27 @@ void Debugger::handleFatalCrash(ExceptionState *state) {
}
}
else {
const char *type;
if (state->type == ExceptionState::DSI) type = "A DSI";
else if (state->type == ExceptionState::ISI) type = "An ISI";
else {
type = "A program";
}
DumpContext(&state->context, type);
handleFatalCrash(&state->context, state->type);
}
}
void Debugger::handleFatalCrash(OSContext *context, ExceptionState::Type type) {
const char *name;
if (type == ExceptionState::DSI) name = "A DSI";
else if (type == ExceptionState::ISI) name = "An ISI";
else {
name = "A program";
}
DumpContext(context, name);
}
void Debugger::handleException(OSContext *context, ExceptionState::Type type) {
OSThread *thread = OSGetCurrentThread();
if (thread == serverThread) {
handleFatalCrash(context, type);
}
ExceptionState *state = exceptions.findOrCreate(thread);
memcpy(&state->context, context, sizeof(OSContext));
state->type = type;
@ -616,7 +624,7 @@ void Debugger::handleException(OSContext *context, ExceptionState::Type type) {
handleBreakPoint(state);
}
else {
handleFatalCrash(state);
handleCrash(state);
}
}
@ -913,16 +921,16 @@ void Debugger::start() {
exceptions.init();
stepper.init();
OSThread *thread = new OSThread();
serverThread = new OSThread();
char *stack = new char[0x8000];
OSCreateThread(
thread, threadEntry, 0, 0,
serverThread, threadEntry, 0, 0,
stack + STACK_SIZE, STACK_SIZE,
0, 12
);
OSSetThreadName(thread, "Debug Server");
OSResumeThread(thread);
OSSetThreadName(serverThread, "Debug Server");
OSResumeThread(serverThread);
while (!initialized) {
OSSleepTicks(OSMillisecondsToTicks(20));

View File

@ -235,7 +235,8 @@ private:
void threadFunc();
void mainLoop(Client *client);
void handleException(OSContext *context, ExceptionState::Type type);
void handleFatalCrash(ExceptionState *state);
void handleFatalCrash(OSContext *context, ExceptionState::Type type);
void handleCrash(ExceptionState *state);
void handleBreakPoint(ExceptionState *state);
void processBreakPoint(ExceptionState *state);
void resumeBreakPoint(ExceptionState *state);
@ -247,6 +248,8 @@ private:
OSMessageQueue eventQueue;
OSMessage eventMessages[MESSAGE_COUNT];
OSThread *serverThread;
BreakPointMgr breakpoints;
ExceptionMgr exceptions;
StepMgr stepper;