LibDebug: Fix DebugSession teardown

Previously, we were trying to remove the breakpoints we set on the
debugee even if it has already exited, which caused PT_POKE to fail.
This commit is contained in:
Itamar 2020-08-15 14:23:03 +03:00 committed by Andreas Kling
parent 627f258c97
commit dca6a77669
Notes: sideshowbarker 2024-07-19 03:36:49 +09:00

View file

@ -45,15 +45,16 @@ NonnullOwnPtr<const MappedFile> DebugSession::initialize_executable_mapped_file(
DebugSession::~DebugSession()
{
if (m_is_debugee_dead)
return;
for (const auto& bp : m_breakpoints) {
disable_breakpoint(bp.key);
}
m_breakpoints.clear();
if (!m_is_debugee_dead) {
if (ptrace(PT_DETACH, m_debugee_pid, 0, 0) < 0) {
perror("PT_DETACH");
}
if (ptrace(PT_DETACH, m_debugee_pid, 0, 0) < 0) {
perror("PT_DETACH");
}
}