diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 0b2cc4f0f3328..9a67015199473 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2486,9 +2486,18 @@ Status ProcessGDBRemote::DoDestroy() { StopAsyncThread(); KillDebugserverProcess(); + RemoveNewThreadBreakpoints(); return Status(); } +void ProcessGDBRemote::RemoveNewThreadBreakpoints() { + if (m_thread_create_bp_sp) { + if (TargetSP target_sp = m_target_wp.lock()) + target_sp->RemoveBreakpointByID(m_thread_create_bp_sp->GetID()); + m_thread_create_bp_sp.reset(); + } +} + void ProcessGDBRemote::SetLastStopPacket( const StringExtractorGDBRemote &response) { const bool did_exec = @@ -3315,9 +3324,6 @@ Status ProcessGDBRemote::DisableWatchpoint(WatchpointSP wp_sp, bool notify) { void ProcessGDBRemote::Clear() { m_thread_list_real.Clear(); m_thread_list.Clear(); - if (m_thread_create_bp_sp) - if (TargetSP target_sp = m_target_wp.lock()) - target_sp->RemoveBreakpointByID(m_thread_create_bp_sp->GetID()); } Status ProcessGDBRemote::DoSignal(int signo) { diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index b44ffefcd0d36..881a6b1376b19 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -434,6 +434,9 @@ class ProcessGDBRemote : public Process, lldb::user_id_t break_id, lldb::user_id_t break_loc_id); + /// Remove the breakpoints associated with thread creation from the Target. + void RemoveNewThreadBreakpoints(); + // ContinueDelegate interface void HandleAsyncStdout(llvm::StringRef out) override; void HandleAsyncMisc(llvm::StringRef data) override;