From 22d4e106642ac9d6a0dabc700c4dcd47be08ff41 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Sat, 29 Dec 2018 12:55:19 +1100 Subject: Moved log backtrace to arm_interface.cpp. Added printing of error code to fatal --- src/core/arm/arm_interface.cpp | 26 ++++++++++++++++++++++++++ src/core/arm/arm_interface.h | 24 +++++++----------------- 2 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 src/core/arm/arm_interface.cpp (limited to 'src/core/arm') 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 b0472d55d..91d2b0f81 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h @@ -6,8 +6,6 @@ #include #include "common/common_types.h" -#include "common/logging/log.h" -#include "core/memory.h" namespace Kernel { enum class VMAPermission : u8; @@ -144,21 +142,13 @@ public: /// Prepare core for thread reschedule (if needed to correctly handle state) virtual void PrepareReschedule() = 0; - void 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); - } - } + /// 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 -- cgit v1.2.3