Skip to content

Commit 8ce641c

Browse files
itamar8910awesomekling
authored andcommitted
LibDebug: Add ability to detach from debuggee
1 parent 6c73fdf commit 8ce641c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Libraries/LibDebug/DebugSession.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,12 @@ void* DebugSession::single_step()
266266
return (void*)regs.eip;
267267
}
268268

269+
void DebugSession::detach()
270+
{
271+
for (auto& breakpoint : m_breakpoints.keys()) {
272+
remove_breakpoint(breakpoint);
273+
}
274+
continue_debugee();
275+
}
276+
269277
}

Libraries/LibDebug/DebugSession.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,14 @@ class DebugSession {
9090
};
9191
void continue_debugee(ContinueType type = ContinueType::FreeRun);
9292

93-
//returns the wstatus result of waitpid()
93+
// Returns the wstatus result of waitpid()
9494
int continue_debugee_and_wait(ContinueType type = ContinueType::FreeRun);
9595

96+
// Returns the new eip
9697
void* single_step();
9798

99+
void detach();
100+
98101
template<typename Callback>
99102
void run(Callback callback);
100103

@@ -236,7 +239,11 @@ void DebugSession::run(Callback callback)
236239
state = State::SingleStep;
237240
}
238241

239-
if (decision == DebugDecision::Kill || decision == DebugDecision::Detach) {
242+
if (decision == DebugDecision::Detach) {
243+
detach();
244+
break;
245+
}
246+
if (decision == DebugDecision::Kill) {
240247
ASSERT_NOT_REACHED(); // TODO: implement
241248
}
242249

0 commit comments

Comments
 (0)