51 assert(proc !=
nullptr);
53 ModuleSP module = proc->GetTarget().GetExecutableModule();
54 assert(module.get() !=
nullptr);
57 assert(exe !=
nullptr);
60 assert(symtab !=
nullptr);
64 assert(sym !=
nullptr);
85 return "Dynamic loader plug-in that watches for shared library "
86 "loads/unloads in Hexagon processes.";
93 const llvm::Triple &triple_ref =
95 if (triple_ref.getArch() == llvm::Triple::hexagon)
127 if (executable.get() ==
nullptr)
134 m_process->SetCanInterpretFunctionCalls(
true);
138 module_list.
Append(executable);
150 m_process->GetTarget().ModulesDidLoad(module_list);
170 if (!executable.get())
178 ModuleSpec module_spec(executable->GetFileSpec(),
179 executable->GetArchitecture());
184 if (module_sp.get() && module_sp->GetUUID().IsValid() &&
185 executable->GetUUID().IsValid()) {
187 if (module_sp->GetUUID() != executable->GetUUID())
189 }
else if (executable->FileHasChanged())
192 if (executable.get())
212 bool base_addr_is_offset) {
216 assert(sections &&
"SectionList missing from loaded module.");
220 const size_t num_sections = sections->
GetSize();
222 for (
unsigned i = 0; i < num_sections; ++i) {
224 lldb::addr_t new_load_addr = section_sp->GetFileAddress() + base_addr;
247 assert(sections &&
"SectionList missing from unloaded module.");
251 const size_t num_sections = sections->
GetSize();
252 for (
size_t i = 0; i < num_sections; ++i) {
274 LLDB_LOGF(log,
"Unable to locate _rtld_debug_state breakpoint address");
292 ->FindLocationByAddress(break_addr)
296 if (log && dyld_break ==
nullptr)
297 LLDB_LOGF(log,
"Failed to create _rtld_debug_state breakpoint");
300 return (dyld_break !=
nullptr);
312 LLDB_LOGF(log,
"Rendezvous breakpoint hit!");
328 LLDB_LOGF(log,
"Found _rtld_debug structure @ 0x%08" PRIx64, structAddr);
330 LLDB_LOGF(log,
"Unable to resolve the _rtld_debug structure");
362 if (module_sp.get()) {
364 new_modules.
Append(module_sp);
368 LLDB_LOGF(log,
"Target is loading '%s'", I->path.c_str());
369 if (!module_sp.get())
370 LLDB_LOGF(log,
"LLDB failed to load '%s'", I->path.c_str());
372 LLDB_LOGF(log,
"LLDB successfully loaded '%s'", I->path.c_str());
375 m_process->GetTarget().ModulesDidLoad(new_modules);
388 if (module_sp.get()) {
389 old_modules.
Append(module_sp);
393 LLDB_LOGF(log,
"Target is unloading '%s'", I->path.c_str());
395 loaded_modules.
Remove(old_modules);
396 m_process->GetTarget().ModulesDidUnload(old_modules,
false);
408 StackFrame *frame = thread.GetStackFrameAtIndex(0).get();
413 return thread_plan_sp;
418 return thread_plan_sp;
421 Target &target = thread.GetProcess()->GetTarget();
425 if (target_symbols.
GetSize() == 0)
426 return thread_plan_sp;
428 typedef std::vector<lldb::addr_t> AddressVector;
433 addrs.push_back(addr);
436 if (addrs.size() > 0) {
437 AddressVector::iterator start = addrs.begin();
438 AddressVector::iterator end = addrs.end();
440 llvm::sort(start, end);
441 addrs.erase(std::unique(start, end), end);
443 std::make_shared<ThreadPlanRunToAddress>(thread, addrs, stop);
446 return thread_plan_sp;
460 "DynamicLoaderHexagonDYLD::%s unable to resolve rendezvous address",
471 const char *module_path = I->path.c_str();
475 if (module_sp.get()) {
476 module_list.
Append(module_sp);
480 "DynamicLoaderHexagonDYLD::%s failed loading module %s at "
482 __FUNCTION__, module_path, I->base_addr);
486 m_process->GetTarget().ModulesDidLoad(module_list);
515 Module &module = *(
m_process->GetTarget().GetExecutableModule().get());
519 if (
object.IsExecutable()) {
533 ObjectFile *obj_file =
module->GetObjectFile();
544 addr,
sizeof(uint32_t), 0,
error);
559 addr_t link_map = it->second;
569 addr_t tp = thread->GetThreadPointer();
588 Module *mod =
module.get();
591 "DynamicLoaderHexagonDYLD::Performed TLS lookup: "
592 "module=%s, link_map=0x%" PRIx64
", tp=0x%" PRIx64
593 ", modid=%i, tls_block=0x%" PRIx64,
599 return tls_block + tls_file_addr;
static llvm::raw_ostream & error(Stream &strm)
static lldb::addr_t findSymbolAddress(Process *proc, ConstString findName)
static int ReadInt(Process *process, addr_t addr)
#define LLDB_LOGF(log,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
lldb::ModuleSP GetTargetExecutable()
Checks to see if the target module has changed, updates the target accordingly and returns the target...
static llvm::StringRef GetPluginDescriptionStatic()
void LoadAllCurrentModules()
Helper for the entry breakpoint callback.
std::map< lldb::ModuleWP, lldb::addr_t, std::owner_less< lldb::ModuleWP > > m_loaded_modules
Loaded module list. (link map for each module)
lldb_private::Status CanLoadImage() override
Ask if it is ok to try and load or unload an shared library (image).
lldb::break_id_t m_dyld_bid
Rendezvous breakpoint.
lldb::addr_t m_entry_point
Virtual entry address of the inferior process.
bool SetRendezvousBreakpoint()
Enables a breakpoint on a function called by the runtime linker each time a module is loaded or unloa...
lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr) override
Retrieves the per-module TLS block for a given thread.
DynamicLoaderHexagonDYLD(lldb_private::Process *process)
static lldb_private::DynamicLoader * CreateInstance(lldb_private::Process *process, bool force)
void RefreshModules()
Helper method for RendezvousBreakpointHit.
HexagonDYLDRendezvous m_rendezvous
Runtime linker rendezvous structure.
static bool RendezvousBreakpointHit(void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Callback routine which updates the current list of loaded modules based on the information supplied b...
lldb::addr_t ComputeLoadOffset()
Computes a value for m_load_offset returning the computed address on success and LLDB_INVALID_ADDRESS...
const lldb_private::SectionList * GetSectionListFromModule(const lldb::ModuleSP module) const
~DynamicLoaderHexagonDYLD() override
void DidLaunch() override
Called after launching a process.
void UnloadSections(const lldb::ModuleSP module) override
Removes the loaded sections from the target in module.
void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset) override
Updates the load address of every allocatable section in module.
static llvm::StringRef GetPluginNameStatic()
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread, bool stop_others) override
Provides a plan to step through the dynamic loader trampoline for the current state of thread.
void DidAttach() override
Called after attaching a process.
lldb::addr_t GetEntryPoint()
Computes a value for m_entry_point returning the computed address on success and LLDB_INVALID_ADDRESS...
lldb::addr_t m_load_offset
Virtual load address of the inferior process.
SOEntryList::const_iterator iterator
void SetRendezvousAddress(lldb::addr_t)
Provide the dyld structure address.
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
lldb::addr_t GetFileAddress() const
Get the file address.
llvm::Triple & GetTriple()
Architecture triple accessor.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
void SetBreakpointKind(const char *kind)
Set the "kind" description for a breakpoint.
void SetCallback(BreakpointHitCallback callback, void *baton, bool is_synchronous=false)
Set the callback action invoked when the breakpoint is hit.
A uniqued constant string class.
static int Compare(ConstString lhs, ConstString rhs, const bool case_sensitive=true)
Compare two string objects.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
lldb::addr_t ReadPointer(lldb::addr_t addr)
Process * m_process
The process that this dynamic loader plug-in is tracking.
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 ...
DynamicLoader(Process *process)
Construct with a process.
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
A collection class for Module objects.
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Finds the first module whose file specification matches module_spec.
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
bool Remove(const lldb::ModuleSP &module_sp, bool notify=true)
Remove a module from the module list.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
A class that describes an executable image and its associated object and symbol files.
ConstString GetObjectName() const
A plug-in interface definition class for object file parsers.
Symtab * GetSymtab(bool can_create=true)
Gets the symbol table for the currently selected architecture (and object for archives).
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
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.
Target & GetTarget()
Get the target object pointer for this module.
lldb::SectionSP GetSectionAtIndex(size_t idx) const
This base class provides an interface to stack frames.
virtual const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
lldb::break_id_t GetID() const
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
Defines a symbol context baton that can be handed other debug core functions.
Symbol * symbol
The Symbol for a given query.
Address GetFunctionOrSymbolAddress() const
Get the address of the function or symbol represented by this symbol context.
bool IsTrampoline() const
ConstString GetName() const
Address GetAddress() const
Symbol * SymbolAtIndex(size_t idx)
size_t GetNumSymbols() const
Module * GetExecutableModulePointer()
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
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...
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
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.
bool SetSectionLoadAddress(const lldb::SectionSP §ion, lldb::addr_t load_addr, bool warn_multiple=false)
#define LLDB_INVALID_BREAK_ID
#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.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::Module > ModuleSP