diff options
| author | Pavel Labath <pavel@labath.sk> | 2022-03-09 18:12:28 +0100 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2022-03-09 18:13:45 +0100 |
| commit | d65e6ff2f1a480df52b275cadc9bc3e7b31d4fb6 (patch) | |
| tree | f5269b8e7976e580291a5f105ee72bc058455e3e /lldb/source/API/SBDebugger.cpp | |
| parent | 28f67aed9d7f42529e34b2d4252b089975be3698 (diff) | |
| download | llvm-d65e6ff2f1a480df52b275cadc9bc3e7b31d4fb6.zip llvm-d65e6ff2f1a480df52b275cadc9bc3e7b31d4fb6.tar.gz llvm-d65e6ff2f1a480df52b275cadc9bc3e7b31d4fb6.tar.bz2 | |
Revert "[lldb] Remove the global platform list"
It makes module dependencies loopier.
This reverts commits 49cffe3c7fab74252d4b6a073303c803dc1659f0 and
ffb9429b6f3c29ab4687b96fd85374924c98ad16.
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"); } |
