[Lldb-commits] [PATCH] D117103: [lldb] [Process/FreeBSD] Set current thread ID on events

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 12 04:58:00 PST 2022


mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
mgorny requested review of this revision.

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, some of the lldb-server
tests rely on that for convenience.


https://reviews.llvm.org/D117103

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


Index: lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
===================================================================
--- lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
@@ -254,6 +254,7 @@
 
     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 @@
         } else
           thread->SetStoppedByBreakpoint();
         FixupBreakpointPCAsNeeded(*thread);
+        SetCurrentThreadID(thread->GetID());
       }
       SetState(StateType::eStateStopped, true);
       return;
@@ -333,11 +335,13 @@
         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 @@
         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 @@
       break;
     }
   }
+
+  if (GetCurrentThreadID() == thread_id)
+    SetCurrentThreadID(m_threads.front()->GetID());
 }
 
 Status NativeProcessFreeBSD::Attach() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117103.399291.patch
Type: text/x-patch
Size: 1915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220112/fd3eb060/attachment-0001.bin>


More information about the lldb-commits mailing list