core/debugger: Improved stepping mechanism and misc fixes
This commit is contained in:
parent
fb4b3c127f
commit
989d4a7a41
16 changed files with 252 additions and 122 deletions
|
@ -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);
|
||||
}
|
||||
Dynarmic::HaltReason ARM_Dynarmic_32::RunJit() {
|
||||
return jit.load()->Run();
|
||||
}
|
||||
|
||||
// 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::StepJit() {
|
||||
return jit.load()->Step();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
u32 ARM_Dynarmic_32::GetSvcNumber() const {
|
||||
return svc_swi;
|
||||
}
|
||||
|
||||
ARM_Dynarmic_32::ARM_Dynarmic_32(System& system_, CPUInterrupts& interrupt_handlers_,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
Dynarmic::HaltReason ARM_Dynarmic_64::RunJit() {
|
||||
return jit.load()->Run();
|
||||
}
|
||||
|
||||
// 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::StepJit() {
|
||||
return jit.load()->Step();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
u32 ARM_Dynarmic_64::GetSvcNumber() const {
|
||||
return svc_swi;
|
||||
}
|
||||
|
||||
ARM_Dynarmic_64::ARM_Dynarmic_64(System& system_, CPUInterrupts& interrupt_handlers_,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue