[Lldb-commits] [PATCH] D100541: [lldb] [gdb-remote client] Support detaching by PID
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 15 03:45:22 PDT 2021
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski.
mgorny requested review of this revision.
https://reviews.llvm.org/D100541
Files:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -229,7 +229,7 @@
bool DeallocateMemory(lldb::addr_t addr);
- Status Detach(bool keep_stopped);
+ Status Detach(bool keep_stopped, lldb::pid_t pid = LLDB_INVALID_PROCESS_ID);
Status GetMemoryRegionInfo(lldb::addr_t addr, MemoryRegionInfo &range_info);
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
@@ -1412,9 +1412,12 @@
return false;
}
-Status GDBRemoteCommunicationClient::Detach(bool keep_stopped) {
+Status GDBRemoteCommunicationClient::Detach(bool keep_stopped,
+ lldb::pid_t pid) {
Status error;
+ lldb_private::StreamString packet;
+ packet.PutChar('D');
if (keep_stopped) {
if (m_supports_detach_stay_stopped == eLazyBoolCalculate) {
char packet[64];
@@ -1436,19 +1439,25 @@
error.SetErrorString("Stays stopped not supported by this target.");
return error;
} else {
- StringExtractorGDBRemote response;
- PacketResult packet_result =
- SendPacketAndWaitForResponse("D1", response, false);
- if (packet_result != PacketResult::Success)
- error.SetErrorString("Sending extended disconnect packet failed.");
+ packet.PutChar('1');
}
- } else {
- StringExtractorGDBRemote response;
- PacketResult packet_result =
- SendPacketAndWaitForResponse("D", response, false);
- if (packet_result != PacketResult::Success)
- error.SetErrorString("Sending disconnect packet failed.");
}
+
+ if (pid != LLDB_INVALID_PROCESS_ID) {
+ if (!m_supports_multiprocess) {
+ error.SetErrorString(
+ "Multiprocess extension not supported by the server.");
+ return error;
+ }
+ packet.PutChar(';');
+ packet.PutHex64(pid);
+ }
+
+ StringExtractorGDBRemote response;
+ PacketResult packet_result =
+ SendPacketAndWaitForResponse(packet.GetString(), response, false);
+ if (packet_result != PacketResult::Success)
+ error.SetErrorString("Sending isconnect packet failed.");
return error;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100541.337692.patch
Type: text/x-patch
Size: 2541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210415/b96afe69/attachment.bin>
More information about the lldb-commits
mailing list