aboutsummaryrefslogtreecommitdiff
path: root/source/API/SBDebugger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/API/SBDebugger.cpp')
-rw-r--r--source/API/SBDebugger.cpp74
1 files changed, 73 insertions, 1 deletions
diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp
index 88c991b72054..10c0b7dea208 100644
--- a/source/API/SBDebugger.cpp
+++ b/source/API/SBDebugger.cpp
@@ -38,6 +38,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/State.h"
#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/Host/DynamicLibrary.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionGroupPlatform.h"
@@ -47,6 +48,41 @@
using namespace lldb;
using namespace lldb_private;
+
+static lldb::DynamicLibrarySP
+LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& error)
+{
+ lldb::DynamicLibrarySP dynlib_sp(new lldb_private::DynamicLibrary(spec));
+ if (dynlib_sp && dynlib_sp->IsValid())
+ {
+ typedef bool (*LLDBCommandPluginInit) (lldb::SBDebugger& debugger);
+
+ lldb::SBDebugger debugger_sb(debugger_sp);
+ // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) function.
+ // TODO: mangle this differently for your system - on OSX, the first underscore needs to be removed and the second one stays
+ LLDBCommandPluginInit init_func = dynlib_sp->GetSymbol<LLDBCommandPluginInit>("_ZN4lldb16PluginInitializeENS_10SBDebuggerE");
+ if (init_func)
+ {
+ if (init_func(debugger_sb))
+ return dynlib_sp;
+ else
+ error.SetErrorString("plug-in refused to load (lldb::PluginInitialize(lldb::SBDebugger) returned false)");
+ }
+ else
+ {
+ error.SetErrorString("plug-in is missing the required initialization: lldb::PluginInitialize(lldb::SBDebugger)");
+ }
+ }
+ else
+ {
+ if (spec.Exists())
+ error.SetErrorString("this file does not represent a loadable dylib");
+ else
+ error.SetErrorString("no such file");
+ }
+ return lldb::DynamicLibrarySP();
+}
+
void
SBDebugger::Initialize ()
{
@@ -57,7 +93,7 @@ SBDebugger::Initialize ()
SBCommandInterpreter::InitializeSWIG ();
- Debugger::Initialize();
+ Debugger::Initialize(LoadPlugin);
}
void
@@ -804,6 +840,42 @@ SBDebugger::SetSelectedTarget (SBTarget &sb_target)
}
}
+SBPlatform
+SBDebugger::GetSelectedPlatform()
+{
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ SBPlatform sb_platform;
+ DebuggerSP debugger_sp(m_opaque_sp);
+ if (debugger_sp)
+ {
+ sb_platform.SetSP(debugger_sp->GetPlatformList().GetSelectedPlatform());
+ }
+ if (log)
+ {
+ log->Printf ("SBDebugger(%p)::GetSelectedPlatform () => SBPlatform(%p): %s", m_opaque_sp.get(),
+ sb_platform.GetSP().get(), sb_platform.GetName());
+ }
+ return sb_platform;
+}
+
+void
+SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform)
+{
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ DebuggerSP debugger_sp(m_opaque_sp);
+ if (debugger_sp)
+ {
+ debugger_sp->GetPlatformList().SetSelectedPlatform(sb_platform.GetSP());
+ }
+ if (log)
+ {
+ log->Printf ("SBDebugger(%p)::SetSelectedPlatform (SBPlatform(%p) %s)", m_opaque_sp.get(),
+ sb_platform.GetSP().get(), sb_platform.GetName());
+ }
+}
+
void
SBDebugger::DispatchInput (void* baton, const void *data, size_t data_len)
{