Print backtrace on svcBreak

When we get an svcBreak we get a backtrace now
This commit is contained in:
David Marcec 2018-12-03 19:12:09 +11:00
parent 7ce17b2cf6
commit 7149332712
3 changed files with 24 additions and 0 deletions

View File

@ -625,6 +625,8 @@ static void Break(u32 reason, u64 info1, u64 info2) {
"Emulated program broke execution! reason=0x{:016X}, info1=0x{:016X}, info2=0x{:016X}",
reason, info1, info2);
handle_debug_buffer(info1, info2);
GetCurrentThread()->LogBacktrace();
ASSERT(false);
Core::CurrentProcess()->PrepareForTermination();

View File

@ -388,6 +388,23 @@ bool Thread::InvokeWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thread> t
return wakeup_callback(reason, std::move(thread), std::move(object), index);
}
void Thread::LogBacktrace() {
auto& system = Core::System::GetInstance();
VAddr fp = system.ArmInterface(processor_id).GetReg(29);
VAddr lr = system.ArmInterface(processor_id).GetReg(30);
VAddr sp = system.ArmInterface(processor_id).GetReg(13);
VAddr pc = system.ArmInterface(processor_id).GetPC();
LOG_ERROR(Debug, "Backtrace, sp={:016X}, pc={:016X}", sp, pc);
for (std::size_t i = 0; i < 256; i++) {
LOG_ERROR(Debug, "{:016X}", lr - 4);
if (!fp) {
break;
}
lr = Memory::Read64(fp + 8);
fp = Memory::Read64(fp);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/**

View File

@ -240,6 +240,11 @@ public:
return status == ThreadStatus::WaitSynchAll;
}
/**
* Logs the backtrace for the current thread
*/
void LogBacktrace();
ThreadContext& GetContext() {
return context;
}