diff options
Diffstat (limited to 'lldb/source/API/SBDebugger.cpp')
| -rw-r--r-- | lldb/source/API/SBDebugger.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 187b7a7..c3d1a98 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1428,11 +1428,21 @@ SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) { SBError sb_error; if (m_opaque_sp) { if (platform_name_cstr && platform_name_cstr[0]) { - PlatformList &platforms = m_opaque_sp->GetPlatformList(); - if (PlatformSP platform_sp = platforms.GetOrCreate(platform_name_cstr)) - platforms.SetSelectedPlatform(platform_sp); - else - sb_error.ref().SetErrorString("platform not found"); + ConstString platform_name(platform_name_cstr); + PlatformSP platform_sp(Platform::Find(platform_name)); + + if (platform_sp) { + // Already have a platform with this name, just select it + m_opaque_sp->GetPlatformList().SetSelectedPlatform(platform_sp); + } else { + // We don't have a platform by this name yet, create one + platform_sp = Platform::Create(platform_name, sb_error.ref()); + if (platform_sp) { + // We created the platform, now append and select it + bool make_selected = true; + m_opaque_sp->GetPlatformList().Append(platform_sp, make_selected); + } + } } else { sb_error.ref().SetErrorString("invalid platform name"); } |
