diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp index a62d3c1ba0522..7290d300a41f5 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp @@ -254,6 +254,7 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) { for (const auto &thread : m_threads) static_cast(*thread).SetStoppedByExec(); + SetCurrentThreadID(m_threads.front()->GetID()); SetState(StateType::eStateStopped, true); return; } @@ -312,6 +313,7 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) { } else thread->SetStoppedByBreakpoint(); FixupBreakpointPCAsNeeded(*thread); + SetCurrentThreadID(thread->GetID()); } SetState(StateType::eStateStopped, true); return; @@ -333,11 +335,13 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) { if (wp_index != LLDB_INVALID_INDEX32) { regctx.ClearWatchpointHit(wp_index); thread->SetStoppedByWatchpoint(wp_index); + SetCurrentThreadID(thread->GetID()); SetState(StateType::eStateStopped, true); break; } thread->SetStoppedByTrace(); + SetCurrentThreadID(thread->GetID()); } SetState(StateType::eStateStopped, true); @@ -370,9 +374,10 @@ void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) { static_cast(*abs_thread); assert(info.pl_lwpid >= 0); if (info.pl_lwpid == 0 || - static_cast(info.pl_lwpid) == thread.GetID()) + static_cast(info.pl_lwpid) == thread.GetID()) { thread.SetStoppedBySignal(info.pl_siginfo.si_signo, &info.pl_siginfo); - else + SetCurrentThreadID(thread.GetID()); + } else thread.SetStoppedWithNoReason(); } SetState(StateType::eStateStopped, true); @@ -809,6 +814,9 @@ void NativeProcessFreeBSD::RemoveThread(lldb::tid_t thread_id) { break; } } + + if (GetCurrentThreadID() == thread_id) + SetCurrentThreadID(m_threads.front()->GetID()); } Status NativeProcessFreeBSD::Attach() {