summaryrefslogtreecommitdiffstats
path: root/lldb/source/API/SBCommandInterpreter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/API/SBCommandInterpreter.cpp')
-rw-r--r--lldb/source/API/SBCommandInterpreter.cpp68
1 files changed, 67 insertions, 1 deletions
diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp
index bc8d6d34aa9..4e65c4f857c 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/lldb/source/API/SBCommandInterpreter.cpp
@@ -20,6 +20,7 @@
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBCommandReturnObject.h"
#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBExecutionContext.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBTarget.h"
#include "lldb/API/SBListener.h"
@@ -222,6 +223,13 @@ SBCommandInterpreter::GetIOHandlerControlSequence(char ch)
lldb::ReturnStatus
SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnObject &result, bool add_to_history)
{
+ SBExecutionContext sb_exe_ctx;
+ return HandleCommand (command_line, sb_exe_ctx, result, add_to_history);
+}
+
+lldb::ReturnStatus
+SBCommandInterpreter::HandleCommand (const char *command_line, SBExecutionContext &override_context, SBCommandReturnObject &result, bool add_to_history)
+{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
@@ -229,11 +237,21 @@ SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnOb
static_cast<void*>(m_opaque_ptr), command_line,
static_cast<void*>(result.get()), add_to_history);
+ ExecutionContext ctx, *ctx_ptr;
+ if (override_context.get())
+ {
+ ctx = override_context.get()->Lock(true);
+ ctx_ptr = &ctx;
+ }
+ else
+ ctx_ptr = nullptr;
+
+
result.Clear();
if (command_line && m_opaque_ptr)
{
result.ref().SetInteractive(false);
- m_opaque_ptr->HandleCommand (command_line, add_to_history ? eLazyBoolYes : eLazyBoolNo, result.ref());
+ m_opaque_ptr->HandleCommand (command_line, add_to_history ? eLazyBoolYes : eLazyBoolNo, result.ref(), ctx_ptr);
}
else
{
@@ -256,6 +274,54 @@ SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnOb
return result.GetStatus();
}
+void
+SBCommandInterpreter::HandleCommandsFromFile (lldb::SBFileSpec &file,
+ lldb::SBExecutionContext &override_context,
+ lldb::SBCommandInterpreterRunOptions &options,
+ lldb::SBCommandReturnObject result)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ if (log)
+ {
+ SBStream s;
+ file.GetDescription (s);
+ log->Printf ("SBCommandInterpreter(%p)::HandleCommandsFromFile (file=\"%s\", SBCommandReturnObject(%p))",
+ static_cast<void*>(m_opaque_ptr), s.GetData(),
+ static_cast<void*>(result.get()));
+ }
+
+ if (!m_opaque_ptr)
+ {
+ result->AppendError ("SBCommandInterpreter is not valid.");
+ result->SetStatus (eReturnStatusFailed);
+ return;
+ }
+
+ if (!file.IsValid())
+ {
+ SBStream s;
+ file.GetDescription (s);
+ result->AppendErrorWithFormat ("File is not valid: %s.", s.GetData());
+ result->SetStatus (eReturnStatusFailed);
+ }
+
+ FileSpec tmp_spec = file.ref();
+ ExecutionContext ctx, *ctx_ptr;
+ if (override_context.get())
+ {
+ ctx = override_context.get()->Lock(true);
+ ctx_ptr = &ctx;
+ }
+ else
+ ctx_ptr = nullptr;
+
+
+ m_opaque_ptr->HandleCommandsFromFile (tmp_spec, ctx_ptr, options.ref(), result.ref());
+
+}
+
+
int
SBCommandInterpreter::HandleCompletion (const char *current_line,
const char *cursor,
OpenPOWER on IntegriCloud