[Lldb-commits] [lldb] r216470 - Fix llgs to send triple for non-Apple platforms and lldb to interpret correctly.
Todd Fiala
todd.fiala at gmail.com
Tue Aug 26 11:21:03 PDT 2014
Author: tfiala
Date: Tue Aug 26 13:21:02 2014
New Revision: 216470
URL: http://llvm.org/viewvc/llvm-project?rev=216470&view=rev
Log:
Fix llgs to send triple for non-Apple platforms and lldb to interpret correctly.
This change addresses this bug:
http://llvm.org/bugs/show_bug.cgi?id=20755
This change:
* Modifies llgs to send triple instead of cputype and cpusubtype when not on Apple platforms in qProcessInfo.
* Modifies lldb's GDBRemoteCommunicationClient to handle the triple returned from qProcessInfo if given.
When given, it will prefer to use triple over cputype and cpusubtype.
* Adds gdb-remote protocol tests to verify that cputype and cpusubtype are specified on darwin, and that triple is specified on Linux.
Modified:
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
lldb/trunk/test/tools/lldb-gdbserver/TestGdbRemoteProcessInfo.py
lldb/trunk/test/tools/lldb-gdbserver/gdbremote_testcase.py
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=216470&r1=216469&r2=216470&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Tue Aug 26 13:21:02 2014
@@ -2442,6 +2442,11 @@ GDBRemoteCommunicationClient::GetCurrent
if (sub != 0)
++num_keys_decoded;
}
+ else if (name.compare("triple") == 0)
+ {
+ triple = value;
+ ++num_keys_decoded;
+ }
else if (name.compare("ostype") == 0)
{
os_name.swap (value);
@@ -2479,7 +2484,17 @@ GDBRemoteCommunicationClient::GetCurrent
m_curr_pid_is_valid = eLazyBoolYes;
m_curr_pid = pid;
}
- if (cpu != LLDB_INVALID_CPUTYPE && !os_name.empty() && !vendor_name.empty())
+
+ // Set the ArchSpec from the triple if we have it.
+ if (!triple.empty ())
+ {
+ m_process_arch.SetTriple (triple.c_str ());
+ if (pointer_byte_size)
+ {
+ assert (pointer_byte_size == m_process_arch.GetAddressByteSize());
+ }
+ }
+ else if (cpu != LLDB_INVALID_CPUTYPE && !os_name.empty() && !vendor_name.empty())
{
m_process_arch.SetArchitecture (eArchTypeMachO, cpu, sub);
if (pointer_byte_size)
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=216470&r1=216469&r2=216470&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Tue Aug 26 13:21:02 2014
@@ -1328,6 +1328,9 @@ CreateProcessInfoResponse_DebugServerSty
const ArchSpec &proc_arch = proc_info.GetArchitecture();
if (proc_arch.IsValid())
{
+ const llvm::Triple &proc_triple = proc_arch.GetTriple();
+#if defined(__APPLE__)
+ // We'll send cputype/cpusubtype.
const uint32_t cpu_type = proc_arch.GetMachOCPUType();
if (cpu_type != 0)
response.Printf ("cputype:%" PRIx32 ";", cpu_type);
@@ -1335,12 +1338,15 @@ CreateProcessInfoResponse_DebugServerSty
const uint32_t cpu_subtype = proc_arch.GetMachOCPUSubType();
if (cpu_subtype != 0)
response.Printf ("cpusubtype:%" PRIx32 ";", cpu_subtype);
+
- const llvm::Triple &proc_triple = proc_arch.GetTriple();
const std::string vendor = proc_triple.getVendorName ();
if (!vendor.empty ())
response.Printf ("vendor:%s;", vendor.c_str ());
-
+#else
+ // We'll send the triple.
+ response.Printf ("triple:%s;", proc_triple.getTriple().c_str ());
+#endif
std::string ostype = proc_triple.getOSName ();
// Adjust so ostype reports ios for Apple/ARM and Apple/ARM64.
if (proc_triple.getVendor () == llvm::Triple::Apple)
Modified: lldb/trunk/test/tools/lldb-gdbserver/TestGdbRemoteProcessInfo.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-gdbserver/TestGdbRemoteProcessInfo.py?rev=216470&r1=216469&r2=216470&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-gdbserver/TestGdbRemoteProcessInfo.py (original)
+++ lldb/trunk/test/tools/lldb-gdbserver/TestGdbRemoteProcessInfo.py Tue Aug 26 13:21:02 2014
@@ -1,7 +1,7 @@
-import unittest2
-
import gdbremote_testcase
import lldbgdbserverutils
+import sys
+import unittest2
from lldbtest import *
@@ -108,6 +108,42 @@ class TestGdbRemoteProcessInfo(gdbremote
self.buildDwarf()
self.qProcessInfo_reports_valid_endian()
+ def qProcessInfo_contains_keys(self, expected_key_set):
+ procs = self.prep_debug_monitor_and_inferior()
+ self.add_process_info_collection_packets()
+
+ # Run the stream
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ # Gather process info response
+ process_info = self.parse_process_info_response(context)
+ self.assertIsNotNone(process_info)
+
+ # Ensure the expected keys are present and non-None within the process info.
+ missing_key_set = set()
+ for expected_key in expected_key_set:
+ if expected_key not in process_info:
+ missing_key_set.add(expected_key)
+
+ self.assertEquals(missing_key_set, set(), "the listed keys are missing in the qProcessInfo result")
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ @debugserver_test
+ @dsym_test
+ def test_qProcessInfo_contains_cputype_cpusubtype_debugserver_darwin(self):
+ self.init_debugserver_test()
+ self.buildDsym()
+ self.qProcessInfo_contains_keys(set(['cputype', 'cpusubtype']))
+
+ @unittest2.skipUnless(sys.platform.startswith("linux"), "requires Linux")
+ @llgs_test
+ @dwarf_test
+ def test_qProcessInfo_contains_triple_llgs_linux(self):
+ self.init_llgs_test()
+ self.buildDwarf()
+ self.qProcessInfo_contains_keys(set(['triple']))
+
if __name__ == '__main__':
unittest2.main()
Modified: lldb/trunk/test/tools/lldb-gdbserver/gdbremote_testcase.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-gdbserver/gdbremote_testcase.py?rev=216470&r1=216469&r2=216470&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-gdbserver/gdbremote_testcase.py (original)
+++ lldb/trunk/test/tools/lldb-gdbserver/gdbremote_testcase.py Tue Aug 26 13:21:02 2014
@@ -428,6 +428,7 @@ class GdbRemoteTestCaseBase(TestBase):
"cputype",
"cpusubtype",
"ostype",
+ "triple",
"vendor",
"endian",
"ptrsize"
More information about the lldb-commits
mailing list