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);
83 return "Dynamic loader plug-in that watches for shared library "
84 "loads/unloads in Hexagon processes.";
91 const llvm::Triple &triple_ref =
93 if (triple_ref.getArch() == llvm::Triple::hexagon)
125 if (executable.get() ==
nullptr)
136 module_list.
Append(executable);
168 if (!executable.get())
176 ModuleSpec module_spec(executable->GetFileSpec(),
177 executable->GetArchitecture());
182 if (module_sp.get() && module_sp->GetUUID().IsValid() &&
183 executable->GetUUID().IsValid()) {
185 if (module_sp->GetUUID() != executable->GetUUID())
187 }
else if (executable->FileHasChanged())
190 if (executable.get())
210 bool base_addr_is_offset) {
214 assert(sections &&
"SectionList missing from loaded module.");
218 const size_t num_sections = sections->
GetSize();
220 for (
unsigned i = 0; i < num_sections; ++i) {
222 lldb::addr_t new_load_addr = section_sp->GetFileAddress() + base_addr;
245 assert(sections &&
"SectionList missing from unloaded module.");
249 const size_t num_sections = sections->
GetSize();
250 for (
size_t i = 0; i < num_sections; ++i) {
258 Log *log =
GetLog(LLDBLog::DynamicLoader);
272 LLDB_LOGF(log,
"Unable to locate _rtld_debug_state breakpoint address");
290 ->FindLocationByAddress(break_addr)
294 if (log && dyld_break ==
nullptr)
295 LLDB_LOGF(log,
"Failed to create _rtld_debug_state breakpoint");
298 return (dyld_break !=
nullptr);
308 Log *log =
GetLog(LLDBLog::DynamicLoader);
310 LLDB_LOGF(log,
"Rendezvous breakpoint hit!");
326 LLDB_LOGF(log,
"Found _rtld_debug structure @ 0x%08" PRIx64, structAddr);
328 LLDB_LOGF(log,
"Unable to resolve the _rtld_debug structure");
341 Log *log =
GetLog(LLDBLog::DynamicLoader);
360 if (module_sp.get()) {
362 new_modules.
Append(module_sp);
366 LLDB_LOGF(log,
"Target is loading '%s'", I->path.c_str());
367 if (!module_sp.get())
368 LLDB_LOGF(log,
"LLDB failed to load '%s'", I->path.c_str());
370 LLDB_LOGF(log,
"LLDB successfully loaded '%s'", I->path.c_str());
386 if (module_sp.get()) {
387 old_modules.
Append(module_sp);
391 LLDB_LOGF(log,
"Target is unloading '%s'", I->path.c_str());
393 loaded_modules.
Remove(old_modules);
411 return thread_plan_sp;
416 return thread_plan_sp;
423 if (target_symbols.
GetSize() == 0)
424 return thread_plan_sp;
426 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;
457 Log *log =
GetLog(LLDBLog::DynamicLoader);
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);
478 Log *log =
GetLog(LLDBLog::DynamicLoader);
480 "DynamicLoaderHexagonDYLD::%s failed loading module %s at "
482 __FUNCTION__, module_path, I->base_addr);
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();
589 Log *log =
GetLog(LLDBLog::DynamicLoader);
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...
iterator unloaded_end() const
bool ModulesDidLoad() const
lldb::addr_t GetLinkMapAddress() const
bool Resolve()
Update the internal snapshot of runtime linker rendezvous and recompute the currently loaded modules.
const ThreadInfo & GetThreadInfo()
SOEntryList::const_iterator iterator
void SetBreakAddress(lldb::addr_t addr)
In hexagon it is possible that we can know the dyld breakpoint without having to find it from the ren...
bool ModulesDidUnload() const
iterator loaded_end() const
iterator loaded_begin() const
Iterators over all modules loaded into the inferior since the last call to Resolve().
iterator begin() const
Iterators over all currently loaded modules.
void SetRendezvousAddress(lldb::addr_t)
Provide the dyld structure address.
iterator unloaded_begin() const
Iterators over all modules unloaded from the inferior since the last call to Resolve().
A section + offset based address range class.
Address & GetBaseAddress()
Get accessor for the base address of the range.
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.
A plug-in interface definition class for dynamic loaders.
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 ...
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
static FileSystem & Instance()
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
A collection class for Module objects.
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
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.
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
ConstString GetObjectName() const
A plug-in interface definition class for object file parsers.
Symtab * GetSymtab()
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)
A plug-in interface definition class for debugging a process.
void SetCanJIT(bool can_jit)
Sets whether executing JIT-compiled code in this process is possible.
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.
void SetCanInterpretFunctionCalls(bool can_interpret_function_calls)
Sets whether executing function calls using the interpreter is possible for this process.
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.
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.
bool GetAddressRange(uint32_t scope, uint32_t range_idx, bool use_inline_block_range, AddressRange &range) const
Get the address range contained within a symbol context.
Symbol * symbol
The Symbol for a given query.
bool IsTrampoline() const
ConstString GetName() const
Address GetAddress() const
Symbol * SymbolAtIndex(size_t idx)
size_t GetNumSymbols() const
void ModulesDidLoad(ModuleList &module_list)
Module * GetExecutableModulePointer()
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
bool SetSectionUnloaded(const lldb::SectionSP §ion_sp)
bool RemoveBreakpointByID(lldb::break_id_t break_id)
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.
void ModulesDidUnload(ModuleList &module_list, bool delete_locations)
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)
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
lldb::ProcessSP GetProcess() const
#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