diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/core/arm/arm_interface.cpp | 26 | ||||
-rw-r--r-- | src/core/arm/arm_interface.h | 8 | ||||
-rw-r--r-- | src/core/arm/unicorn/arm_unicorn.cpp | 1 | ||||
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 3 | ||||
-rw-r--r-- | src/core/hle/service/fatal/fatal.cpp | 3 |
6 files changed, 41 insertions, 1 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f38271336..8f2db5bea 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,5 +1,6 @@ add_library(core STATIC arm/arm_interface.h + arm/arm_interface.cpp arm/exclusive_monitor.cpp arm/exclusive_monitor.h arm/unicorn/arm_unicorn.cpp diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp new file mode 100644 index 000000000..bcc812da4 --- /dev/null +++ b/src/core/arm/arm_interface.cpp @@ -0,0 +1,26 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "arm_interface.h" +#include "common/common_types.h" +#include "common/logging/log.h" +#include "core/memory.h" + +namespace Core { +void ARM_Interface::LogBacktrace() { + VAddr fp = GetReg(29); + VAddr lr = GetReg(30); + VAddr sp = GetReg(13); + VAddr pc = GetPC(); + LOG_ERROR(Core_ARM, "Backtrace, sp={:016X}, pc={:016X}", sp, pc); + for (;;) { + LOG_ERROR(Core_ARM, "{:016X}", lr); + if (!fp) { + break; + } + lr = Memory::Read64(fp + 8) - 4; + fp = Memory::Read64(fp); + } +} +}; // namespace Core diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index 59da33f30..91d2b0f81 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h @@ -141,6 +141,14 @@ public: /// Prepare core for thread reschedule (if needed to correctly handle state) virtual void PrepareReschedule() = 0; + + /// fp (= r29) points to the last frame record. + /// Note that this is the frame record for the *previous* frame, not the current one. + /// Note we need to subtract 4 from our last read to get the proper address + /// Frame records are two words long: + /// fp+0 : pointer to previous frame record + /// fp+8 : value of lr for frame + void LogBacktrace(); }; } // namespace Core diff --git a/src/core/arm/unicorn/arm_unicorn.cpp b/src/core/arm/unicorn/arm_unicorn.cpp index ded4dd359..c455c81fb 100644 --- a/src/core/arm/unicorn/arm_unicorn.cpp +++ b/src/core/arm/unicorn/arm_unicorn.cpp @@ -10,6 +10,7 @@ #include "core/core.h" #include "core/core_timing.h" #include "core/hle/kernel/svc.h" +#include "core/memory.h" namespace Core { diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index b955f9839..5fac831ee 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -684,6 +684,9 @@ 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); + Core::System::GetInstance() + .ArmInterface(static_cast<std::size_t>(GetCurrentThread()->GetProcessorID())) + .LogBacktrace(); ASSERT(false); Core::CurrentProcess()->PrepareForTermination(); diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp index 2f15ac2a6..770590d0b 100644 --- a/src/core/hle/service/fatal/fatal.cpp +++ b/src/core/hle/service/fatal/fatal.cpp @@ -111,7 +111,8 @@ static void GenerateErrorReport(ResultCode error_code, const FatalInfo& info) { } static void ThrowFatalError(ResultCode error_code, FatalType fatal_type, const FatalInfo& info) { - LOG_ERROR(Service_Fatal, "Threw fatal error type {}", static_cast<u32>(fatal_type)); + LOG_ERROR(Service_Fatal, "Threw fatal error type {} with error code 0x{:X}", + static_cast<u32>(fatal_type), error_code.raw); switch (fatal_type) { case FatalType::ErrorReportAndScreen: GenerateErrorReport(error_code, info); |