Added better handling for incomplete data received when debugging

This commit is contained in:
Quajak 2020-10-22 19:38:43 +02:00
parent 25639bc279
commit 2cd0d32184
3 changed files with 18 additions and 7 deletions

View file

@ -90,6 +90,11 @@ namespace Cosmos.TestRunner.Core
aDebugConnector.CmdCoreDump = dump => aDebugConnector.CmdCoreDump = dump =>
{ {
if(dump is null)
{
OutputHandler.LogMessage("Attempted to dump core but didnt get enough data;");
return;
}
OutputHandler.LogMessage("Core dump:"); OutputHandler.LogMessage("Core dump:");
string eax = "EAX = 0x" + dump.EAX.ToString("X8"); string eax = "EAX = 0x" + dump.EAX.ToString("X8");

View file

@ -26,7 +26,7 @@ namespace Cosmos.TestRunner.Core
protected override void OnUnhandledException(Exception exception) protected override void OnUnhandledException(Exception exception)
{ {
Log("Unhandled exception: " + exception.ToString()); Log("Unhandled exception: " + exception?.ToString() ?? "Unable to get exception: Exception was null!");
} }
protected override void OnExecutionEnd() protected override void OnExecutionEnd()

View file

@ -48,12 +48,18 @@ namespace Cosmos.Debug.DebugConnectors
{ {
stack.Push(BitConverter.ToUInt32(stackBytes, i)); stack.Push(BitConverter.ToUInt32(stackBytes, i));
} }
if(stack.Count != 9)
return new CoreDump( {
stack.Pop(), stack.Pop(), stack.Pop(), stack.Pop(), return null;
stack.Pop(), stack.Pop(), }
stack.Pop(), stack.Pop(), stack.Pop(), else
stack); {
return new CoreDump(
stack.Pop(), stack.Pop(), stack.Pop(), stack.Pop(),
stack.Pop(), stack.Pop(),
stack.Pop(), stack.Pop(), stack.Pop(),
stack);
}
} }
} }
} }