diff options
Diffstat (limited to 'lldb/source/Core')
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 24 | ||||
-rw-r--r-- | lldb/source/Core/Module.cpp | 7 | ||||
-rw-r--r-- | lldb/source/Core/ModuleList.cpp | 28 |
3 files changed, 55 insertions, 4 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index f6cffec2b76..4cda3417de2 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -47,6 +47,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StopInfo.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/AnsiTerminal.h" @@ -170,15 +171,38 @@ Debugger::SetPropertyValue (const ExecutionContext *exe_ctx, const char *property_path, const char *value) { + bool is_load_script = strcmp(property_path,"target.load-script-from-symbol-file") == 0; + TargetSP target_sp; + LoadScriptFromSymFile load_script_old_value; + if (is_load_script && exe_ctx->GetTargetSP()) + { + target_sp = exe_ctx->GetTargetSP(); + load_script_old_value = target_sp->TargetProperties::GetLoadScriptFromSymbolFile(); + } Error error (Properties::SetPropertyValue (exe_ctx, op, property_path, value)); if (error.Success()) { + // FIXME it would be nice to have "on-change" callbacks for properties if (strcmp(property_path, g_properties[ePropertyPrompt].name) == 0) { const char *new_prompt = GetPrompt(); EventSP prompt_change_event_sp (new Event(CommandInterpreter::eBroadcastBitResetPrompt, new EventDataBytes (new_prompt))); GetCommandInterpreter().BroadcastEvent (prompt_change_event_sp); } + else if (is_load_script && target_sp && load_script_old_value == LoadScriptFromSymFile::eDefault) + { + if (target_sp->TargetProperties::GetLoadScriptFromSymbolFile() == LoadScriptFromSymFile::eYes) + { + std::list<Error> errors; + if (!target_sp->LoadScriptingResources(errors)) + { + for (auto error : errors) + { + GetErrorStream().Printf("unable to autoload scripting data: %s\n",error.AsCString()); + } + } + } + } } return error; } diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 7ce0c1b1f26..86057c17eff 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1243,7 +1243,7 @@ Module::LoadScriptingResourceInTarget (Target *target, Error& error) return false; } - bool shoud_load = target->TargetProperties::GetLoadScriptFromSymbolFile(); + LoadScriptFromSymFile shoud_load = target->TargetProperties::GetLoadScriptFromSymbolFile(); Debugger &debugger = target->GetDebugger(); const ScriptLanguage script_language = debugger.GetScriptLanguage(); @@ -1273,9 +1273,10 @@ Module::LoadScriptingResourceInTarget (Target *target, Error& error) FileSpec scripting_fspec (file_specs.GetFileSpecAtIndex(i)); if (scripting_fspec && scripting_fspec.Exists()) { - if (!shoud_load) + if (shoud_load != LoadScriptFromSymFile::eYes) { - error.SetErrorString("Target doesn't allow loading scripting resource. Please set target.load-script-from-symbol-file and retry."); + if (shoud_load == LoadScriptFromSymFile::eDefault) + error.SetErrorStringWithFormat("the setting target.load-script-from-symbol-file disallows loading script files - change it to yes or manually command script import %s",scripting_fspec.GetPath().c_str()); return false; } StreamString scripting_stream; diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 376d046eb61..96dbc4f6e62 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -1008,4 +1008,30 @@ ModuleList::RemoveSharedModuleIfOrphaned (const Module *module_ptr) return GetSharedModuleList ().RemoveIfOrphaned (module_ptr); } - +bool +ModuleList::LoadScriptingResourcesInTarget (Target *target, + std::list<Error>& errors, + bool continue_on_error) +{ + if (!target) + return false; + Mutex::Locker locker(m_modules_mutex); + for (auto module : m_modules) + { + Error error; + if (module) + { + module->LoadScriptingResourceInTarget(target, error); + if (error.Fail()) + { + error.SetErrorStringWithFormat("unable to load scripting data for module %s - error reported was %s", + module->GetFileSpec().GetFileNameStrippingExtension().GetCString(), + error.AsCString()); + errors.push_back(error); + } + if (!continue_on_error) + return false; + } + } + return errors.size() == 0; +} |