[Lldb-commits] [PATCH 1/4] ArchSpec: Do not set default to host settings when setting a triple.
Stephen Wilson
wilsons at start.ca
Wed Feb 23 16:48:19 PST 2011
On Wed, Feb 23, 2011 at 03:59:37PM -0800, Greg Clayton wrote:
> Or use the llvm::sys::getHostTriple() like you did in path 2/4...
OK. How about the following patch. Instead of filling in unknown
fields selectively this version updates the missing
vendor/OS/environment fields iff all of them are undefined.
This should help in the situations where, for example, you are
debugging an embedded linux board remotely on darwin. Otherwise a call to
SetTriple("armv5l-unknown-linux") would come out as "armv5l-apple-linux".
diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h
index a479f47..69fff9f 100644
--- a/include/lldb/Core/ArchSpec.h
+++ b/include/lldb/Core/ArchSpec.h
@@ -294,11 +294,12 @@ public:
//------------------------------------------------------------------
/// 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.
//------------------------------------------------------------------
diff --git a/source/Core/ArchSpec.cpp b/source/Core/ArchSpec.cpp
index a5493b3..3d59d28 100644
--- a/source/Core/ArchSpec.cpp
+++ b/source/Core/ArchSpec.cpp
@@ -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 @@ ArchSpec::SetTriple (const llvm::Triple &triple)
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