[Lldb-commits] [lldb] r217773 - Check for byte order correctness in GDBRemoteCommunicationClient::GetCurrentProcessInfo.

Todd Fiala todd.fiala at gmail.com
Mon Sep 15 08:31:11 PDT 2014


Author: tfiala
Date: Mon Sep 15 10:31:11 2014
New Revision: 217773

URL: http://llvm.org/viewvc/llvm-project?rev=217773&view=rev
Log:
Check for byte order correctness in GDBRemoteCommunicationClient::GetCurrentProcessInfo.

This is useful for checking inconsistencies between what the remote debug server thinks we are debugging and we think we are debugging. This follows the check for pointer byte size done just above.

Change by Stephane Sezer.

Tested:
Ubuntu 14.04 x86_64, llvm-3.5-built lldb
MacOSX 10.9.4, Xcode-Beta(2014-09-09)-built lldb.

Modified:
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

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=217773&r1=217772&r2=217773&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Mon Sep 15 10:31:11 2014
@@ -2426,6 +2426,7 @@ GDBRemoteCommunicationClient::GetCurrent
             std::string triple;
             uint32_t pointer_byte_size = 0;
             StringExtractor extractor;
+            ByteOrder byte_order = eByteOrderInvalid;
             uint32_t num_keys_decoded = 0;
             lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
             while (response.GetNameColonValue(name, value))
@@ -2459,10 +2460,15 @@ GDBRemoteCommunicationClient::GetCurrent
                 }
                 else if (name.compare("endian") == 0)
                 {
-                    if (value.compare("little") == 0 ||
-                        value.compare("big") == 0 ||
-                        value.compare("pdp") == 0)
-                        ++num_keys_decoded;
+                    ++num_keys_decoded;
+                    if (value.compare("little") == 0)
+                        byte_order = eByteOrderLittle;
+                    else if (value.compare("big") == 0)
+                        byte_order = eByteOrderBig;
+                    else if (value.compare("pdp") == 0)
+                        byte_order = eByteOrderPDP;
+                    else
+                        --num_keys_decoded;
                 }
                 else if (name.compare("ptrsize") == 0)
                 {
@@ -2501,6 +2507,10 @@ GDBRemoteCommunicationClient::GetCurrent
                 {
                     assert (pointer_byte_size == m_process_arch.GetAddressByteSize());
                 }
+                if (byte_order != eByteOrderInvalid)
+                {
+                    assert (byte_order == m_process_arch.GetByteOrder());
+                }
                 m_process_arch.GetTriple().setVendorName (llvm::StringRef (vendor_name));
                 m_process_arch.GetTriple().setOSName(llvm::StringRef (os_name));
                 m_host_arch.GetTriple().setVendorName (llvm::StringRef (vendor_name));





More information about the lldb-commits mailing list