aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter/OptionGroupPlatform.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Interpreter/OptionGroupPlatform.cpp')
-rw-r--r--lldb/source/Interpreter/OptionGroupPlatform.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp
index 4242e010fa64..acdf3f293496 100644
--- a/lldb/source/Interpreter/OptionGroupPlatform.cpp
+++ b/lldb/source/Interpreter/OptionGroupPlatform.cpp
@@ -18,27 +18,34 @@ using namespace lldb_private;
PlatformSP OptionGroupPlatform::CreatePlatformWithOptions(
CommandInterpreter &interpreter, const ArchSpec &arch, bool make_selected,
Status &error, ArchSpec &platform_arch) const {
+ PlatformList &platforms = interpreter.GetDebugger().GetPlatformList();
+
PlatformSP platform_sp;
if (!m_platform_name.empty()) {
- platform_sp = Platform::Create(ConstString(m_platform_name.c_str()), error);
+ platform_sp = platforms.Create(m_platform_name);
+ if (!platform_sp) {
+ error.SetErrorStringWithFormatv(
+ "unable to find a plug-in for the platform named \"{0}\"",
+ m_platform_name);
+ }
if (platform_sp) {
- if (platform_arch.IsValid() &&
- !platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch)) {
- error.SetErrorStringWithFormat("platform '%s' doesn't support '%s'",
- platform_sp->GetName().GetCString(),
- arch.GetTriple().getTriple().c_str());
+ if (platform_arch.IsValid() && !platform_sp->IsCompatibleArchitecture(
+ arch, {}, false, &platform_arch)) {
+ error.SetErrorStringWithFormatv("platform '{0}' doesn't support '{1}'",
+ platform_sp->GetPluginName(),
+ arch.GetTriple().getTriple());
platform_sp.reset();
return platform_sp;
}
}
} else if (arch.IsValid()) {
- platform_sp = Platform::Create(arch, &platform_arch, error);
+ platform_sp = platforms.GetOrCreate(arch, {}, &platform_arch, error);
}
if (platform_sp) {
- interpreter.GetDebugger().GetPlatformList().Append(platform_sp,
- make_selected);
+ if (make_selected)
+ platforms.SetSelectedPlatform(platform_sp);
if (!m_os_version.empty())
platform_sp->SetOSVersion(m_os_version);
@@ -122,7 +129,7 @@ bool OptionGroupPlatform::PlatformMatches(
const lldb::PlatformSP &platform_sp) const {
if (platform_sp) {
if (!m_platform_name.empty()) {
- if (platform_sp->GetName() != ConstString(m_platform_name.c_str()))
+ if (platform_sp->GetName() != m_platform_name)
return false;
}