summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2014-03-28 20:00:07 +0000
committerJim Ingham <jingham@apple.com>2014-03-28 20:00:07 +0000
commit6c8824d216c808f211be8ef4014ee0d750cfe795 (patch)
tree0ddaebc6a0e1c4e654c51050f45d796e5d109a50 /lldb
parent950667a331d2a9aab35a9657e1eca2160ef77853 (diff)
downloadbcm5719-llvm-6c8824d216c808f211be8ef4014ee0d750cfe795.tar.gz
bcm5719-llvm-6c8824d216c808f211be8ef4014ee0d750cfe795.zip
Wait for the reply from the 'D' detach packet before tearing down the debugger. Avoids a race
condition where we could end up killing debugserver (and thus the target) before it had a chance to detach. Also fix debugserver to send the OK AFTER it detaches to avoid the same race condition. <rdar://problem/16202713> llvm-svn: 205043
Diffstat (limited to 'lldb')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp6
-rw-r--r--lldb/tools/debugserver/source/RNBRemote.cpp12
2 files changed, 14 insertions, 4 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 9b9de22808c..e27186ff86c 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1756,14 +1756,16 @@ GDBRemoteCommunicationClient::Detach (bool keep_stopped)
}
else
{
- PacketResult packet_result = SendPacket ("D1", 2);
+ StringExtractorGDBRemote response;
+ PacketResult packet_result = SendPacketAndWaitForResponse ("D1", 1, response, false);
if (packet_result != PacketResult::Success)
error.SetErrorString ("Sending extended disconnect packet failed.");
}
}
else
{
- PacketResult packet_result = SendPacket ("D", 1);
+ StringExtractorGDBRemote response;
+ PacketResult packet_result = SendPacketAndWaitForResponse ("D", 1, response, false);
if (packet_result != PacketResult::Success)
error.SetErrorString ("Sending disconnect packet failed.");
}
diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp
index 2d8b36688e4..a74fdf1e189 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -3605,9 +3605,17 @@ RNBRemote::HandlePacket_C (const char *p)
rnb_err_t
RNBRemote::HandlePacket_D (const char *p)
{
- SendPacket ("OK");
if (m_ctx.HasValidProcessID())
- DNBProcessDetach(m_ctx.ProcessID());
+ {
+ if (DNBProcessDetach(m_ctx.ProcessID()))
+ SendPacket ("OK");
+ else
+ SendPacket ("E");
+ }
+ else
+ {
+ SendPacket ("E");
+ }
return rnb_success;
}
OpenPOWER on IntegriCloud