diff options
Diffstat (limited to 'lldb/source/Target')
| -rw-r--r-- | lldb/source/Target/Platform.cpp | 31 | ||||
| -rw-r--r-- | lldb/source/Target/Process.cpp | 4 |
2 files changed, 33 insertions, 2 deletions
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. |

