summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Process')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp109
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h26
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp13
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h4
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp62
5 files changed, 110 insertions, 104 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index b4fb6f2ddfe..7700ab2b7f5 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -50,11 +50,7 @@ GDBRemoteCommunicationClient::GDBRemoteCommunicationClient() :
m_async_packet (),
m_async_response (),
m_async_signal (-1),
- m_arch(),
- m_os(),
- m_vendor(),
- m_byte_order(lldb::endian::InlHostByteOrder()),
- m_pointer_byte_size(0)
+ m_host_arch()
{
m_rx_packet_listener.StartListeningForEvents(this,
Communication::eBroadcastBitPacketAvailable |
@@ -102,11 +98,7 @@ GDBRemoteCommunicationClient::ResetDiscoverableSettings()
m_supports_vCont_C = eLazyBoolCalculate;
m_supports_vCont_s = eLazyBoolCalculate;
m_supports_vCont_S = eLazyBoolCalculate;
- m_arch.Clear();
- m_os.Clear();
- m_vendor.Clear();
- m_byte_order = lldb::endian::InlHostByteOrder();
- m_pointer_byte_size = 0;
+ m_host_arch.Clear();
}
@@ -690,7 +682,11 @@ GDBRemoteCommunicationClient::GetHostInfo ()
std::string value;
uint32_t cpu = LLDB_INVALID_CPUTYPE;
uint32_t sub = 0;
-
+ std::string arch_name;
+ std::string os_name;
+ std::string vendor_name;
+ uint32_t pointer_byte_size = 0;
+ ByteOrder byte_order = eByteOrderInvalid;
while (response.GetNameColonValue(name, value))
{
if (name.compare("cputype") == 0)
@@ -703,32 +699,69 @@ GDBRemoteCommunicationClient::GetHostInfo ()
// exception count in big endian hex
sub = Args::StringToUInt32 (value.c_str(), 0, 0);
}
+ else if (name.compare("arch") == 0)
+ {
+ arch_name.swap (value);
+ }
else if (name.compare("ostype") == 0)
{
- // exception data in big endian hex
- m_os.SetCString(value.c_str());
+ os_name.swap (value);
}
else if (name.compare("vendor") == 0)
{
- m_vendor.SetCString(value.c_str());
+ vendor_name.swap(value);
}
else if (name.compare("endian") == 0)
{
if (value.compare("little") == 0)
- m_byte_order = eByteOrderLittle;
+ byte_order = eByteOrderLittle;
else if (value.compare("big") == 0)
- m_byte_order = eByteOrderBig;
+ byte_order = eByteOrderBig;
else if (value.compare("pdp") == 0)
- m_byte_order = eByteOrderPDP;
+ byte_order = eByteOrderPDP;
}
else if (name.compare("ptrsize") == 0)
{
- m_pointer_byte_size = Args::StringToUInt32 (value.c_str(), 0, 0);
+ pointer_byte_size = Args::StringToUInt32 (value.c_str(), 0, 0);
}
}
- if (cpu != LLDB_INVALID_CPUTYPE)
- m_arch.SetArchitecture (lldb::eArchTypeMachO, cpu, sub);
+ if (arch_name.empty())
+ {
+ if (cpu != LLDB_INVALID_CPUTYPE)
+ {
+ m_host_arch.SetArchitecture (lldb::eArchTypeMachO, cpu, sub);
+ if (pointer_byte_size)
+ {
+ assert (pointer_byte_size == m_host_arch.GetAddressByteSize());
+ }
+ if (byte_order != eByteOrderInvalid)
+ {
+ assert (byte_order == m_host_arch.GetByteOrder());
+ }
+ if (!vendor_name.empty())
+ m_host_arch.GetTriple().setVendorName (llvm::StringRef (vendor_name));
+ if (!os_name.empty())
+ m_host_arch.GetTriple().setVendorName (llvm::StringRef (os_name));
+
+ }
+ }
+ else
+ {
+ std::string triple;
+ triple += arch_name;
+ triple += '-';
+ if (vendor_name.empty())
+ triple += "unknown";
+ else
+ triple += vendor_name;
+ triple += '-';
+ if (os_name.empty())
+ triple += "unknown";
+ else
+ triple += os_name;
+ m_host_arch.SetTriple (triple.c_str());
+ }
}
}
return m_supports_qHostInfo == eLazyBoolYes;
@@ -759,41 +792,9 @@ GDBRemoteCommunicationClient::SendAttach
const lldb_private::ArchSpec &
GDBRemoteCommunicationClient::GetHostArchitecture ()
{
- if (!HostInfoIsValid ())
- GetHostInfo ();
- return m_arch;
-}
-
-const lldb_private::ConstString &
-GDBRemoteCommunicationClient::GetOSString ()
-{
- if (!HostInfoIsValid ())
- GetHostInfo ();
- return m_os;
-}
-
-const lldb_private::ConstString &
-GDBRemoteCommunicationClient::GetVendorString()
-{
- if (!HostInfoIsValid ())
- GetHostInfo ();
- return m_vendor;
-}
-
-lldb::ByteOrder
-GDBRemoteCommunicationClient::GetByteOrder ()
-{
- if (!HostInfoIsValid ())
- GetHostInfo ();
- return m_byte_order;
-}
-
-uint32_t
-GDBRemoteCommunicationClient::GetAddressByteSize ()
-{
- if (!HostInfoIsValid ())
+ if (m_supports_qHostInfo == lldb::eLazyBoolCalculate)
GetHostInfo ();
- return m_pointer_byte_size;
+ return m_host_arch;
}
addr_t
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
index 604e09a9491..bcf23f2c589 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -176,18 +176,6 @@ public:
const lldb_private::ArchSpec &
GetHostArchitecture ();
- const lldb_private::ConstString &
- GetOSString ();
-
- const lldb_private::ConstString &
- GetVendorString();
-
- lldb::ByteOrder
- GetByteOrder ();
-
- uint32_t
- GetAddressByteSize ();
-
bool
GetVContSupported (char flavor);
@@ -222,12 +210,6 @@ public:
protected:
- bool
- HostInfoIsValid () const
- {
- return m_supports_qHostInfo != lldb::eLazyBoolCalculate;
- }
-
//------------------------------------------------------------------
// Classes that inherit from GDBRemoteCommunicationClient can see and modify these
//------------------------------------------------------------------
@@ -249,14 +231,8 @@ protected:
StringExtractorGDBRemote m_async_response;
int m_async_signal; // We were asked to deliver a signal to the inferior process.
- lldb_private::ArchSpec m_arch;
+ lldb_private::ArchSpec m_host_arch;
uint32_t m_cpusubtype;
- lldb_private::ConstString m_os;
- lldb_private::ConstString m_vendor;
- lldb::ByteOrder m_byte_order;
- uint32_t m_pointer_byte_size;
-
-
private:
//------------------------------------------------------------------
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
index 2e4ff70cf2d..18d6087e8b5 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
@@ -72,10 +72,12 @@ GDBRemoteCommunicationServer::~GDBRemoteCommunicationServer()
//}
//
bool
-GDBRemoteCommunicationServer::GetPacketAndSendResponse (const TimeValue* timeout_time_ptr)
+GDBRemoteCommunicationServer::GetPacketAndSendResponse (const TimeValue* timeout_ptr,
+ bool &interrupt,
+ bool &quit)
{
StringExtractorGDBRemote packet;
- if (WaitForPacketNoLock (packet, timeout_time_ptr))
+ if (WaitForPacketNoLock (packet, timeout_ptr))
{
const StringExtractorGDBRemote::ServerPacketType packet_type = packet.GetServerPacketType ();
switch (packet_type)
@@ -85,6 +87,13 @@ GDBRemoteCommunicationServer::GetPacketAndSendResponse (const TimeValue* timeout
break;
case StringExtractorGDBRemote::eServerPacketType_invalid:
+ quit = true;
+ break;
+
+ case StringExtractorGDBRemote::eServerPacketType_interrupt:
+ interrupt = true;
+ break;
+
case StringExtractorGDBRemote::eServerPacketType_unimplemented:
return SendUnimplementedResponse () > 0;
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
index 8ccfca2ee1d..4e0b24ddea0 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
@@ -34,7 +34,9 @@ public:
~GDBRemoteCommunicationServer();
bool
- GetPacketAndSendResponse (const lldb_private::TimeValue* timeout_time_ptr);
+ GetPacketAndSendResponse (const lldb_private::TimeValue* timeout_ptr,
+ bool &interrupt,
+ bool &quit);
virtual bool
GetThreadSuffixSupported ()
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 79949669e77..e5a1d7c0606 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -622,34 +622,52 @@ ProcessGDBRemote::DidLaunchOrAttach ()
BuildDynamicRegisterInfo (false);
- m_target.GetArchitecture().SetByteOrder (m_gdb_comm.GetByteOrder());
StreamString strm;
// See if the GDB server supports the qHostInfo information
- const char *vendor = m_gdb_comm.GetVendorString().AsCString();
- const char *os_type = m_gdb_comm.GetOSString().AsCString();
- ArchSpec target_arch (GetTarget().GetArchitecture());
- ArchSpec gdb_remote_arch (m_gdb_comm.GetHostArchitecture());
-
- // If the remote host is ARM and we have apple as the vendor, then
- // ARM executables and shared libraries can have mixed ARM architectures.
- // You can have an armv6 executable, and if the host is armv7, then the
- // system will load the best possible architecture for all shared libraries
- // it has, so we really need to take the remote host architecture as our
- // defacto architecture in this case.
-
- if (gdb_remote_arch.GetMachine() == llvm::Triple::arm &&
- gdb_remote_arch.GetTriple().getVendor() == llvm::Triple::Apple)
+
+ const ArchSpec &gdb_remote_arch = m_gdb_comm.GetHostArchitecture();
+ if (gdb_remote_arch.IsValid())
{
- GetTarget().SetArchitecture (gdb_remote_arch);
- target_arch = gdb_remote_arch;
+ ArchSpec &target_arch = GetTarget().GetArchitecture();
+
+ if (target_arch.IsValid())
+ {
+ // If the remote host is ARM and we have apple as the vendor, then
+ // ARM executables and shared libraries can have mixed ARM architectures.
+ // You can have an armv6 executable, and if the host is armv7, then the
+ // system will load the best possible architecture for all shared libraries
+ // it has, so we really need to take the remote host architecture as our
+ // defacto architecture in this case.
+
+ if (gdb_remote_arch.GetMachine() == llvm::Triple::arm &&
+ gdb_remote_arch.GetTriple().getVendor() == llvm::Triple::Apple)
+ {
+ target_arch = gdb_remote_arch;
+ }
+ else
+ {
+ // Fill in what is missing in the triple
+ const llvm::Triple &remote_triple = gdb_remote_arch.GetTriple();
+ llvm::Triple &target_triple = target_arch.GetTriple();
+ if (target_triple.getVendor() == llvm::Triple::UnknownVendor)
+ target_triple.setVendor (remote_triple.getVendor());
+
+ if (target_triple.getOS() == llvm::Triple::UnknownOS)
+ target_triple.setOS (remote_triple.getOS());
+
+ if (target_triple.getEnvironment() == llvm::Triple::UnknownEnvironment)
+ target_triple.setEnvironment (remote_triple.getEnvironment());
+ }
+ }
+ else
+ {
+ // The target doesn't have a valid architecture yet, set it from
+ // the architecture we got from the remote GDB server
+ target_arch = gdb_remote_arch;
+ }
}
-
- if (vendor)
- m_target.GetArchitecture().GetTriple().setVendorName(vendor);
- if (os_type)
- m_target.GetArchitecture().GetTriple().setOSName(os_type);
}
}
OpenPOWER on IntegriCloud