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()); } 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()