summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-04-26 22:43:16 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-04-26 22:43:16 +0000
commit2b29b432d206ee706538b8dad54806d7649fb378 (patch)
treec1c288a9ee56edb568e0f4eb8925b5215ee50c97
parent3bf116c1a4f88d6e3f3fd0887453dea3569e0823 (diff)
downloadbcm5719-llvm-2b29b432d206ee706538b8dad54806d7649fb378.tar.gz
bcm5719-llvm-2b29b432d206ee706538b8dad54806d7649fb378.zip
[ScriptInterpreter] Move ownership into debugger (NFC)
This is part two of the change started in r359330. This patch moves the ownership of the script interpreter from the command interpreter into the debugger. I would've preferred to remove the lazy initialization, however the fact that the scripting language is set after the debugger is created makes that tricky. So for now this does exactly the same thing as when it was under the command interpreter. The result is that this patch is fully NFC. Differential revision: https://reviews.llvm.org/D61211 llvm-svn: 359354
-rw-r--r--lldb/include/lldb/Core/Debugger.h5
-rw-r--r--lldb/include/lldb/Interpreter/CommandInterpreter.h6
-rw-r--r--lldb/include/lldb/Interpreter/CommandObject.h1
-rw-r--r--lldb/source/API/SBBreakpoint.cpp2
-rw-r--r--lldb/source/API/SBBreakpointLocation.cpp2
-rw-r--r--lldb/source/API/SBBreakpointName.cpp2
-rw-r--r--lldb/source/API/SBTypeCategory.cpp4
-rw-r--r--lldb/source/Breakpoint/BreakpointOptions.cpp3
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverScripted.cpp5
-rw-r--r--lldb/source/Commands/CommandObjectBreakpointCommand.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp19
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectType.cpp14
-rw-r--r--lldb/source/Commands/CommandObjectWatchpointCommand.cpp7
-rw-r--r--lldb/source/Core/Debugger.cpp27
-rw-r--r--lldb/source/Core/FormatEntity.cpp2
-rw-r--r--lldb/source/Core/Module.cpp3
-rw-r--r--lldb/source/DataFormatters/TypeSummary.cpp2
-rw-r--r--lldb/source/DataFormatters/TypeSynthetic.cpp3
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp20
-rw-r--r--lldb/source/Interpreter/CommandObject.cpp2
-rw-r--r--lldb/source/Interpreter/CommandObjectScript.cpp2
-rw-r--r--lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp3
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp2
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp20
-rw-r--r--lldb/source/Target/Target.cpp11
-rw-r--r--lldb/source/Target/ThreadPlanPython.cpp5
29 files changed, 76 insertions, 104 deletions
diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h
index 1e032beb503..794a32b88cf 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -154,6 +154,8 @@ public:
return *m_command_interpreter_up;
}
+ ScriptInterpreter *GetScriptInterpreter(bool can_create = true);
+
lldb::ListenerSP GetListener() { return m_listener_sp; }
// This returns the Debugger's scratch source manager. It won't be able to
@@ -395,6 +397,9 @@ protected:
// source file cache.
std::unique_ptr<CommandInterpreter> m_command_interpreter_up;
+ lldb::ScriptInterpreterSP m_script_interpreter_sp;
+ std::recursive_mutex m_script_interpreter_mutex;
+
IOHandlerStack m_input_reader_stack;
llvm::StringMap<std::weak_ptr<llvm::raw_ostream>> m_log_streams;
std::shared_ptr<llvm::raw_ostream> m_log_callback_stream_sp;
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index e17fc3555a5..70f21d45a1e 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -386,10 +386,6 @@ public:
int GetOptionArgumentPosition(const char *in_string);
- ScriptInterpreter *GetScriptInterpreter(bool can_create = true);
-
- void SetScriptInterpreter();
-
void SkipLLDBInitFiles(bool skip_lldbinit_files) {
m_skip_lldbinit_files = skip_lldbinit_files;
}
@@ -573,8 +569,6 @@ private:
CommandHistory m_command_history;
std::string m_repeat_command; // Stores the command that will be executed for
// an empty command string.
- lldb::ScriptInterpreterSP m_script_interpreter_sp;
- std::recursive_mutex m_script_interpreter_mutex;
lldb::IOHandlerSP m_command_io_handler_sp;
char m_comment_char;
bool m_batch_command_mode;
diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h
index 02b094cf553..31f7f126a9f 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -121,6 +121,7 @@ public:
GetArgumentDescriptionAsCString(const lldb::CommandArgumentType arg_type);
CommandInterpreter &GetCommandInterpreter() { return m_interpreter; }
+ Debugger &GetDebugger();
virtual llvm::StringRef GetHelp();
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index b97bb0f84b2..45eaea6b618 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -602,7 +602,6 @@ void SBBreakpoint::SetScriptCallbackFunction(
BreakpointOptions *bp_options = bkpt_sp->GetOptions();
bkpt_sp->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallbackFunction(bp_options,
callback_function_name);
@@ -623,7 +622,6 @@ SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
Status error =
bkpt_sp->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallback(bp_options, callback_body_text);
sb_error.SetError(error);
diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp
index f3ee8201afd..56068750709 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -220,7 +220,6 @@ void SBBreakpointLocation::SetScriptCallbackFunction(
loc_sp->GetBreakpoint()
.GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallbackFunction(bp_options,
callback_function_name);
@@ -243,7 +242,6 @@ SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) {
loc_sp->GetBreakpoint()
.GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallback(bp_options, callback_body_text);
sb_error.SetError(error);
diff --git a/lldb/source/API/SBBreakpointName.cpp b/lldb/source/API/SBBreakpointName.cpp
index 63439a1f890..1c794fca8ca 100644
--- a/lldb/source/API/SBBreakpointName.cpp
+++ b/lldb/source/API/SBBreakpointName.cpp
@@ -579,7 +579,6 @@ void SBBreakpointName::SetScriptCallbackFunction(
BreakpointOptions &bp_options = bp_name->GetOptions();
m_impl_up->GetTarget()
->GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallbackFunction(&bp_options,
callback_function_name);
@@ -603,7 +602,6 @@ SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text) {
Status error =
m_impl_up->GetTarget()
->GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallback(&bp_options, callback_body_text);
sb_error.SetError(error);
diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp
index a41b02acf68..c2ec8cf8522 100644
--- a/lldb/source/API/SBTypeCategory.cpp
+++ b/lldb/source/API/SBTypeCategory.cpp
@@ -425,7 +425,7 @@ bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name,
DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j);
if (debugger_sp) {
ScriptInterpreter *interpreter_ptr =
- debugger_sp->GetCommandInterpreter().GetScriptInterpreter();
+ debugger_sp->GetScriptInterpreter();
if (interpreter_ptr) {
std::string output;
if (interpreter_ptr->GenerateTypeScriptFunction(input, output,
@@ -549,7 +549,7 @@ bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name,
DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j);
if (debugger_sp) {
ScriptInterpreter *interpreter_ptr =
- debugger_sp->GetCommandInterpreter().GetScriptInterpreter();
+ debugger_sp->GetScriptInterpreter();
if (interpreter_ptr) {
std::string output;
if (interpreter_ptr->GenerateTypeSynthClass(input, output,
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 98b0b57a8c7..16d0bd43b91 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -316,8 +316,7 @@ std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
if (cmd_data_up->interpreter == eScriptLanguageNone)
bp_options->SetCommandDataCallback(cmd_data_up);
else {
- ScriptInterpreter *interp =
- target.GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ ScriptInterpreter *interp = target.GetDebugger().GetScriptInterpreter();
if (!interp) {
error.SetErrorStringWithFormat(
"Can't set script commands - no script interpreter");
diff --git a/lldb/source/Breakpoint/BreakpointResolverScripted.cpp b/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
index e28f1790ab9..ae9775738f2 100644
--- a/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -46,7 +46,6 @@ void BreakpointResolverScripted::CreateImplementationIfNeeded() {
if (m_breakpoint) {
TargetSP target_sp = m_breakpoint->GetTargetSP();
ScriptInterpreter *script_interp = target_sp->GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (!script_interp)
return;
@@ -105,7 +104,6 @@ BreakpointResolverScripted::CreateFromStructuredData(
}
ScriptInterpreter *script_interp = bkpt->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
return new BreakpointResolverScripted(bkpt, class_name, depth, args_data_impl,
*script_interp);
@@ -122,8 +120,7 @@ BreakpointResolverScripted::SerializeToStructuredData() {
}
ScriptInterpreter *BreakpointResolverScripted::GetScriptInterpreter() {
- return m_breakpoint->GetTarget().GetDebugger().GetCommandInterpreter()
- .GetScriptInterpreter();
+ return m_breakpoint->GetTarget().GetDebugger().GetScriptInterpreter();
}
Searcher::CallbackReturn
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index 411c9ef8244..9ae1065ecfb 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -422,7 +422,7 @@ protected:
// to set or collect command callback. Otherwise, call the methods
// associated with this object.
if (m_options.m_use_script_language) {
- ScriptInterpreter *script_interp = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *script_interp = GetDebugger().GetScriptInterpreter();
// Special handling for one-liner specified inline.
if (m_options.m_use_one_liner) {
script_interp->SetBreakpointCommandCallback(
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index dabc5c802b7..45427753b42 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1246,7 +1246,7 @@ public:
if (m_fetched_help_long)
return CommandObjectRaw::GetHelpLong();
- ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
if (!scripter)
return CommandObjectRaw::GetHelpLong();
@@ -1261,7 +1261,7 @@ public:
protected:
bool DoExecute(llvm::StringRef raw_command_line,
CommandReturnObject &result) override {
- ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
Status error;
@@ -1304,7 +1304,7 @@ public:
StreamString stream;
stream.Printf("For more information run 'help %s'", name.c_str());
SetHelp(stream.GetString());
- if (ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter())
+ if (ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter())
GetFlags().Set(scripter->GetFlagsForCommandObject(cmd_obj_sp));
}
@@ -1319,7 +1319,7 @@ public:
llvm::StringRef GetHelp() override {
if (m_fetched_help_short)
return CommandObjectRaw::GetHelp();
- ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
if (!scripter)
return CommandObjectRaw::GetHelp();
std::string docstring;
@@ -1335,7 +1335,7 @@ public:
if (m_fetched_help_long)
return CommandObjectRaw::GetHelpLong();
- ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
if (!scripter)
return CommandObjectRaw::GetHelpLong();
@@ -1350,7 +1350,7 @@ public:
protected:
bool DoExecute(llvm::StringRef raw_command_line,
CommandReturnObject &result) override {
- ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
Status error;
@@ -1489,7 +1489,7 @@ protected:
// won't stomp on each other (wrt to execution contents, options, and
// more)
m_exe_ctx.Clear();
- if (m_interpreter.GetScriptInterpreter()->LoadScriptingModule(
+ if (GetDebugger().GetScriptInterpreter()->LoadScriptingModule(
entry.c_str(), m_options.m_allow_reload, init_session, error)) {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
@@ -1630,7 +1630,7 @@ protected:
std::string &data) override {
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
StringList lines;
@@ -1715,8 +1715,7 @@ protected:
}
}
} else {
- ScriptInterpreter *interpreter =
- GetCommandInterpreter().GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (!interpreter) {
result.AppendError("cannot find ScriptInterpreter");
result.SetStatus(eReturnStatusFailed);
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 9d82d7533fe..ab6a07952f1 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -890,7 +890,7 @@ bool CommandObjectFrameRecognizerAdd::DoExecute(Args &command,
return false;
}
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter &&
!interpreter->CheckObjectExists(m_options.m_class_name.c_str())) {
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 1552d1a189e..e41733f2711 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -612,7 +612,7 @@ protected:
result.AppendErrorWithFormat("empty class name for scripted step.");
result.SetStatus(eReturnStatusFailed);
return false;
- } else if (!m_interpreter.GetScriptInterpreter()->CheckObjectExists(
+ } else if (!GetDebugger().GetScriptInterpreter()->CheckObjectExists(
m_options.m_class_name.c_str())) {
result.AppendErrorWithFormat(
"class for scripted step: \"%s\" does not exist.",
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index 9f0770a1a56..64150f0b0bb 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -180,7 +180,7 @@ public:
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
StringList lines;
lines.SplitIntoLines(data);
@@ -192,7 +192,7 @@ public:
options_ptr); // this will ensure that we get rid of the pointer
// when going out of scope
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
std::string funct_name_str;
if (interpreter->GenerateTypeScriptFunction(lines,
@@ -425,7 +425,7 @@ protected:
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
StringList lines;
lines.SplitIntoLines(data);
@@ -437,7 +437,7 @@ protected:
options_ptr); // this will ensure that we get rid of the pointer
// when going out of scope
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
std::string class_name_str;
if (interpreter->GenerateTypeSynthClass(lines, class_name_str)) {
@@ -1346,7 +1346,7 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary(
script_format = std::make_shared<ScriptSummaryFormat>(
m_options.m_flags, funct_name, code.c_str());
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter && !interpreter->CheckObjectExists(funct_name))
result.AppendWarningWithFormat(
@@ -1356,7 +1356,7 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary(
} else if (!m_options.m_python_script
.empty()) // we have a quick 1-line script, just use it
{
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (!interpreter) {
result.AppendError("script interpreter missing - unable to generate "
"function wrapper.\n");
@@ -2357,7 +2357,7 @@ bool CommandObjectTypeSynthAdd::Execute_PythonClass(
entry.reset(impl);
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter &&
!interpreter->CheckObjectExists(impl->GetPythonClassName()))
diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
index 29c85924c44..8894d2cea81 100644
--- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -442,7 +442,7 @@ protected:
if (m_options.m_use_script_language) {
// Special handling for one-liner specified inline.
if (m_options.m_use_one_liner) {
- m_interpreter.GetScriptInterpreter()->SetWatchpointCommandCallback(
+ GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback(
wp_options, m_options.m_one_liner.c_str());
}
// Special handling for using a Python function by name instead of
@@ -452,10 +452,11 @@ protected:
else if (!m_options.m_function_name.empty()) {
std::string oneliner(m_options.m_function_name);
oneliner += "(frame, wp, internal_dict)";
- m_interpreter.GetScriptInterpreter()->SetWatchpointCommandCallback(
+ GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback(
wp_options, oneliner.c_str());
} else {
- m_interpreter.GetScriptInterpreter()
+ GetDebugger()
+ .GetScriptInterpreter()
->CollectDataForWatchpointCommandCallback(wp_options, result);
}
} else {
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 9c56905a2ba..7f180c1575a 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -767,8 +767,8 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
m_source_manager_up(), m_source_file_cache(),
m_command_interpreter_up(
llvm::make_unique<CommandInterpreter>(*this, false)),
- m_input_reader_stack(), m_instance_name(), m_loaded_plugins(),
- m_event_handler_thread(), m_io_handler_thread(),
+ m_script_interpreter_sp(), m_input_reader_stack(), m_instance_name(),
+ m_loaded_plugins(), m_event_handler_thread(), m_io_handler_thread(),
m_sync_broadcaster(nullptr, "lldb.debugger.sync"),
m_forward_listener_sp(), m_clear_once() {
char instance_cstr[256];
@@ -905,12 +905,10 @@ void Debugger::SetOutputFileHandle(FILE *fh, bool tranfer_ownership) {
if (!out_file.IsValid())
out_file.SetStream(stdout, false);
- // do not create the ScriptInterpreter just for setting the output file
- // handle as the constructor will know how to do the right thing on its own
- const bool can_create = false;
- ScriptInterpreter *script_interpreter =
- GetCommandInterpreter().GetScriptInterpreter(can_create);
- if (script_interpreter)
+ // Do not create the ScriptInterpreter just for setting the output file
+ // handle as the constructor will know how to do the right thing on its own.
+ if (ScriptInterpreter *script_interpreter =
+ GetScriptInterpreter(/*can_create=*/false))
script_interpreter->ResetOutputFileHandle(fh);
}
@@ -1288,6 +1286,19 @@ bool Debugger::EnableLog(llvm::StringRef channel,
error_stream);
}
+ScriptInterpreter *Debugger::GetScriptInterpreter(bool can_create) {
+ std::lock_guard<std::recursive_mutex> locker(m_script_interpreter_mutex);
+
+ if (!m_script_interpreter_sp) {
+ if (!can_create)
+ return nullptr;
+ m_script_interpreter_sp = PluginManager::GetScriptInterpreterForLanguage(
+ GetScriptLanguage(), *this);
+ }
+
+ return m_script_interpreter_sp.get();
+}
+
SourceManager &Debugger::GetSourceManager() {
if (!m_source_manager_up)
m_source_manager_up = llvm::make_unique<SourceManager>(shared_from_this());
diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp
index 78c639aa3e8..6ebe0e22096 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -410,7 +410,7 @@ static bool RunScriptFormatKeyword(Stream &s, const SymbolContext *sc,
if (target) {
ScriptInterpreter *script_interpreter =
- target->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ target->GetDebugger().GetScriptInterpreter();
if (script_interpreter) {
Status error;
std::string script_output;
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 9e7be79a364..153d5a74093 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1545,8 +1545,7 @@ bool Module::LoadScriptingResourceInTarget(Target *target, Status &error,
const uint32_t num_specs = file_specs.GetSize();
if (num_specs) {
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
if (script_interpreter) {
for (uint32_t i = 0; i < num_specs; ++i) {
FileSpec scripting_fspec(file_specs.GetFileSpecAtIndex(i));
diff --git a/lldb/source/DataFormatters/TypeSummary.cpp b/lldb/source/DataFormatters/TypeSummary.cpp
index a0bf2111ba8..1a6496080d8 100644
--- a/lldb/source/DataFormatters/TypeSummary.cpp
+++ b/lldb/source/DataFormatters/TypeSummary.cpp
@@ -177,7 +177,7 @@ bool ScriptSummaryFormat::FormatObject(ValueObject *valobj, std::string &retval,
}
ScriptInterpreter *script_interpreter =
- target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ target_sp->GetDebugger().GetScriptInterpreter();
if (!script_interpreter) {
retval.assign("error: no ScriptInterpreter");
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp b/lldb/source/DataFormatters/TypeSynthetic.cpp
index 89ebd919727..c40aed1f792 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -137,8 +137,7 @@ ScriptedSyntheticChildren::FrontEnd::FrontEnd(std::string pclass,
if (!target_sp)
return;
- m_interpreter =
- target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ m_interpreter = target_sp->GetDebugger().GetScriptInterpreter();
if (m_interpreter != NULL)
m_wrapper_sp = m_interpreter->CreateSyntheticScriptedProvider(
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 35596c86435..78230e54dcd 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -130,7 +130,7 @@ CommandInterpreter::CommandInterpreter(Debugger &debugger,
IOHandlerDelegate(IOHandlerDelegate::Completion::LLDBCommand),
m_debugger(debugger), m_synchronous_execution(synchronous_execution),
m_skip_lldbinit_files(false), m_skip_app_init_files(false),
- m_script_interpreter_sp(), m_command_io_handler_sp(), m_comment_char('#'),
+ m_command_io_handler_sp(), m_comment_char('#'),
m_batch_command_mode(false), m_truncation_warning(eNoTruncation),
m_command_source_depth(0), m_num_errors(0), m_quit_requested(false),
m_stopped_for_crash(false) {
@@ -433,9 +433,6 @@ void CommandInterpreter::Initialize() {
void CommandInterpreter::Clear() {
m_command_io_handler_sp.reset();
-
- if (m_script_interpreter_sp)
- m_script_interpreter_sp->Clear();
}
const char *CommandInterpreter::ProcessEmbeddedScriptCommands(const char *arg) {
@@ -2498,18 +2495,6 @@ void CommandInterpreter::HandleCommandsFromFile(
debugger.SetAsyncExecution(old_async_execution);
}
-ScriptInterpreter *CommandInterpreter::GetScriptInterpreter(bool can_create) {
- std::lock_guard<std::recursive_mutex> locker(m_script_interpreter_mutex);
- if (!m_script_interpreter_sp) {
- if (!can_create)
- return nullptr;
- lldb::ScriptLanguage script_lang = GetDebugger().GetScriptLanguage();
- m_script_interpreter_sp =
- PluginManager::GetScriptInterpreterForLanguage(script_lang, m_debugger);
- }
- return m_script_interpreter_sp.get();
-}
-
bool CommandInterpreter::GetSynchronous() { return m_synchronous_execution; }
void CommandInterpreter::SetSynchronous(bool value) {
@@ -2884,7 +2869,8 @@ bool CommandInterpreter::IOHandlerInterrupt(IOHandler &io_handler) {
}
}
- ScriptInterpreter *script_interpreter = GetScriptInterpreter(false);
+ ScriptInterpreter *script_interpreter =
+ m_debugger.GetScriptInterpreter(false);
if (script_interpreter) {
if (script_interpreter->Interrupt())
return true;
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index 1016d7222da..841c34b7ce7 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -49,6 +49,8 @@ CommandObject::CommandObject(CommandInterpreter &interpreter, llvm::StringRef na
CommandObject::~CommandObject() {}
+Debugger &CommandObject::GetDebugger() { return m_interpreter.GetDebugger(); }
+
llvm::StringRef CommandObject::GetHelp() { return m_cmd_help_short; }
llvm::StringRef CommandObject::GetHelpLong() { return m_cmd_help_long; }
diff --git a/lldb/source/Interpreter/CommandObjectScript.cpp b/lldb/source/Interpreter/CommandObjectScript.cpp
index 758dddcb52d..edb1f67e7b3 100644
--- a/lldb/source/Interpreter/CommandObjectScript.cpp
+++ b/lldb/source/Interpreter/CommandObjectScript.cpp
@@ -50,7 +50,7 @@ bool CommandObjectScript::DoExecute(llvm::StringRef command,
return false;
}
- ScriptInterpreter *script_interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *script_interpreter = GetDebugger().GetScriptInterpreter();
if (script_interpreter == nullptr) {
result.AppendError("no script interpreter");
diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
index ddf33bf015c..874ca85fb43 100644
--- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
+++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
@@ -81,8 +81,7 @@ OperatingSystemPython::OperatingSystemPython(lldb_private::Process *process,
TargetSP target_sp = process->CalculateTarget();
if (!target_sp)
return;
- m_interpreter =
- target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ m_interpreter = target_sp->GetDebugger().GetScriptInterpreter();
if (m_interpreter) {
std::string os_plugin_class_name(
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 5602c0faf08..a4b17a93d7d 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -105,7 +105,7 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
std::replace(module_basename.begin(), module_basename.end(),
'-', '_');
ScriptInterpreter *script_interpreter =
- target->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ target->GetDebugger().GetScriptInterpreter();
if (script_interpreter &&
script_interpreter->IsReservedWord(
module_basename.c_str())) {
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 15975f6825d..890b5366020 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -377,7 +377,7 @@ uint32_t ProcessGDBRemote::GetPluginVersion() { return 1; }
bool ProcessGDBRemote::ParsePythonTargetDefinition(
const FileSpec &target_definition_fspec) {
ScriptInterpreter *interpreter =
- GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ GetTarget().GetDebugger().GetScriptInterpreter();
Status error;
StructuredData::ObjectSP module_object_sp(
interpreter->LoadPluginModule(target_definition_fspec, error));
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index eabbdcc373a..a4959265fad 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1285,9 +1285,8 @@ void ScriptInterpreterPythonImpl::SetBreakpointCommandCallbackFunction(
std::string oneliner("return ");
oneliner += function_name;
oneliner += "(frame, bp_loc, internal_dict)";
- m_debugger.GetCommandInterpreter()
- .GetScriptInterpreter()
- ->SetBreakpointCommandCallback(bp_options, oneliner.c_str());
+ m_debugger.GetScriptInterpreter()->SetBreakpointCommandCallback(
+ bp_options, oneliner.c_str());
}
Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
@@ -1862,8 +1861,7 @@ StructuredData::ObjectSP ScriptInterpreterPythonImpl::CreateScriptedThreadPlan(
return StructuredData::ObjectSP();
Debugger &debugger = thread_plan_sp->GetTarget().GetDebugger();
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
ScriptInterpreterPythonImpl *python_interpreter =
static_cast<ScriptInterpreterPythonImpl *>(script_interpreter);
@@ -1967,8 +1965,7 @@ ScriptInterpreterPythonImpl::CreateScriptedBreakpointResolver(
return StructuredData::GenericSP();
Debugger &debugger = bkpt_sp->GetTarget().GetDebugger();
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
ScriptInterpreterPythonImpl *python_interpreter =
static_cast<ScriptInterpreterPythonImpl *>(script_interpreter);
@@ -2083,8 +2080,7 @@ ScriptInterpreterPythonImpl::CreateSyntheticScriptedProvider(
return StructuredData::ObjectSP();
Debugger &debugger = target->GetDebugger();
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
ScriptInterpreterPythonImpl *python_interpreter =
(ScriptInterpreterPythonImpl *)script_interpreter;
@@ -2262,8 +2258,7 @@ bool ScriptInterpreterPythonImpl::BreakpointCallbackFunction(
return true;
Debugger &debugger = target->GetDebugger();
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
ScriptInterpreterPythonImpl *python_interpreter =
(ScriptInterpreterPythonImpl *)script_interpreter;
@@ -2313,8 +2308,7 @@ bool ScriptInterpreterPythonImpl::WatchpointCallbackFunction(
return true;
Debugger &debugger = target->GetDebugger();
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
ScriptInterpreterPythonImpl *python_interpreter =
(ScriptInterpreterPythonImpl *)script_interpreter;
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index b173a68f381..5fbe33b5557 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -615,13 +615,10 @@ Target::CreateScriptedBreakpoint(const llvm::StringRef class_name,
StructuredDataImpl *extra_args_impl = new StructuredDataImpl();
if (extra_args_sp)
extra_args_impl->SetObjectSP(extra_args_sp);
-
- BreakpointResolverSP resolver_sp(new
- BreakpointResolverScripted(nullptr, class_name,
- depth,
- extra_args_impl,
- *GetDebugger().GetCommandInterpreter()
- .GetScriptInterpreter()));
+
+ BreakpointResolverSP resolver_sp(new BreakpointResolverScripted(
+ nullptr, class_name, depth, extra_args_impl,
+ *GetDebugger().GetScriptInterpreter()));
return CreateBreakpoint(filter_sp, resolver_sp, internal, false, true);
}
diff --git a/lldb/source/Target/ThreadPlanPython.cpp b/lldb/source/Target/ThreadPlanPython.cpp
index baf49ed4776..8b30c4ea7cb 100644
--- a/lldb/source/Target/ThreadPlanPython.cpp
+++ b/lldb/source/Target/ThreadPlanPython.cpp
@@ -60,7 +60,6 @@ void ThreadPlanPython::DidPush() {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
m_implementation_sp = script_interp->CreateScriptedThreadPlan(
@@ -80,7 +79,6 @@ bool ThreadPlanPython::ShouldStop(Event *event_ptr) {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
@@ -104,7 +102,6 @@ bool ThreadPlanPython::IsPlanStale() {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
@@ -128,7 +125,6 @@ bool ThreadPlanPython::DoPlanExplainsStop(Event *event_ptr) {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
@@ -167,7 +163,6 @@ lldb::StateType ThreadPlanPython::GetPlanRunState() {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
OpenPOWER on IntegriCloud