Lines Matching +full:target +full:- +full:module

1 //===-- DynamicLoaderHexagonDYLD.cpp --------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 #include "lldb/Core/Module.h"
15 #include "lldb/Target/Process.h"
16 #include "lldb/Target/Target.h"
17 #include "lldb/Target/Thread.h"
18 #include "lldb/Target/ThreadPlanRunToAddress.h"
35 // When we connect to a target we find the dyld breakpoint address. We put in LLDB_PLUGIN_DEFINE()
42 // target calls dlinit(). in LLDB_PLUGIN_DEFINE()
53 ModuleSP module = proc->GetTarget().GetExecutableModule(); in LLDB_PLUGIN_DEFINE() local
54 assert(module.get() != nullptr); in LLDB_PLUGIN_DEFINE()
56 ObjectFile *exe = module->GetObjectFile(); in LLDB_PLUGIN_DEFINE()
59 lldb_private::Symtab *symtab = exe->GetSymtab(); in LLDB_PLUGIN_DEFINE()
62 for (size_t i = 0; i < symtab->GetNumSymbols(); i++) { in LLDB_PLUGIN_DEFINE()
63 const Symbol *sym = symtab->SymbolAtIndex(i); in LLDB_PLUGIN_DEFINE()
65 ConstString symName = sym->GetName(); in LLDB_PLUGIN_DEFINE()
68 Address addr = sym->GetAddress(); in LLDB_PLUGIN_DEFINE()
69 return addr.GetLoadAddress(&proc->GetTarget()); in LLDB_PLUGIN_DEFINE()
83 return "Dynamic loader plug-in that watches for shared library " in GetPluginDescriptionStatic()
92 process->GetTarget().GetArchitecture().GetTriple(); in CreateInstance()
109 m_process->GetTarget().RemoveBreakpointByID(m_dyld_bid); in ~DynamicLoaderHexagonDYLD()
129 m_process->SetCanJIT(false); in DidAttach()
132 m_process->SetCanInterpretFunctionCalls(true); in DidAttach()
134 // Add the current executable to the module list in DidAttach()
147 // Callback for the target to give it the loaded module list in DidAttach()
148 m_process->GetTarget().ModulesDidLoad(module_list); in DidAttach()
161 /// Checks to see if the target module has changed, updates the target
162 /// accordingly and returns the target executable module.
164 Target &target = m_process->GetTarget(); in GetTargetExecutable() local
165 ModuleSP executable = target.GetExecutableModule(); in GetTargetExecutable()
171 // The target executable file does not exits in GetTargetExecutable()
172 if (!FileSystem::Instance().Exists(executable->GetFileSpec())) in GetTargetExecutable()
175 // Prep module for loading in GetTargetExecutable()
176 ModuleSpec module_spec(executable->GetFileSpec(), in GetTargetExecutable()
177 executable->GetArchitecture()); in GetTargetExecutable()
178 ModuleSP module_sp(new Module(module_spec)); in GetTargetExecutable()
180 // Check if the executable has changed and set it to the target executable if in GetTargetExecutable()
182 if (module_sp.get() && module_sp->GetUUID().IsValid() && in GetTargetExecutable()
183 executable->GetUUID().IsValid()) { in GetTargetExecutable()
185 if (module_sp->GetUUID() != executable->GetUUID()) in GetTargetExecutable()
187 } else if (executable->FileHasChanged()) in GetTargetExecutable()
194 executable = target.GetOrCreateModule(module_spec, true /* notify */); in GetTargetExecutable()
195 if (executable.get() != target.GetExecutableModulePointer()) { in GetTargetExecutable()
198 target.SetExecutableModule(executable, eLoadDependentsNo); in GetTargetExecutable()
207 void DynamicLoaderHexagonDYLD::UpdateLoadedSections(ModuleSP module, in UpdateLoadedSections() argument
211 Target &target = m_process->GetTarget(); in UpdateLoadedSections() local
212 const SectionList *sections = GetSectionListFromModule(module); in UpdateLoadedSections()
214 assert(sections && "SectionList missing from loaded module."); in UpdateLoadedSections()
216 m_loaded_modules[module] = link_map_addr; in UpdateLoadedSections()
218 const size_t num_sections = sections->GetSize(); in UpdateLoadedSections()
221 SectionSP section_sp(sections->GetSectionAtIndex(i)); in UpdateLoadedSections()
222 lldb::addr_t new_load_addr = section_sp->GetFileAddress() + base_addr; in UpdateLoadedSections()
234 target.SetSectionLoadAddress(section_sp, new_load_addr); in UpdateLoadedSections()
238 /// Removes the loaded sections from the target in \p module.
240 /// \param module The module to traverse.
241 void DynamicLoaderHexagonDYLD::UnloadSections(const ModuleSP module) { in UnloadSections() argument
242 Target &target = m_process->GetTarget(); in UnloadSections() local
243 const SectionList *sections = GetSectionListFromModule(module); in UnloadSections()
245 assert(sections && "SectionList missing from unloaded module."); in UnloadSections()
247 m_loaded_modules.erase(module); in UnloadSections()
249 const size_t num_sections = sections->GetSize(); in UnloadSections()
251 SectionSP section_sp(sections->GetSectionAtIndex(i)); in UnloadSections()
252 target.SetSectionUnloaded(section_sp); in UnloadSections()
268 Target &target = m_process->GetTarget(); in SetRendezvousBreakpoint() local
283 target.CreateBreakpoint(break_addr, true, false).get(); in SetRendezvousBreakpoint()
284 dyld_break->SetCallback(RendezvousBreakpointHit, this, true); in SetRendezvousBreakpoint()
285 dyld_break->SetBreakpointKind("shared-library-event"); in SetRendezvousBreakpoint()
286 m_dyld_bid = dyld_break->GetID(); in SetRendezvousBreakpoint()
289 assert(target.GetBreakpointByID(m_dyld_bid) in SetRendezvousBreakpoint()
290 ->FindLocationByAddress(break_addr) in SetRendezvousBreakpoint()
291 ->GetBreakpoint() in SetRendezvousBreakpoint()
317 if (!dyld_instance->m_rendezvous.IsValid()) { in RendezvousBreakpointHit()
318 Process *proc = dyld_instance->m_process; in RendezvousBreakpointHit()
324 dyld_instance->m_rendezvous.SetRendezvousAddress(structAddr); in RendezvousBreakpointHit()
332 dyld_instance->RefreshModules(); in RendezvousBreakpointHit()
334 // Return true to stop the target, false to just let the target run. in RendezvousBreakpointHit()
335 return dyld_instance->GetStopWhenImagesChange(); in RendezvousBreakpointHit()
349 ModuleList &loaded_modules = m_process->GetTarget().GetImages(); in RefreshModules()
356 FileSpec file(I->path); in RefreshModules()
359 LoadModuleAtAddress(file, I->link_addr, I->base_addr, true); in RefreshModules()
366 LLDB_LOGF(log, "Target is loading '%s'", I->path.c_str()); in RefreshModules()
368 LLDB_LOGF(log, "LLDB failed to load '%s'", I->path.c_str()); in RefreshModules()
370 LLDB_LOGF(log, "LLDB successfully loaded '%s'", I->path.c_str()); in RefreshModules()
373 m_process->GetTarget().ModulesDidLoad(new_modules); in RefreshModules()
381 FileSpec file(I->path); in RefreshModules()
391 LLDB_LOGF(log, "Target is unloading '%s'", I->path.c_str()); in RefreshModules()
394 m_process->GetTarget().ModulesDidUnload(old_modules, false); in RefreshModules()
407 const SymbolContext &context = frame->GetSymbolContext(eSymbolContextSymbol); in GetStepThroughTrampolinePlan()
410 if (sym == nullptr || !sym->IsTrampoline()) in GetStepThroughTrampolinePlan()
414 sym->GetMangled().GetName(Mangled::ePreferMangled); in GetStepThroughTrampolinePlan()
419 Target &target = thread.GetProcess()->GetTarget(); in GetStepThroughTrampolinePlan() local
420 const ModuleList &images = target.GetImages(); in GetStepThroughTrampolinePlan()
431 lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(&target); in GetStepThroughTrampolinePlan()
465 // The rendezvous class doesn't enumerate the main module, so track that in LoadAllCurrentModules()
471 const char *module_path = I->path.c_str(); in LoadAllCurrentModules()
474 LoadModuleAtAddress(file, I->link_addr, I->base_addr, true); in LoadAllCurrentModules()
480 "DynamicLoaderHexagonDYLD::%s failed loading module %s at " in LoadAllCurrentModules()
482 __FUNCTION__, module_path, I->base_addr); in LoadAllCurrentModules()
486 m_process->GetTarget().ModulesDidLoad(module_list); in LoadAllCurrentModules()
514 // Get the current executable module in GetEntryPoint()
515 Module &module = *(m_process->GetTarget().GetExecutableModule().get()); in GetEntryPoint() local
516 // Get the object file (elf file) for this module in GetEntryPoint()
517 lldb_private::ObjectFile &object = *(module.GetObjectFile()); in GetEntryPoint()
530 const ModuleSP module) const { in GetSectionListFromModule()
532 if (module.get()) { in GetSectionListFromModule()
533 ObjectFile *obj_file = module->GetObjectFile(); in GetSectionListFromModule()
535 sections = obj_file->GetSectionList(); in GetSectionListFromModule()
543 int value = (int)process->ReadUnsignedIntegerFromMemory( in ReadInt()
546 return -1; in ReadInt()
552 DynamicLoaderHexagonDYLD::GetThreadLocalData(const lldb::ModuleSP module, in GetThreadLocalData() argument
555 auto it = m_loaded_modules.find(module); in GetThreadLocalData()
559 addr_t link_map = it->second; in GetThreadLocalData()
569 addr_t tp = thread->GetThreadPointer(); in GetThreadLocalData()
573 // Find the module's modid. in GetThreadLocalData()
575 if (modid == -1) in GetThreadLocalData()
584 // Find the TLS block for this module. in GetThreadLocalData()
588 Module *mod = module.get(); in GetThreadLocalData()
592 "module=%s, link_map=0x%" PRIx64 ", tp=0x%" PRIx64 in GetThreadLocalData()
594 mod->GetObjectName().AsCString(""), link_map, tp, modid, tls_block); in GetThreadLocalData()