[Lldb-commits] [lldb] r126403 - in /lldb/trunk: include/lldb/Core/ArchSpec.h source/Core/ArchSpec.cpp

Stephen Wilson wilsons at start.ca
Thu Feb 24 11:13:58 PST 2011


Author: wilsons
Date: Thu Feb 24 13:13:58 2011
New Revision: 126403

URL: http://llvm.org/viewvc/llvm-project?rev=126403&view=rev
Log:
ArchSpec: Do not depend on Host::GetArchitecture.

The major issue this patch solves is that ArchSpec::SetTriple no longer depends
on the implementation of Host::GetArchitecture.  On linux, Host::GetArchitecture
calls ArchSpec::SetTriple, thus blowing the stack.

A second smaller point is that SetTriple now defaults to Host defined components
iff all OS, vendor and environment fields are not set.


Modified:
    lldb/trunk/include/lldb/Core/ArchSpec.h
    lldb/trunk/source/Core/ArchSpec.cpp

Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=126403&r1=126402&r2=126403&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Thu Feb 24 13:13:58 2011
@@ -294,11 +294,12 @@
     //------------------------------------------------------------------
     /// Architecture tripple setter.
     ///
-    /// Configures this ArchSpec according to the given triple.  At a
-    /// minimum, the given triple must describe a valid operating
-    /// system.  If archetecture or environment components are present
-    /// they too will be used to further resolve the CPU type and
-    /// subtype, endian characteristics, etc.
+    /// Configures this ArchSpec according to the given triple.  If the 
+    /// triple has unknown components in all of the vendor, OS, and 
+    /// the optional environment field (i.e. "i386-unknown-unknown")
+    /// then default values are taken from the host.  Architecture and
+    /// environment components are used to further resolve the CPU type
+    /// and subtype, endian characteristics, etc.
     ///
     /// @return A triple describing this ArchSpec.
     //------------------------------------------------------------------

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=126403&r1=126402&r2=126403&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Thu Feb 24 13:13:58 2011
@@ -14,6 +14,7 @@
 #include <string>
 
 #include "llvm/Support/ELF.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/MachO.h"
 #include "lldb/Host/Endian.h"
 #include "lldb/Host/Host.h"
@@ -407,14 +408,16 @@
         m_core = core_def->core;
         m_byte_order = core_def->default_byte_order;
 
-        // If the vendor, OS or environment aren't specified, default to the system?
-        const ArchSpec &host_arch_ref = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
-        if (m_triple.getVendor() == llvm::Triple::UnknownVendor)
-            m_triple.setVendor(host_arch_ref.GetTriple().getVendor());
-        if (m_triple.getOS() == llvm::Triple::UnknownOS)
-            m_triple.setOS(host_arch_ref.GetTriple().getOS());
-        if (m_triple.getEnvironment() == llvm::Triple::UnknownEnvironment)
-            m_triple.setEnvironment(host_arch_ref.GetTriple().getEnvironment());
+        if (m_triple.getVendor() == llvm::Triple::UnknownVendor &&
+            m_triple.getOS() == llvm::Triple::UnknownOS &&
+            m_triple.getEnvironment() == llvm::Triple::UnknownEnvironment)
+        {
+            llvm::Triple host_triple(llvm::sys::getHostTriple());
+
+            m_triple.setVendor(host_triple.getVendor());
+            m_triple.setOS(host_triple.getOS());
+            m_triple.setEnvironment(host_triple.getEnvironment());
+        }
     }
     else
     {





More information about the lldb-commits mailing list