[Lldb-commits] [PATCH] D110033: [lldb] [gdb-remote] Always send PID when detaching w/ multiprocess

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sun Sep 19 04:04:26 PDT 2021


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

Always send PID in the detach packet when multiprocess extensions are
enabled.  This is required by qemu's GDB server, as plain 'D' packet
results in an error and the emulated system is not resumed.


https://reviews.llvm.org/D110033

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1547,14 +1547,16 @@
     }
   }
 
-  if (pid != LLDB_INVALID_PROCESS_ID) {
-    if (!m_supports_multiprocess) {
-      error.SetErrorString(
-          "Multiprocess extension not supported by the server.");
-      return error;
-    }
+  if (m_supports_multiprocess) {
+    // Some servers (e.g. qemu) require specifying the PID even if only a single
+    // process is running.
+    if (pid == LLDB_INVALID_PROCESS_ID)
+      pid = GetCurrentProcessID();
     packet.PutChar(';');
     packet.PutHex64(pid);
+  } else if (pid != LLDB_INVALID_PROCESS_ID) {
+    error.SetErrorString("Multiprocess extension not supported by the server.");
+    return error;
   }
 
   StringExtractorGDBRemote response;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110033.373450.patch
Type: text/x-patch
Size: 1007 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210919/3b0f78ed/attachment.bin>


More information about the lldb-commits mailing list