From dca6a7766912133ec70b26516187ea92b1f8eaeb Mon Sep 17 00:00:00 2001 From: Itamar Date: Sat, 15 Aug 2020 14:23:03 +0300 Subject: [PATCH] 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. --- Libraries/LibDebug/DebugSession.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Libraries/LibDebug/DebugSession.cpp b/Libraries/LibDebug/DebugSession.cpp index 25d9cf1ff2..242108761a 100644 --- a/Libraries/LibDebug/DebugSession.cpp +++ b/Libraries/LibDebug/DebugSession.cpp @@ -45,15 +45,16 @@ NonnullOwnPtr 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"); } }