[Lldb-commits] [lldb] 9a1ce35 - [lldb] [Process/FreeBSD] Set current thread ID on events

Michał Górny via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 12 06:40:26 PST 2022


Author: Michał Górny
Date: 2022-01-12T15:40:13+01:00
New Revision: 9a1ce35d7e7fdfa6d45fb24abc3ad30e8eb6c6f4

URL: https://github.com/llvm/llvm-project/commit/9a1ce35d7e7fdfa6d45fb24abc3ad30e8eb6c6f4
DIFF: https://github.com/llvm/llvm-project/commit/9a1ce35d7e7fdfa6d45fb24abc3ad30e8eb6c6f4.diff

LOG: [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

Added: 
    

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

Removed: 
    


################################################################################
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<NativeThreadFreeBSD &>(*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<NativeThreadFreeBSD &>(*abs_thread);
     assert(info.pl_lwpid >= 0);
     if (info.pl_lwpid == 0 ||
-        static_cast<lldb::tid_t>(info.pl_lwpid) == thread.GetID())
+        static_cast<lldb::tid_t>(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() {


        


More information about the lldb-commits mailing list