[Lldb-commits] [PATCH] D127192: [lldb] [llgs] Include process ID in stop responses

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 7 01:47:49 PDT 2022


mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.

Include the process identifier in the `T` stop responses when
multiprocess extension is enabled (i.e. prepend it to the thread
identifier).  Use the exposed identifier to simplify the fork-and-follow
tests.

The LLDB client accounts for the possible PID since the multiprocess
extension support was added in b601c6719226fb83c43dae62a581e5ee08bfb169 <https://reviews.llvm.org/rGb601c6719226fb83c43dae62a581e5ee08bfb169>.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D127192

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py


Index: lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
===================================================================
--- lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
@@ -102,15 +102,12 @@
         self.reset_test_sequence()
 
         # continue and expect fork
-        procinfo_regex = "[$]pid:([0-9a-f]+);.*"
-        fork_regex = "[$]T.*;{}:p([0-9a-f]+)[.]([0-9a-f]+).*".format(variant)
+        fork_regex = ("[$]T[0-9a-f]{{2}}thread:p([0-9a-f]+)[.][0-9a-f]+;.*"
+                      "{}:p([0-9a-f]+)[.]([0-9a-f]+).*".format(variant))
         self.test_sequence.add_log_lines([
-            "read packet: $qProcessInfo#00",
-            {"direction": "send", "regex": procinfo_regex,
-             "capture": {1: "parent_pid"}},
             "read packet: $c#00",
             {"direction": "send", "regex": fork_regex,
-             "capture": {1: "pid", 2: "tid"}},
+             "capture": {1: "parent_pid", 2: "pid", 3: "tid"}},
         ], True)
         ret = self.expect_gdbremote_sequence()
         parent_pid, pid, tid = (int(ret[x], 16) for x
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -809,8 +809,11 @@
   // Print the signal number.
   response.PutHex8(signum & 0xff);
 
-  // Include the tid.
-  response.Printf("thread:%" PRIx64 ";", tid);
+  // Include the (pid and) tid.
+  response.PutCString("thread:");
+  if (bool(m_extensions_supported & NativeProcessProtocol::Extension::multiprocess))
+    response.Format("p{0:x-}.", m_current_process->GetID());
+  response.Format("{0:x-};", tid);
 
   // Include the thread name if there is one.
   const std::string thread_name = thread->GetName();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127192.434734.patch
Type: text/x-patch
Size: 1965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220607/3b55d054/attachment.bin>


More information about the lldb-commits mailing list