[Lldb-commits] [PATCH] D128156: [lldb] [llgs] Include PID in QC response in multiprocess mode
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 20 00:00:59 PDT 2022
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski, jingham.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.
Sponsored by: The FreeBSD Foundation
https://reviews.llvm.org/D128156
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
@@ -817,3 +817,56 @@
data = ret.get("data")
self.assertIsNotNone(data)
self.assertEqual(data, old_val[1])
+
+ @add_test_categories(["fork"])
+ def test_qC(self):
+ self.build()
+ self.prep_debug_monitor_and_inferior(
+ inferior_args=["fork",
+ "thread:new",
+ "trap",
+ ])
+ self.add_qSupported_packets(["multiprocess+",
+ "fork-events+"])
+ ret = self.expect_gdbremote_sequence()
+ self.assertIn("fork-events+", ret["qSupported_response"])
+ self.reset_test_sequence()
+
+ # continue and expect fork
+ self.test_sequence.add_log_lines([
+ "read packet: $c#00",
+ {"direction": "send", "regex": self.fork_regex.format("fork"),
+ "capture": self.fork_capture},
+ ], True)
+ self.add_threadinfo_collection_packets()
+ ret = self.expect_gdbremote_sequence()
+ pidtids = [
+ (ret["parent_pid"], ret["parent_tid"]),
+ (ret["child_pid"], ret["child_tid"]),
+ ]
+ self.reset_test_sequence()
+
+ for pidtid in pidtids:
+ self.test_sequence.add_log_lines(
+ ["read packet: $Hcp{}.{}#00".format(*pidtid),
+ "send packet: $OK#00",
+ "read packet: $c#00",
+ {"direction": "send",
+ "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
+ },
+ ], True)
+
+ self.add_threadinfo_collection_packets()
+ ret = self.expect_gdbremote_sequence()
+ self.reset_test_sequence()
+
+ pidtids = set(self.parse_threadinfo_packets(ret))
+ self.assertEqual(len(pidtids), 4)
+ for pidtid in pidtids:
+ self.test_sequence.add_log_lines(
+ ["read packet: $Hgp{:x}.{:x}#00".format(*pidtid),
+ "send packet: $OK#00",
+ "read packet: $qC#00",
+ "send packet: $QCp{:x}.{:x}#00".format(*pidtid),
+ ], True)
+ self.expect_gdbremote_sequence()
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
@@ -1412,7 +1412,10 @@
return SendErrorResponse(69);
StreamString response;
- response.Printf("QC%" PRIx64, thread->GetID());
+ response.PutCString("QC");
+ if (bool(m_extensions_supported & NativeProcessProtocol::Extension::multiprocess))
+ response.Format("p{0:x-}.", m_current_process->GetID());
+ response.Format("{0:x-}", thread->GetID());
return SendPacketNoLock(response.GetString());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128156.438264.patch
Type: text/x-patch
Size: 3166 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220620/5d41577b/attachment.bin>
More information about the lldb-commits
mailing list