From 208ed712f42cfd277405a22663197dc1c5e84cfe Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 6 Jun 2022 12:56:01 -0400 Subject: core/debugger: memory breakpoint support --- src/core/debugger/debugger.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/core/debugger/debugger.cpp') diff --git a/src/core/debugger/debugger.cpp b/src/core/debugger/debugger.cpp index ab3940922..ac64d2f9d 100644 --- a/src/core/debugger/debugger.cpp +++ b/src/core/debugger/debugger.cpp @@ -44,12 +44,14 @@ static std::span ReceiveInto(Readable& r, Buffer& buffer) { enum class SignalType { Stopped, + Watchpoint, ShuttingDown, }; struct SignalInfo { SignalType type; Kernel::KThread* thread; + const Kernel::DebugWatchpoint* watchpoint; }; namespace Core { @@ -157,13 +159,19 @@ private: void PipeData(std::span data) { switch (info.type) { case SignalType::Stopped: + case SignalType::Watchpoint: // Stop emulation. PauseEmulation(); // Notify the client. active_thread = info.thread; UpdateActiveThread(); - frontend->Stopped(active_thread); + + if (info.type == SignalType::Watchpoint) { + frontend->Watchpoint(active_thread, *info.watchpoint); + } else { + frontend->Stopped(active_thread); + } break; case SignalType::ShuttingDown: @@ -290,12 +298,17 @@ Debugger::Debugger(Core::System& system, u16 port) { Debugger::~Debugger() = default; bool Debugger::NotifyThreadStopped(Kernel::KThread* thread) { - return impl && impl->SignalDebugger(SignalInfo{SignalType::Stopped, thread}); + return impl && impl->SignalDebugger(SignalInfo{SignalType::Stopped, thread, nullptr}); +} + +bool Debugger::NotifyThreadWatchpoint(Kernel::KThread* thread, + const Kernel::DebugWatchpoint& watch) { + return impl && impl->SignalDebugger(SignalInfo{SignalType::Watchpoint, thread, &watch}); } void Debugger::NotifyShutdown() { if (impl) { - impl->SignalDebugger(SignalInfo{SignalType::ShuttingDown, nullptr}); + impl->SignalDebugger(SignalInfo{SignalType::ShuttingDown, nullptr, nullptr}); } } -- cgit v1.2.3