summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/API/SBDebugger.cpp4
-rw-r--r--lldb/source/API/SBInstruction.cpp4
-rw-r--r--lldb/source/API/SBTarget.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectDisassemble.cpp3
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp4
-rw-r--r--lldb/source/Core/ArchSpec.cpp92
-rw-r--r--lldb/source/Host/common/HostInfoBase.cpp18
-rw-r--r--lldb/source/Interpreter/OptionGroupArchitecture.cpp11
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp7
-rw-r--r--lldb/source/Target/Platform.cpp31
-rw-r--r--lldb/source/Target/Process.cpp4
11 files changed, 70 insertions, 112 deletions
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 3170dc72405..d3294dab582 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -694,8 +694,8 @@ SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename,
SBTarget sb_target;
if (m_opaque_sp && filename && filename[0]) {
// No need to lock, the target list is thread safe
- ArchSpec arch(arch_name,
- m_opaque_sp->GetPlatformList().GetSelectedPlatform().get());
+ ArchSpec arch = Platform::GetAugmentedArchSpec(
+ m_opaque_sp->GetPlatformList().GetSelectedPlatform().get(), arch_name);
TargetSP target_sp(
m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture(
FileSpec(filename, false), arch_name ? &arch : nullptr));
diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp
index 8b7deb7011b..181ce362ea7 100644
--- a/lldb/source/API/SBInstruction.cpp
+++ b/lldb/source/API/SBInstruction.cpp
@@ -20,6 +20,7 @@
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Host/HostInfo.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
@@ -259,8 +260,7 @@ bool SBInstruction::EmulateWithFrame(lldb::SBFrame &frame,
bool SBInstruction::DumpEmulation(const char *triple) {
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp && triple) {
- lldb_private::ArchSpec arch(triple, NULL);
- return inst_sp->DumpEmulation(arch);
+ return inst_sp->DumpEmulation(HostInfo::GetAugmentedArchSpec(triple));
}
return false;
}
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 4b9c64f70f5..19cd53ec0ff 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1442,8 +1442,8 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
module_spec.GetUUID().SetFromCString(uuid_cstr);
if (triple)
- module_spec.GetArchitecture().SetTriple(triple,
- target_sp->GetPlatform().get());
+ module_spec.GetArchitecture() = Platform::GetAugmentedArchSpec(
+ target_sp->GetPlatform().get(), triple);
else
module_spec.GetArchitecture() = target_sp->GetArchitecture();
diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 5d0f2417f99..31c54b7d433 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -163,8 +163,7 @@ Status CommandObjectDisassemble::CommandOptions::SetOptionValue(
auto target_sp =
execution_context ? execution_context->GetTargetSP() : TargetSP();
auto platform_sp = target_sp ? target_sp->GetPlatform() : PlatformSP();
- if (!arch.SetTriple(option_arg, platform_sp.get()))
- arch.SetTriple(option_arg);
+ arch = Platform::GetAugmentedArchSpec(platform_sp.get(), option_arg);
}
break;
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 8003ae88ac0..8ed003767d5 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1337,8 +1337,8 @@ protected:
PlatformSP platform_sp =
debugger_sp ? debugger_sp->GetPlatformList().GetSelectedPlatform()
: PlatformSP();
- match_info.GetProcessInfo().GetArchitecture().SetTriple(
- option_arg, platform_sp.get());
+ match_info.GetProcessInfo().GetArchitecture() =
+ Platform::GetAugmentedArchSpec(platform_sp.get(), option_arg);
} break;
case 'n':
diff --git a/lldb/source/Core/ArchSpec.cpp b/lldb/source/Core/ArchSpec.cpp
index 07c31f391ab..dc2b98250c1 100644
--- a/lldb/source/Core/ArchSpec.cpp
+++ b/lldb/source/Core/ArchSpec.cpp
@@ -10,7 +10,6 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Target/Platform.h"
#include "lldb/Utility/NameMatches.h"
#include "lldb/Utility/Stream.h" // for Stream
#include "lldb/Utility/StringList.h"
@@ -555,15 +554,6 @@ FindArchDefinitionEntry(const ArchDefinition *def, ArchSpec::Core core) {
ArchSpec::ArchSpec() {}
-ArchSpec::ArchSpec(const char *triple_cstr, Platform *platform) {
- if (triple_cstr)
- SetTriple(triple_cstr, platform);
-}
-
-ArchSpec::ArchSpec(llvm::StringRef triple_str, Platform *platform) {
- SetTriple(triple_str, platform);
-}
-
ArchSpec::ArchSpec(const char *triple_cstr) {
if (triple_cstr)
SetTriple(triple_cstr);
@@ -873,16 +863,6 @@ bool lldb_private::ParseMachCPUDashSubtypeTriple(llvm::StringRef triple_str,
return true;
}
-bool ArchSpec::SetTriple(const char *triple_cstr) {
- llvm::StringRef str(triple_cstr ? triple_cstr : "");
- return SetTriple(str);
-}
-
-bool ArchSpec::SetTriple(const char *triple_cstr, Platform *platform) {
- llvm::StringRef str(triple_cstr ? triple_cstr : "");
- return SetTriple(str, platform);
-}
-
bool ArchSpec::SetTriple(llvm::StringRef triple) {
if (triple.empty()) {
Clear();
@@ -906,73 +886,11 @@ bool ArchSpec::SetTriple(llvm::StringRef triple) {
return IsValid();
}
-bool ArchSpec::SetTriple(llvm::StringRef triple, Platform *platform) {
- if (triple.empty()) {
- Clear();
- return false;
- }
- if (ParseMachCPUDashSubtypeTriple(triple, *this))
- return true;
-
- if (triple.startswith(LLDB_ARCH_DEFAULT)) {
- // Special case for the current host default architectures...
- if (triple.equals(LLDB_ARCH_DEFAULT_32BIT))
- *this = HostInfo::GetArchitecture(HostInfo::eArchKind32);
- else if (triple.equals(LLDB_ARCH_DEFAULT_64BIT))
- *this = HostInfo::GetArchitecture(HostInfo::eArchKind64);
- else if (triple.equals(LLDB_ARCH_DEFAULT))
- *this = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
- return IsValid();
- }
-
- ArchSpec raw_arch(triple);
-
- llvm::Triple normalized_triple(llvm::Triple::normalize(triple));
-
- const bool os_specified = !normalized_triple.getOSName().empty();
- const bool vendor_specified = !normalized_triple.getVendorName().empty();
- const bool env_specified = !normalized_triple.getEnvironmentName().empty();
-
- if (os_specified || vendor_specified || env_specified) {
- SetTriple(normalized_triple);
- return IsValid();
- }
-
- // We got an arch only. If there is no platform, fallback to the host system
- // for defaults.
- if (!platform) {
- llvm::Triple host_triple(llvm::sys::getDefaultTargetTriple());
- if (!vendor_specified)
- normalized_triple.setVendor(host_triple.getVendor());
- if (!vendor_specified)
- normalized_triple.setOS(host_triple.getOS());
- if (!env_specified && host_triple.getEnvironmentName().size())
- normalized_triple.setEnvironment(host_triple.getEnvironment());
- SetTriple(normalized_triple);
- return IsValid();
- }
-
- // If we were given a platform, use the platform's system architecture. If
- // this is not available (might not be connected) use the first supported
- // architecture.
- ArchSpec compatible_arch;
- if (!platform->IsCompatibleArchitecture(raw_arch, false, &compatible_arch)) {
- *this = raw_arch;
- return IsValid();
- }
-
- if (compatible_arch.IsValid()) {
- const llvm::Triple &compatible_triple = compatible_arch.GetTriple();
- if (!vendor_specified)
- normalized_triple.setVendor(compatible_triple.getVendor());
- if (!os_specified)
- normalized_triple.setOS(compatible_triple.getOS());
- if (!env_specified && compatible_triple.hasEnvironment())
- normalized_triple.setEnvironment(compatible_triple.getEnvironment());
- }
-
- SetTriple(normalized_triple);
- return IsValid();
+bool ArchSpec::ContainsOnlyArch(const llvm::Triple &normalized_triple) {
+ return !normalized_triple.getArchName().empty() &&
+ normalized_triple.getOSName().empty() &&
+ normalized_triple.getVendorName().empty() &&
+ normalized_triple.getEnvironmentName().empty();
}
void ArchSpec::MergeFrom(const ArchSpec &other) {
diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp
index a6c9e91a98e..1362a0cdd46 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -251,6 +251,24 @@ bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
return true;
}
+ArchSpec HostInfoBase::GetAugmentedArchSpec(llvm::StringRef triple) {
+ if (triple.empty())
+ return ArchSpec();
+ llvm::Triple normalized_triple(llvm::Triple::normalize(triple));
+ if (!ArchSpec::ContainsOnlyArch(normalized_triple))
+ return ArchSpec(triple);
+
+ llvm::Triple host_triple(llvm::sys::getDefaultTargetTriple());
+
+ if (normalized_triple.getVendorName().empty())
+ normalized_triple.setVendor(host_triple.getVendor());
+ if (normalized_triple.getOSName().empty())
+ normalized_triple.setOS(host_triple.getOS());
+ if (normalized_triple.getEnvironmentName().empty())
+ normalized_triple.setEnvironment(host_triple.getEnvironment());
+ return ArchSpec(normalized_triple);
+}
+
bool HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec) {
// To get paths related to LLDB we get the path to the executable that
// contains this function. On MacOSX this will be "LLDB.framework/.../LLDB",
diff --git a/lldb/source/Interpreter/OptionGroupArchitecture.cpp b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
index d5354fe0739..bbd69b8f13f 100644
--- a/lldb/source/Interpreter/OptionGroupArchitecture.cpp
+++ b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
@@ -8,12 +8,8 @@
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/OptionGroupArchitecture.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Host/OptionParser.h"
+#include "lldb/Target/Platform.h"
using namespace lldb;
using namespace lldb_private;
@@ -34,10 +30,7 @@ llvm::ArrayRef<OptionDefinition> OptionGroupArchitecture::GetDefinitions() {
bool OptionGroupArchitecture::GetArchitecture(Platform *platform,
ArchSpec &arch) {
- if (m_arch_str.empty())
- arch.Clear();
- else
- arch.SetTriple(m_arch_str.c_str(), platform);
+ arch = Platform::GetAugmentedArchSpec(platform, m_arch_str);
return arch.IsValid();
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index f53db502be9..3cf6b8ac07b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -403,8 +403,8 @@ GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo(
match_info.SetMatchAllUsers(
Args::StringToBoolean(value, false, &success));
} else if (key.equals("triple")) {
- match_info.GetProcessInfo().GetArchitecture().SetTriple(
- value.str().c_str(), NULL);
+ match_info.GetProcessInfo().GetArchitecture() =
+ HostInfo::GetAugmentedArchSpec(value);
} else {
success = false;
}
@@ -973,8 +973,7 @@ GDBRemoteCommunicationServerCommon::Handle_QLaunchArch(
const uint32_t bytes_left = packet.GetBytesLeft();
if (bytes_left > 0) {
const char *arch_triple = packet.Peek();
- ArchSpec arch_spec(arch_triple, NULL);
- m_process_launch_info.SetArchitecture(arch_spec);
+ m_process_launch_info.SetArchitecture(HostInfo::GetAugmentedArchSpec(arch_triple));
return SendOKResponse();
}
return SendErrorResponse(13);
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index ab09517b633..60aa0079060 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -356,6 +356,12 @@ PlatformSP Platform::Create(const ArchSpec &arch, ArchSpec *platform_arch_ptr,
return platform_sp;
}
+ArchSpec Platform::GetAugmentedArchSpec(Platform *platform, llvm::StringRef triple) {
+ if (platform)
+ return platform->GetAugmentedArchSpec(triple);
+ return HostInfo::GetAugmentedArchSpec(triple);
+}
+
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
@@ -963,6 +969,31 @@ const ArchSpec &Platform::GetSystemArchitecture() {
return m_system_arch;
}
+ArchSpec Platform::GetAugmentedArchSpec(llvm::StringRef triple) {
+ if (triple.empty())
+ return ArchSpec();
+ llvm::Triple normalized_triple(llvm::Triple::normalize(triple));
+ if (!ArchSpec::ContainsOnlyArch(normalized_triple))
+ return ArchSpec(triple);
+
+ ArchSpec compatible_arch;
+ ArchSpec raw_arch(triple);
+ if (!IsCompatibleArchitecture(raw_arch, false, &compatible_arch))
+ return raw_arch;
+
+ if (!compatible_arch.IsValid())
+ return ArchSpec(normalized_triple);
+
+ const llvm::Triple &compatible_triple = compatible_arch.GetTriple();
+ if (normalized_triple.getVendorName().empty())
+ normalized_triple.setVendor(compatible_triple.getVendor());
+ if (normalized_triple.getOSName().empty())
+ normalized_triple.setOS(compatible_triple.getOS());
+ if (normalized_triple.getEnvironmentName().empty())
+ normalized_triple.setEnvironment(compatible_triple.getEnvironment());
+ return ArchSpec(normalized_triple);
+}
+
Status Platform::ConnectRemote(Args &args) {
Status error;
if (IsHost())
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 6540b906477..812000d2d3a 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -480,8 +480,8 @@ Status ProcessLaunchCommandOptions::SetOptionValue(
execution_context ? execution_context->GetTargetSP() : TargetSP();
PlatformSP platform_sp =
target_sp ? target_sp->GetPlatform() : PlatformSP();
- if (!launch_info.GetArchitecture().SetTriple(option_arg, platform_sp.get()))
- launch_info.GetArchitecture().SetTriple(option_arg);
+ launch_info.GetArchitecture() =
+ Platform::GetAugmentedArchSpec(platform_sp.get(), option_arg);
} break;
case 'A': // Disable ASLR.
OpenPOWER on IntegriCloud