diff options
| author | 2022-05-31 14:37:37 -0400 | |
|---|---|---|
| committer | 2022-06-01 02:15:15 -0400 | |
| commit | 989d4a7a41f449af0ea09e34bee331a3a3ac8170 (patch) | |
| tree | df24bd9d7e6942b939e3ea42d08c0d65006e539f /src/core/arm/arm_interface.cpp | |
| parent | core/debugger: Implement new GDB stub debugger (diff) | |
| download | yuzu-989d4a7a41f449af0ea09e34bee331a3a3ac8170.tar.gz yuzu-989d4a7a41f449af0ea09e34bee331a3a3ac8170.tar.xz yuzu-989d4a7a41f449af0ea09e34bee331a3a3ac8170.zip | |
core/debugger: Improved stepping mechanism and misc fixes
Diffstat (limited to 'src/core/arm/arm_interface.cpp')
| -rw-r--r-- | src/core/arm/arm_interface.cpp | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp index 1310f72bf..9b5a5ca57 100644 --- a/src/core/arm/arm_interface.cpp +++ b/src/core/arm/arm_interface.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "core/core.h" | 11 | #include "core/core.h" |
| 12 | #include "core/debugger/debugger.h" | 12 | #include "core/debugger/debugger.h" |
| 13 | #include "core/hle/kernel/k_process.h" | 13 | #include "core/hle/kernel/k_process.h" |
| 14 | #include "core/hle/kernel/svc.h" | ||
| 14 | #include "core/loader/loader.h" | 15 | #include "core/loader/loader.h" |
| 15 | #include "core/memory.h" | 16 | #include "core/memory.h" |
| 16 | 17 | ||
| @@ -89,8 +90,48 @@ void ARM_Interface::LogBacktrace() const { | |||
| 89 | } | 90 | } |
| 90 | } | 91 | } |
| 91 | 92 | ||
| 92 | bool ARM_Interface::ShouldStep() const { | 93 | void ARM_Interface::Run() { |
| 93 | return system.DebuggerEnabled() && system.GetDebugger().IsStepping(); | 94 | using Kernel::StepState; |
| 95 | using Kernel::SuspendType; | ||
| 96 | |||
| 97 | while (true) { | ||
| 98 | Kernel::KThread* current_thread{system.Kernel().CurrentScheduler()->GetCurrentThread()}; | ||
| 99 | Dynarmic::HaltReason hr{}; | ||
| 100 | |||
| 101 | // Notify the debugger and go to sleep if a step was performed | ||
| 102 | // and this thread has been scheduled again. | ||
| 103 | if (current_thread->GetStepState() == StepState::StepPerformed) { | ||
| 104 | system.GetDebugger().NotifyThreadStopped(current_thread); | ||
| 105 | current_thread->RequestSuspend(SuspendType::Debug); | ||
| 106 | break; | ||
| 107 | } | ||
| 108 | |||
| 109 | // Otherwise, run the thread. | ||
| 110 | if (current_thread->GetStepState() == StepState::StepPending) { | ||
| 111 | hr = StepJit(); | ||
| 112 | |||
| 113 | if (Has(hr, step_thread)) { | ||
| 114 | current_thread->SetStepState(StepState::StepPerformed); | ||
| 115 | } | ||
| 116 | } else { | ||
| 117 | hr = RunJit(); | ||
| 118 | } | ||
| 119 | |||
| 120 | // Notify the debugger and go to sleep if a breakpoint was hit. | ||
| 121 | if (Has(hr, breakpoint)) { | ||
| 122 | system.GetDebugger().NotifyThreadStopped(current_thread); | ||
| 123 | current_thread->RequestSuspend(Kernel::SuspendType::Debug); | ||
| 124 | break; | ||
| 125 | } | ||
| 126 | |||
| 127 | // Handle syscalls and scheduling (this may change the current thread) | ||
| 128 | if (Has(hr, svc_call)) { | ||
| 129 | Kernel::Svc::Call(system, GetSvcNumber()); | ||
| 130 | } | ||
| 131 | if (Has(hr, break_loop) || !uses_wall_clock) { | ||
| 132 | break; | ||
| 133 | } | ||
| 134 | } | ||
| 94 | } | 135 | } |
| 95 | 136 | ||
| 96 | } // namespace Core | 137 | } // namespace Core |