27#include "llvm/ADT/StringRef.h"
37 llvm::StringRef plugin_name) {
38 DynamicLoaderCreateInstance create_callback =
nullptr;
39 if (!plugin_name.empty()) {
42 if (create_callback) {
43 std::unique_ptr<DynamicLoader> instance_up(
44 create_callback(process,
true));
46 return instance_up.release();
54 std::unique_ptr<DynamicLoader> instance_up(
55 create_callback(process,
false));
57 return instance_up.release();
82 ModuleSpec module_spec(executable->GetFileSpec(),
83 executable->GetArchitecture());
84 auto module_sp = std::make_shared<Module>(module_spec);
88 if (module_sp && module_sp->GetUUID().IsValid() &&
89 executable->GetUUID().IsValid()) {
90 if (module_sp->GetUUID() != executable->GetUUID())
92 }
else if (executable->FileHasChanged()) {
111 bool base_addr_is_offset) {
117 bool base_addr_is_offset) {
131 assert(sections &&
"SectionList missing from unloaded module.");
133 const size_t num_sections = sections->
GetSize();
134 for (
size_t i = 0; i < num_sections; ++i) {
144 ObjectFile *obj_file = module->GetObjectFile();
145 if (obj_file !=
nullptr) {
168 bool base_addr_is_offset) {
171 base_addr_is_offset);
179 llvm::StringRef name) {
182 snprintf(namebuf,
sizeof(namebuf),
"memory-image-0x%" PRIx64, addr);
190 bool value_is_offset,
bool force_symbol_search,
bool notify) {
191 ModuleSP memory_module_sp;
199 if (!uuid.
IsValid() && !value_is_offset) {
202 if (memory_module_sp)
203 uuid = memory_module_sp->GetUUID();
215 if (force_symbol_search &&
216 (!module_sp || !module_sp->GetSymbolFileFileSpec())) {
219 module_sp = std::make_shared<Module>(module_spec);
227 if (!memory_module_sp)
229 if (memory_module_sp)
230 module_sp = memory_module_sp;
234 if (module_sp.get()) {
241 bool changed =
false;
242 if (module_sp->GetObjectFile()) {
244 LLDB_LOGF(log,
"Loading binary UUID %s at %s 0x%" PRIx64,
246 value_is_offset ?
"offset" :
"address", value);
247 module_sp->SetLoadAddress(target, value, value_is_offset, changed);
251 LLDB_LOGF(log,
"Loading binary UUID %s at file address",
253 module_sp->SetLoadAddress(target, 0,
true ,
258 LLDB_LOGF(log,
"Loading binary UUID %s from memory at address 0x%" PRIx64,
260 module_sp->SetLoadAddress(target, 0,
true , changed);
265 added_module.
Append(module_sp,
false);
269 LLDB_LOGF(log,
"Unable to find binary with UUID %s and load it at "
272 value_is_offset ?
"offset" :
"address", value);
286 return (int64_t)value;
static llvm::raw_ostream & error(Stream &strm)
static ModuleSP ReadUnnamedMemoryModule(Process *process, addr_t addr, llvm::StringRef name)
#define LLDB_LOGF(log,...)
bool IsValid() const
Tests if this ArchSpec is valid.
A plug-in interface definition class for dynamic loaders.
void LoadOperatingSystemPlugin(bool flush)
void SetStopWhenImagesChange(bool stop)
Set whether the process should stop when images change.
static lldb::ModuleSP LoadBinaryWithUUIDAndAddress(Process *process, llvm::StringRef name, UUID uuid, lldb::addr_t value, bool value_is_offset, bool force_symbol_search, bool notify)
Find/load a binary into lldb given a UUID and the address where it is loaded in memory,...
int64_t ReadUnsignedIntWithSizeInBytes(lldb::addr_t addr, int size_in_bytes)
lldb::addr_t ReadPointer(lldb::addr_t addr)
Process * m_process
The process that this dynamic loader plug-in is tracking.
void UpdateLoadedSectionsCommon(lldb::ModuleSP module, lldb::addr_t base_addr, bool base_addr_is_offset)
lldb::ModuleSP GetTargetExecutable()
Checks to see if the target module has changed, updates the target accordingly and returns the target...
bool GetStopWhenImagesChange() const
Get whether the process should stop when images change.
virtual lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset)
Locates or creates a module given by file and updates/loads the resulting module at the virtual base ...
virtual void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset)
Updates the load address of every allocatable section in module.
DynamicLoader(Process *process)
Construct with a process.
const lldb_private::SectionList * GetSectionListFromModule(const lldb::ModuleSP module) const
static DynamicLoader * FindPlugin(Process *process, llvm::StringRef plugin_name)
Find a dynamic loader plugin for a given process.
void UnloadSectionsCommon(const lldb::ModuleSP module)
lldb::ModuleSP FindModuleViaTarget(const FileSpec &file)
virtual void UnloadSections(const lldb::ModuleSP module)
Removes the loaded sections from the target in module.
static FileSystem & Instance()
A collection class for Module objects.
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
A plug-in interface definition class for object file parsers.
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
static DynamicLoaderCreateInstance GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx)
static DynamicLoaderCreateInstance GetDynamicLoaderCreateCallbackForPluginName(llvm::StringRef name)
void SetStopOnSharedLibraryEvents(bool stop)
bool GetStopOnSharedLibraryEvents() const
A plug-in interface definition class for debugging a process.
void LoadOperatingSystemPlugin(bool flush)
uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error)
Reads an unsigned integer of the specified byte size from process memory.
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
lldb::ModuleSP ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr, size_t size_to_read=512)
Target & GetTarget()
Get the target object pointer for this module.
lldb::SectionSP GetSectionAtIndex(size_t idx) const
static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, Status &error, bool force_lookup=true, bool copy_executable=true)
void ModulesDidLoad(ModuleList &module_list)
Module * GetExecutableModulePointer()
bool SetSectionUnloaded(const lldb::SectionSP §ion_sp)
lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify, Status *error_ptr=nullptr)
Find a binary on the system and return its Module, or return an existing Module that is already in th...
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false, bool merge=true)
Set the architecture for this target.
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
lldb::PlatformSP GetPlatform()
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
void SetExecutableModule(lldb::ModuleSP &module_sp, LoadDependentFiles load_dependent_files=eLoadDependentsDefault)
Set the main executable module.
std::string GetAsString(llvm::StringRef separator="-") const
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.