diff options
author | Mai M <mathew1800@gmail.com> | 2022-06-01 06:19:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-01 06:19:49 +0200 |
commit | de2f2e5140eb85311e0fd844c580d6726adf7e03 (patch) | |
tree | 10f0e96a0689b2edb823f5833ff388ac9c645229 /src/core/arm/dynarmic/arm_dynarmic_32.cpp | |
parent | Merge pull request #8401 from zhaobot/tx-update-20220601034505 (diff) | |
parent | core/debugger: Implement new GDB stub debugger (diff) | |
download | yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.gz yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.bz2 yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.lz yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.xz yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.tar.zst yuzu-de2f2e5140eb85311e0fd844c580d6726adf7e03.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_32.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 781a77f6f..894c1c527 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -17,6 +17,8 @@ #include "core/arm/dynarmic/arm_exclusive_monitor.h" #include "core/core.h" #include "core/core_timing.h" +#include "core/debugger/debugger.h" +#include "core/hle/kernel/k_process.h" #include "core/hle/kernel/svc.h" #include "core/memory.h" @@ -26,6 +28,7 @@ using namespace Common::Literals; constexpr Dynarmic::HaltReason break_loop = Dynarmic::HaltReason::UserDefined2; constexpr Dynarmic::HaltReason svc_call = Dynarmic::HaltReason::UserDefined3; +constexpr Dynarmic::HaltReason breakpoint = Dynarmic::HaltReason::UserDefined4; class DynarmicCallbacks32 : public Dynarmic::A32::UserCallbacks { public: @@ -78,11 +81,16 @@ public: } void ExceptionRaised(u32 pc, Dynarmic::A32::Exception exception) override { + if (parent.system.DebuggerEnabled()) { + parent.breakpoint_pc = pc; + parent.jit.load()->HaltExecution(breakpoint); + return; + } + parent.LogBacktrace(); LOG_CRITICAL(Core_ARM, "ExceptionRaised(exception = {}, pc = {:08X}, code = {:08X}, thumb = {})", exception, pc, MemoryReadCode(pc), parent.IsInThumbMode()); - UNIMPLEMENTED(); } void CallSVC(u32 swi) override { @@ -234,20 +242,35 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* void ARM_Dynarmic_32::Run() { while (true) { - const auto hr = jit.load()->Run(); + const auto hr = ShouldStep() ? jit.load()->Step() : jit.load()->Run(); if (Has(hr, svc_call)) { Kernel::Svc::Call(system, svc_swi); } + + // Check to see if breakpoint is triggered. + // Recheck step condition in case stop is no longer desired. + Kernel::KThread* current_thread = system.Kernel().GetCurrentEmuThread(); + if (Has(hr, breakpoint)) { + jit.load()->Regs()[15] = breakpoint_pc; + + if (system.GetDebugger().NotifyThreadStopped(current_thread)) { + current_thread->RequestSuspend(Kernel::SuspendType::Debug); + } + break; + } + if (ShouldStep()) { + // When stepping, this should be the only thread running. + ASSERT(system.GetDebugger().NotifyThreadStopped(current_thread)); + current_thread->RequestSuspend(Kernel::SuspendType::Debug); + break; + } + if (Has(hr, break_loop) || !uses_wall_clock) { break; } } } -void ARM_Dynarmic_32::Step() { - jit.load()->Step(); -} - ARM_Dynarmic_32::ARM_Dynarmic_32(System& system_, CPUInterrupts& interrupt_handlers_, bool uses_wall_clock_, ExclusiveMonitor& exclusive_monitor_, std::size_t core_index_) |