diff options
Diffstat (limited to 'source/API/SBDebugger.cpp')
-rw-r--r-- | source/API/SBDebugger.cpp | 84 |
1 files changed, 81 insertions, 3 deletions
diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp index 3cdb6bbfd5f99..d3294dab582de 100644 --- a/source/API/SBDebugger.cpp +++ b/source/API/SBDebugger.cpp @@ -26,6 +26,7 @@ #include "lldb/API/SBSourceManager.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" +#include "lldb/API/SBStructuredData.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" #include "lldb/API/SBTypeCategory.h" @@ -37,8 +38,10 @@ #include "lldb/API/SystemInitializerFull.h" #include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" #include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Core/StructuredDataImpl.h" #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Interpreter/Args.h" @@ -69,7 +72,7 @@ static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp, // TODO: mangle this differently for your system - on OSX, the first // underscore needs to be removed and the second one stays LLDBCommandPluginInit init_func = - (LLDBCommandPluginInit)dynlib.getAddressOfSymbol( + (LLDBCommandPluginInit)(uintptr_t)dynlib.getAddressOfSymbol( "_ZN4lldb16PluginInitializeENS_10SBDebuggerE"); if (init_func) { if (init_func(debugger_sb)) @@ -619,6 +622,20 @@ SBTarget SBDebugger::CreateTarget(const char *filename) { return sb_target; } +SBTarget SBDebugger::GetDummyTarget() { + SBTarget sb_target; + if (m_opaque_sp) { + sb_target.SetSP(m_opaque_sp->GetDummyTarget()->shared_from_this()); + } + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + if (log) + log->Printf( + "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)", + static_cast<void *>(m_opaque_sp.get()), + static_cast<void *>(sb_target.GetSP().get())); + return sb_target; +} + bool SBDebugger::DeleteTarget(lldb::SBTarget &target) { bool result = false; if (m_opaque_sp) { @@ -677,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)); @@ -774,6 +791,67 @@ void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) { sb_platform.GetName()); } +uint32_t SBDebugger::GetNumPlatforms() { + if (m_opaque_sp) { + // No need to lock, the platform list is thread safe + return m_opaque_sp->GetPlatformList().GetSize(); + } + return 0; +} + +SBPlatform SBDebugger::GetPlatformAtIndex(uint32_t idx) { + SBPlatform sb_platform; + if (m_opaque_sp) { + // No need to lock, the platform list is thread safe + sb_platform.SetSP(m_opaque_sp->GetPlatformList().GetAtIndex(idx)); + } + return sb_platform; +} + +uint32_t SBDebugger::GetNumAvailablePlatforms() { + uint32_t idx = 0; + while (true) { + if (!PluginManager::GetPlatformPluginNameAtIndex(idx)) { + break; + } + ++idx; + } + // +1 for the host platform, which should always appear first in the list. + return idx + 1; +} + +SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) { + SBStructuredData data; + auto platform_dict = llvm::make_unique<StructuredData::Dictionary>(); + llvm::StringRef name_str("name"), desc_str("description"); + + if (idx == 0) { + PlatformSP host_platform_sp(Platform::GetHostPlatform()); + platform_dict->AddStringItem( + name_str, host_platform_sp->GetPluginName().GetStringRef()); + platform_dict->AddStringItem( + desc_str, llvm::StringRef(host_platform_sp->GetDescription())); + } else if (idx > 0) { + const char *plugin_name = + PluginManager::GetPlatformPluginNameAtIndex(idx - 1); + if (!plugin_name) { + return data; + } + platform_dict->AddStringItem(name_str, llvm::StringRef(plugin_name)); + + const char *plugin_desc = + PluginManager::GetPlatformPluginDescriptionAtIndex(idx - 1); + if (!plugin_desc) { + return data; + } + platform_dict->AddStringItem(desc_str, llvm::StringRef(plugin_desc)); + } + + data.m_impl_up->SetObjectSP( + StructuredData::ObjectSP(platform_dict.release())); + return data; +} + void SBDebugger::DispatchInput(void *baton, const void *data, size_t data_len) { DispatchInput(data, data_len); } |