Fatal: save auto-debug info to SD card.

This commit is contained in:
Michael Scire 2018-11-14 14:13:31 -08:00
parent 962fa0a690
commit 8054b2d219
8 changed files with 151 additions and 6 deletions

View file

@ -146,6 +146,7 @@ void TryCollectDebugInformation(FatalThrowContext *ctx, u64 pid) {
while (R_SUCCEEDED(svcGetDebugEvent((u8 *)&d, debug_handle))) {
if (d.type == DebugEventType::AttachProcess) {
ctx->cpu_ctx.is_aarch32 = (d.info.attach_process.flags & 1) == 0;
memcpy(ctx->proc_name, d.info.attach_process.name, sizeof(d.info.attach_process.name));
got_attach_process = true;
} else if (d.type == DebugEventType::AttachThread) {
thread_id_to_tls[d.info.attach_thread.thread_id] = d.info.attach_thread.tls_address;
@ -228,6 +229,16 @@ void TryCollectDebugInformation(FatalThrowContext *ctx, u64 pid) {
cur_fp = cur_frame.fp;
}
/* Try to read up to 0x100 of stack. */
for (size_t sz = 0x100; sz > 0; sz -= 0x10) {
if (IsAddressReadable(debug_handle, ctx->cpu_ctx.aarch64_ctx.sp, sz, nullptr)) {
if (R_SUCCEEDED(svcReadDebugProcessMemory(ctx->stack_dump, debug_handle, ctx->cpu_ctx.aarch64_ctx.sp, sz))) {
ctx->stack_dump_size = sz;
}
break;
}
}
/* Parse the starting address. */
{
u64 guess = thread_ctx.pc.x;