Skip to content

Commit 9a1ce35

Browse files
committed
[lldb] [Process/FreeBSD] Set current thread ID on events
Set the current thread ID to the thread where an event happened. As a result, e.g. when a signal is delivered to a thread other than the first one, the respective T packet refers to the signaled thread rather than the first thread (with no stop reason). While this doesn't strictly make a difference to the LLDB client, it is the expected behavior. Differential Revision: https://reviews.llvm.org/D117103
1 parent c490f8f commit 9a1ce35

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
254254

255255
for (const auto &thread : m_threads)
256256
static_cast<NativeThreadFreeBSD &>(*thread).SetStoppedByExec();
257+
SetCurrentThreadID(m_threads.front()->GetID());
257258
SetState(StateType::eStateStopped, true);
258259
return;
259260
}
@@ -312,6 +313,7 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
312313
} else
313314
thread->SetStoppedByBreakpoint();
314315
FixupBreakpointPCAsNeeded(*thread);
316+
SetCurrentThreadID(thread->GetID());
315317
}
316318
SetState(StateType::eStateStopped, true);
317319
return;
@@ -333,11 +335,13 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
333335
if (wp_index != LLDB_INVALID_INDEX32) {
334336
regctx.ClearWatchpointHit(wp_index);
335337
thread->SetStoppedByWatchpoint(wp_index);
338+
SetCurrentThreadID(thread->GetID());
336339
SetState(StateType::eStateStopped, true);
337340
break;
338341
}
339342

340343
thread->SetStoppedByTrace();
344+
SetCurrentThreadID(thread->GetID());
341345
}
342346

343347
SetState(StateType::eStateStopped, true);
@@ -370,9 +374,10 @@ void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) {
370374
static_cast<NativeThreadFreeBSD &>(*abs_thread);
371375
assert(info.pl_lwpid >= 0);
372376
if (info.pl_lwpid == 0 ||
373-
static_cast<lldb::tid_t>(info.pl_lwpid) == thread.GetID())
377+
static_cast<lldb::tid_t>(info.pl_lwpid) == thread.GetID()) {
374378
thread.SetStoppedBySignal(info.pl_siginfo.si_signo, &info.pl_siginfo);
375-
else
379+
SetCurrentThreadID(thread.GetID());
380+
} else
376381
thread.SetStoppedWithNoReason();
377382
}
378383
SetState(StateType::eStateStopped, true);
@@ -809,6 +814,9 @@ void NativeProcessFreeBSD::RemoveThread(lldb::tid_t thread_id) {
809814
break;
810815
}
811816
}
817+
818+
if (GetCurrentThreadID() == thread_id)
819+
SetCurrentThreadID(m_threads.front()->GetID());
812820
}
813821

814822
Status NativeProcessFreeBSD::Attach() {

0 commit comments

Comments
 (0)