summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
diff options
context:
space:
mode:
authorTodd Fiala <todd.fiala@gmail.com>2014-07-29 22:30:01 +0000
committerTodd Fiala <todd.fiala@gmail.com>2014-07-29 22:30:01 +0000
commit7306cf3cb7fd69583510529609b975939393254f (patch)
tree7d65b828bb9e7a1a82c4085eb09cf58917bee26b /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
parentcf36a366a81bdca3083cdcdf2f405a9071598230 (diff)
downloadbcm5719-llvm-7306cf3cb7fd69583510529609b975939393254f.tar.gz
bcm5719-llvm-7306cf3cb7fd69583510529609b975939393254f.zip
Add $vAttach support to llgs.
Also adds a new test case for vAttach;{pid} for llgs and debugserver. llvm-svn: 214236
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
index 44475981bdd..585b28ecc30 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
@@ -422,6 +422,10 @@ GDBRemoteCommunicationServer::GetPacketAndSendResponse (uint32_t timeout_usec,
case StringExtractorGDBRemote::eServerPacketType_QRestoreRegisterState:
packet_result = Handle_QRestoreRegisterState (packet);
break;
+
+ case StringExtractorGDBRemote::eServerPacketType_vAttach:
+ packet_result = Handle_vAttach (packet);
+ break;
}
}
else
@@ -4111,6 +4115,44 @@ GDBRemoteCommunicationServer::Handle_QRestoreRegisterState (StringExtractorGDBRe
return SendOKResponse();
}
+GDBRemoteCommunicationServer::PacketResult
+GDBRemoteCommunicationServer::Handle_vAttach (StringExtractorGDBRemote &packet)
+{
+ Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+ // We don't support if we're not llgs.
+ if (!IsGdbServer())
+ return SendUnimplementedResponse ("only supported for lldb-gdbserver");
+
+ // Consume the ';' after vAttach.
+ packet.SetFilePos (strlen ("vAttach"));
+ if (!packet.GetBytesLeft () || packet.GetChar () != ';')
+ return SendIllFormedResponse (packet, "vAttach missing expected ';'");
+
+ // Grab the PID to which we will attach (assume hex encoding).
+ lldb::pid_t pid = packet.GetU32 (LLDB_INVALID_PROCESS_ID, 16);
+ if (pid == LLDB_INVALID_PROCESS_ID)
+ return SendIllFormedResponse (packet, "vAttach failed to parse the process id");
+
+ // Attempt to attach.
+ if (log)
+ log->Printf ("GDBRemoteCommunicationServer::%s attempting to attach to pid %" PRIu64, __FUNCTION__, pid);
+
+ Error error = AttachToProcess (pid);
+
+ if (error.Fail ())
+ {
+ if (log)
+ log->Printf ("GDBRemoteCommunicationServer::%s failed to attach to pid %" PRIu64 ": %s\n", __FUNCTION__, pid, error.AsCString());
+ return SendErrorResponse (0x01);
+ }
+
+ // Notify we attached by sending a stop packet.
+ return SendStopReasonForState (m_debugged_process_sp->GetState (), true);
+
+ return PacketResult::Success;
+}
+
void
GDBRemoteCommunicationServer::FlushInferiorOutput ()
{
OpenPOWER on IntegriCloud