diff options
Diffstat (limited to 'lldb/source/Core')
| -rw-r--r-- | lldb/source/Core/Debugger.cpp | 27 | ||||
| -rw-r--r-- | lldb/source/Core/FormatEntity.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Core/Module.cpp | 3 |
3 files changed, 21 insertions, 11 deletions
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)); |

