Did a lot more work on abtracting and organizing the platforms.
On Mac OS X we now have 3 platforms:
PlatformDarwin - must be subclassed to fill in the missing pure virtual funcs
but this implements all the common functionality between
remote-macosx and remote-ios. It also allows for another
platform to be used (remote-gdb-server for now) when doing
remote connections. Keeping this pluggable will allow for
flexibility.
PlatformMacOSX - Now implements both local and remote macosx desktop platforms.
PlatformRemoteiOS - Remote only iOS that knows how to locate SDK files in the
cached SDK locations on the host.
A new agnostic platform has been created:
PlatformRemoteGDBServer - this implements the platform using the GDB remote
protocol and uses the built in lldb_private::Host
static functions to implement many queries.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128193 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
index 18d6087..faee677 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
@@ -35,8 +35,7 @@
//----------------------------------------------------------------------
GDBRemoteCommunicationServer::GDBRemoteCommunicationServer() :
GDBRemoteCommunication ("gdb-remote.server", "gdb-remote.server.rx_packet"),
- m_async_thread (LLDB_INVALID_HOST_THREAD),
- m_send_acks (true)
+ m_async_thread (LLDB_INVALID_HOST_THREAD)
{
}
@@ -73,6 +72,7 @@
//
bool
GDBRemoteCommunicationServer::GetPacketAndSendResponse (const TimeValue* timeout_ptr,
+ Error &error,
bool &interrupt,
bool &quit)
{
@@ -87,10 +87,12 @@
break;
case StringExtractorGDBRemote::eServerPacketType_invalid:
+ error.SetErrorString("invalid packet");
quit = true;
break;
case StringExtractorGDBRemote::eServerPacketType_interrupt:
+ error.SetErrorString("interrupt received");
interrupt = true;
break;
@@ -99,9 +101,20 @@
case StringExtractorGDBRemote::eServerPacketType_qHostInfo:
return Handle_qHostInfo ();
+
+ case StringExtractorGDBRemote::eServerPacketType_QStartNoAckMode:
+ return Handle_QStartNoAckMode ();
}
return true;
}
+ else
+ {
+ if (!IsConnected())
+ error.SetErrorString("lost connection");
+ else
+ error.SetErrorString("timeout");
+ }
+
return false;
}
@@ -111,6 +124,19 @@
return SendPacket ("");
}
+size_t
+GDBRemoteCommunicationServer::SendOKResponse ()
+{
+ return SendPacket ("OK");
+}
+
+bool
+GDBRemoteCommunicationServer::HandshakeWithClient(Error *error_ptr)
+{
+ if (StartReadThread(error_ptr))
+ return GetAck();
+ return false;
+}
bool
GDBRemoteCommunicationServer::Handle_qHostInfo ()
@@ -120,17 +146,18 @@
// $cputype:16777223;cpusubtype:3;ostype:Darwin;vendor:apple;endian:little;ptrsize:8;#00
ArchSpec host_arch (Host::GetArchitecture ());
-
const llvm::Triple &host_triple = host_arch.GetTriple();
- const llvm::StringRef arch_name (host_triple.getArchName());
- const llvm::StringRef vendor_name (host_triple.getOSName());
- const llvm::StringRef os_name (host_triple.getVendorName());
- response.Printf ("arch:%.*s;ostype:%.*s;vendor:%.*s;ptrsize:%u",
- (int)arch_name.size(), arch_name.data(),
- (int)os_name.size(), os_name.data(),
- (int)vendor_name.size(), vendor_name.data(),
- host_arch.GetAddressByteSize());
+ response.PutCString("triple:");
+ response.PutCStringAsRawHex8(host_triple.getTriple().c_str());
+ response.Printf (";ptrsize:%u;",host_arch.GetAddressByteSize());
+ uint32_t cpu = host_arch.GetMachOCPUType();
+ uint32_t sub = host_arch.GetMachOCPUSubType();
+ if (cpu != LLDB_INVALID_CPUTYPE)
+ response.Printf ("cputype:%u;", cpu);
+ if (sub != LLDB_INVALID_CPUTYPE)
+ response.Printf ("cpusubtype:%u;", sub);
+
switch (lldb::endian::InlHostByteOrder())
{
case eByteOrderBig: response.PutCString ("endian:big;"); break;
@@ -139,5 +166,52 @@
default: response.PutCString ("endian:unknown;"); break;
}
+ uint32_t major = UINT32_MAX;
+ uint32_t minor = UINT32_MAX;
+ uint32_t update = UINT32_MAX;
+ if (Host::GetOSVersion (major, minor, update))
+ {
+ if (major != UINT32_MAX)
+ {
+ response.Printf("os_version:%u", major);
+ if (minor != UINT32_MAX)
+ {
+ response.Printf(".%u", minor);
+ if (update != UINT32_MAX)
+ response.Printf(".%u", update);
+ }
+ response.PutChar(';');
+ }
+ }
+
+ std::string s;
+ if (Host::GetOSBuildString (s))
+ {
+ response.PutCString ("os_build:");
+ response.PutCStringAsRawHex8(s.c_str());
+ response.PutChar(';');
+ }
+ if (Host::GetOSKernelDescription (s))
+ {
+ response.PutCString ("os_kernel:");
+ response.PutCStringAsRawHex8(s.c_str());
+ response.PutChar(';');
+ }
+ if (Host::GetHostname (s))
+ {
+ response.PutCString ("hostname:");
+ response.PutCStringAsRawHex8(s.c_str());
+ response.PutChar(';');
+ }
+
return SendPacket (response.GetString().c_str(),response.GetString().size()) > 0;
}
+
+
+bool
+GDBRemoteCommunicationServer::Handle_QStartNoAckMode ()
+{
+ SendOKResponse ();
+ m_send_acks = false;
+ return true;
+}