summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/API/SBDebugger.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 3cdb6bbfd5f..cf6a27a049b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/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"
@@ -774,6 +777,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);
}
OpenPOWER on IntegriCloud