diff options
author | Liam <byteslice@airmail.cc> | 2022-05-31 20:37:37 +0200 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2022-06-01 08:15:15 +0200 |
commit | 989d4a7a41f449af0ea09e34bee331a3a3ac8170 (patch) | |
tree | df24bd9d7e6942b939e3ea42d08c0d65006e539f /src/core/arm/dynarmic | |
parent | core/debugger: Implement new GDB stub debugger (diff) | |
download | yuzu-989d4a7a41f449af0ea09e34bee331a3a3ac8170.tar yuzu-989d4a7a41f449af0ea09e34bee331a3a3ac8170.tar.gz yuzu-989d4a7a41f449af0ea09e34bee331a3a3ac8170.tar.bz2 yuzu-989d4a7a41f449af0ea09e34bee331a3a3ac8170.tar.lz yuzu-989d4a7a41f449af0ea09e34bee331a3a3ac8170.tar.xz yuzu-989d4a7a41f449af0ea09e34bee331a3a3ac8170.tar.zst yuzu-989d4a7a41f449af0ea09e34bee331a3a3ac8170.zip |
Diffstat (limited to 'src/core/arm/dynarmic')
-rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_32.cpp | 45 | ||||
-rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_32.h | 9 | ||||
-rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_64.cpp | 45 | ||||
-rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_64.h | 9 |
4 files changed, 32 insertions, 76 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 894c1c527..7c82d0b96 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -26,10 +26,6 @@ namespace Core { 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: explicit DynarmicCallbacks32(ARM_Dynarmic_32& parent_) @@ -82,8 +78,8 @@ public: void ExceptionRaised(u32 pc, Dynarmic::A32::Exception exception) override { if (parent.system.DebuggerEnabled()) { - parent.breakpoint_pc = pc; - parent.jit.load()->HaltExecution(breakpoint); + parent.jit.load()->Regs()[15] = pc; + parent.jit.load()->HaltExecution(ARM_Interface::breakpoint); return; } @@ -95,7 +91,7 @@ public: void CallSVC(u32 swi) override { parent.svc_swi = swi; - parent.jit.load()->HaltExecution(svc_call); + parent.jit.load()->HaltExecution(ARM_Interface::svc_call); } void AddTicks(u64 ticks) override { @@ -240,35 +236,16 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* return std::make_unique<Dynarmic::A32::Jit>(config); } -void ARM_Dynarmic_32::Run() { - while (true) { - 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; +Dynarmic::HaltReason ARM_Dynarmic_32::RunJit() { + return jit.load()->Run(); +} - 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; - } +Dynarmic::HaltReason ARM_Dynarmic_32::StepJit() { + return jit.load()->Step(); +} - if (Has(hr, break_loop) || !uses_wall_clock) { - break; - } - } +u32 ARM_Dynarmic_32::GetSvcNumber() const { + return svc_swi; } ARM_Dynarmic_32::ARM_Dynarmic_32(System& system_, CPUInterrupts& interrupt_handlers_, diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.h b/src/core/arm/dynarmic/arm_dynarmic_32.h index 0557d5940..5b1d60005 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.h +++ b/src/core/arm/dynarmic/arm_dynarmic_32.h @@ -41,7 +41,6 @@ public: void SetVectorReg(int index, u128 value) override; u32 GetPSTATE() const override; void SetPSTATE(u32 pstate) override; - void Run() override; VAddr GetTlsAddress() const override; void SetTlsAddress(VAddr address) override; void SetTPIDR_EL0(u64 value) override; @@ -69,6 +68,11 @@ public: std::vector<BacktraceEntry> GetBacktrace() const override; +protected: + Dynarmic::HaltReason RunJit() override; + Dynarmic::HaltReason StepJit() override; + u32 GetSvcNumber() const override; + private: std::shared_ptr<Dynarmic::A32::Jit> MakeJit(Common::PageTable* page_table) const; @@ -94,9 +98,6 @@ private: // SVC callback u32 svc_swi{}; - - // Debug restart address - u32 breakpoint_pc{}; }; } // namespace Core diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 1f596cfef..d4c67eafd 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -26,10 +26,6 @@ namespace Core { using Vector = Dynarmic::A64::Vector; 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 DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks { public: explicit DynarmicCallbacks64(ARM_Dynarmic_64& parent_) @@ -123,8 +119,8 @@ public: return; default: if (parent.system.DebuggerEnabled()) { - parent.breakpoint_pc = pc; - parent.jit.load()->HaltExecution(breakpoint); + parent.jit.load()->SetPC(pc); + parent.jit.load()->HaltExecution(ARM_Interface::breakpoint); return; } @@ -136,7 +132,7 @@ public: void CallSVC(u32 swi) override { parent.svc_swi = swi; - parent.jit.load()->HaltExecution(svc_call); + parent.jit.load()->HaltExecution(ARM_Interface::svc_call); } void AddTicks(u64 ticks) override { @@ -300,35 +296,16 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable* return std::make_shared<Dynarmic::A64::Jit>(config); } -void ARM_Dynarmic_64::Run() { - while (true) { - const auto hr = 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()->SetPC(breakpoint_pc); +Dynarmic::HaltReason ARM_Dynarmic_64::RunJit() { + return jit.load()->Run(); +} - 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; - } +Dynarmic::HaltReason ARM_Dynarmic_64::StepJit() { + return jit.load()->Step(); +} - if (Has(hr, break_loop) || !uses_wall_clock) { - break; - } - } +u32 ARM_Dynarmic_64::GetSvcNumber() const { + return svc_swi; } ARM_Dynarmic_64::ARM_Dynarmic_64(System& system_, CPUInterrupts& interrupt_handlers_, diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.h b/src/core/arm/dynarmic/arm_dynarmic_64.h index aa7054e0c..abfbc3c3f 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.h +++ b/src/core/arm/dynarmic/arm_dynarmic_64.h @@ -39,7 +39,6 @@ public: void SetVectorReg(int index, u128 value) override; u32 GetPSTATE() const override; void SetPSTATE(u32 pstate) override; - void Run() override; VAddr GetTlsAddress() const override; void SetTlsAddress(VAddr address) override; void SetTPIDR_EL0(u64 value) override; @@ -63,6 +62,11 @@ public: std::vector<BacktraceEntry> GetBacktrace() const override; +protected: + Dynarmic::HaltReason RunJit() override; + Dynarmic::HaltReason StepJit() override; + u32 GetSvcNumber() const override; + private: std::shared_ptr<Dynarmic::A64::Jit> MakeJit(Common::PageTable* page_table, std::size_t address_space_bits) const; @@ -87,9 +91,6 @@ private: // SVC callback u32 svc_swi{}; - - // Debug restart address - u64 breakpoint_pc{}; }; } // namespace Core |