From 8ce641cefca3c0e3409b90a0884cc7a9cffea44c Mon Sep 17 00:00:00 2001 From: Itamar Date: Sat, 26 Sep 2020 11:22:58 +0300 Subject: [PATCH] LibDebug: Add ability to detach from debuggee --- Libraries/LibDebug/DebugSession.cpp | 8 ++++++++ Libraries/LibDebug/DebugSession.h | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Libraries/LibDebug/DebugSession.cpp b/Libraries/LibDebug/DebugSession.cpp index 2640817185..e17066b62b 100644 --- a/Libraries/LibDebug/DebugSession.cpp +++ b/Libraries/LibDebug/DebugSession.cpp @@ -266,4 +266,12 @@ void* DebugSession::single_step() return (void*)regs.eip; } +void DebugSession::detach() +{ + for (auto& breakpoint : m_breakpoints.keys()) { + remove_breakpoint(breakpoint); + } + continue_debugee(); +} + } diff --git a/Libraries/LibDebug/DebugSession.h b/Libraries/LibDebug/DebugSession.h index d3e212ff28..25072c9cda 100644 --- a/Libraries/LibDebug/DebugSession.h +++ b/Libraries/LibDebug/DebugSession.h @@ -90,11 +90,14 @@ public: }; void continue_debugee(ContinueType type = ContinueType::FreeRun); - //returns the wstatus result of waitpid() + // Returns the wstatus result of waitpid() int continue_debugee_and_wait(ContinueType type = ContinueType::FreeRun); + // Returns the new eip void* single_step(); + void detach(); + template void run(Callback callback); @@ -236,7 +239,11 @@ void DebugSession::run(Callback callback) state = State::SingleStep; } - if (decision == DebugDecision::Kill || decision == DebugDecision::Detach) { + if (decision == DebugDecision::Detach) { + detach(); + break; + } + if (decision == DebugDecision::Kill) { ASSERT_NOT_REACHED(); // TODO: implement }