Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py =================================================================== --- lldb/examples/python/scripted_process/crashlog_scripted_process.py +++ lldb/examples/python/scripted_process/crashlog_scripted_process.py @@ -31,12 +31,10 @@ if image not in self.loaded_images: if image.uuid == uuid.UUID(int=0): continue - err = image.add_module(self.target) - if err: - # Append to SBCommandReturnObject - print(err) - else: - self.loaded_images.append(image) + for section in image.section_infos: + if section.start_addr and section.name == "__TEXT": + self.loaded_images.append({"uuid": str(image.uuid), + "load_addr": section.start_addr}) for thread in crash_log.threads: if self.load_all_images: Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp =================================================================== --- lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp +++ lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp @@ -11,7 +11,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" - +#include "lldb/Core/Progress.h" #include "lldb/Host/OptionParser.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -19,6 +19,7 @@ #include "lldb/Interpreter/OptionGroupBoolean.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Interpreter/ScriptedMetadata.h" +#include "lldb/Symbol/LocateSymbolFile.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Queue.h" #include "lldb/Target/RegisterContext.h" @@ -410,15 +411,18 @@ StructuredData::ArraySP loaded_images_sp = GetInterface().GetLoadedImages(); - if (!loaded_images_sp || !loaded_images_sp->GetSize()) + size_t num_image_to_load = loaded_images_sp->GetSize(); + if (!loaded_images_sp || !num_image_to_load) return ScriptedInterface::ErrorWithMessage( LLVM_PRETTY_FUNCTION, "No loaded images.", error); ModuleList module_list; Target &target = GetTarget(); - auto reload_image = [&target, &module_list, &error_with_message]( - StructuredData::Object *obj) -> bool { + Progress progress("Fetching external dependencies", num_image_to_load); + auto reload_image = [&target, &module_list, &error_with_message, + &progress](StructuredData::Object *obj) -> bool { + progress.Increment(); StructuredData::Dictionary *dict = obj->GetAsDictionary(); if (!dict) @@ -445,6 +449,13 @@ } module_spec.GetArchitecture() = target.GetArchitecture(); + Status error; + Symbols::DownloadObjectAndSymbolFile(module_spec, error, true); + if (error.Fail() || + !FileSystem::Instance().Exists(module_spec.GetFileSpec())) { + return error_with_message(error.AsCString()); + } + ModuleSP module_sp = target.GetOrCreateModule(module_spec, true /* notify */); @@ -469,9 +480,11 @@ if (!changed && !module_sp->GetObjectFile()) return error_with_message("Couldn't set the load address for module."); - dict->GetValueForKeyAsString("path", value); - FileSpec objfile(value); - module_sp->SetFileSpecAndObjectName(objfile, objfile.GetFilename()); + if (has_path) { + dict->GetValueForKeyAsString("path", value); + FileSpec objfile(value); + module_sp->SetFileSpecAndObjectName(objfile, objfile.GetFilename()); + } return module_list.AppendIfNeeded(module_sp); };