Lines Matching +full:target +full:- +full:module
1 //===-- DynamicLoaderPOSIXDYLD.cpp ----------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 #include "lldb/Core/Module.h"
19 #include "lldb/Target/MemoryRegionInfo.h"
20 #include "lldb/Target/Platform.h"
21 #include "lldb/Target/Target.h"
22 #include "lldb/Target/Thread.h"
23 #include "lldb/Target/ThreadPlanRunToAddress.h"
44 return "Dynamic loader plug-in that watches for shared library "
53 process->GetTarget().GetArchitecture().GetTriple();
76 m_process->GetTarget().RemoveBreakpointByID(m_dyld_bid);
84 m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID);
85 m_auxv = std::make_unique<AuxVector>(m_process->GetAuxvData());
89 __FUNCTION__, m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID);
101 m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID,
102 executable_sp ? executable_sp->GetFileSpec().GetPath().c_str()
108 // if we dont have a load address we cant re-base
113 lldb_private::ObjectFile *obj = executable_sp->GetObjectFile();
115 // don't rebase if the module already has a load address
116 Target &target = m_process->GetTarget();
117 Address addr = obj->GetImageInfoAddress(&target);
118 if (addr.GetLoadAddress(&target) != LLDB_INVALID_ADDRESS)
122 // no executable, nothing to re-base
126 // if the target executable should be re-based
133 " added executable '%s' to module load list",
135 m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID,
136 executable_sp->GetFileSpec().GetPath().c_str());
143 m_process->GetTarget().ModulesDidLoad(module_list);
146 "DynamicLoaderPOSIXDYLD::%s told the target about the "
150 LLDB_LOGF(log, "-- [module] %s (pid %" PRIu64 ")",
151 module_sp ? module_sp->GetFileSpec().GetPath().c_str()
153 m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID);
174 m_auxv = std::make_unique<AuxVector>(m_process->GetAuxvData());
195 m_process->GetTarget().ModulesDidLoad(module_list);
201 void DynamicLoaderPOSIXDYLD::UpdateLoadedSections(ModuleSP module,
205 m_loaded_modules[module] = link_map_addr;
206 UpdateLoadedSectionsCommon(module, base_addr, base_addr_is_offset);
209 void DynamicLoaderPOSIXDYLD::UnloadSections(const ModuleSP module) {
210 m_loaded_modules.erase(module);
212 UnloadSectionsCommon(module);
228 __FUNCTION__, m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID);
237 m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID, entry);
241 m_process->GetTarget().CreateBreakpoint(entry, true, false).get();
242 entry_break->SetCallback(EntryBreakpointHit, this, true);
243 entry_break->SetBreakpointKind("shared-library-event");
246 entry_break->SetOneShot(true);
268 dyld_instance->m_process ? dyld_instance->m_process->GetID()
271 // Disable the breakpoint --- if a stop happens right after this, which we've
272 // seen on occasion, we don't want the breakpoint stepping thread-plan logic
274 // program. Disabling it prevents it. (One-shot is not enough - one-shot
277 if (dyld_instance->m_process) {
279 dyld_instance->m_process->GetTarget().GetBreakpointByID(break_id);
284 __FUNCTION__, dyld_instance->m_process->GetID(), break_id);
285 breakpoint_sp->SetEnabled(false);
290 __FUNCTION__, dyld_instance->m_process->GetID(), break_id);
299 dyld_instance->LoadAllCurrentModules();
300 dyld_instance->SetRendezvousBreakpoint();
316 m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID);
321 Target &target = m_process->GetTarget();
326 m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID,
328 dyld_break = target.CreateBreakpoint(break_addr, true, false);
343 containingModules.Append(interpreter->GetFileSpec());
346 m_process->GetTarget().GetExecutableModulePointer()->GetFileSpec());
348 dyld_break = target.CreateBreakpoint(
357 if (dyld_break->GetNumResolvedLocations() != 1) {
362 dyld_break->GetNumResolvedLocations(),
363 m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID);
365 target.RemoveBreakpointByID(dyld_break->GetID());
369 BreakpointLocationSP location = dyld_break->GetLocationAtIndex(0);
373 location->GetLoadAddress(),
374 m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID);
376 dyld_break->SetCallback(RendezvousBreakpointHit, this, true);
377 dyld_break->SetBreakpointKind("shared-library-event");
378 m_dyld_bid = dyld_break->GetID();
394 dyld_instance->m_process ? dyld_instance->m_process->GetID()
397 dyld_instance->RefreshModules();
399 // Return true to stop the target, false to just let the target run.
400 const bool stop_when_images_change = dyld_instance->GetStopWhenImagesChange();
405 dyld_instance->m_process ? dyld_instance->m_process->GetID()
415 // The rendezvous class doesn't enumerate the main module, so track that
423 ModuleList &loaded_modules = m_process->GetTarget().GetImages();
430 // the loader. This is necessary to list ld-linux.so on Linux,
446 (I->base_addr == m_interpreter_base))
450 LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr, true);
454 if (module_sp->GetObjectFile()->GetBaseAddress().GetLoadAddress(
455 &m_process->GetTarget()) == m_interpreter_base) {
460 // Module already loaded.
468 m_process->GetTarget().ModulesDidLoad(new_modules);
476 ModuleSpec module_spec{I->file_spec};
485 m_process->GetTarget().ModulesDidUnload(old_modules, false);
495 const SymbolContext &context = frame->GetSymbolContext(eSymbolContextSymbol);
498 if (sym == nullptr || !sym->IsTrampoline())
501 ConstString sym_name = sym->GetMangled().GetName(Mangled::ePreferMangled);
506 Target &target = thread.GetProcess()->GetTarget();
507 const ModuleList &images = target.GetImages();
516 // An empty target name can happen for trampolines generated for
517 // section-referencing relocations.
531 lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(&target);
556 Status status = m_process->GetMemoryRegionInfo(m_vdso_base, info);
563 if (ModuleSP module_sp = m_process->ReadModuleFromMemory(
566 m_process->GetTarget().GetImages().AppendIfNeeded(module_sp);
575 Target &target = m_process->GetTarget();
576 Status status = m_process->GetMemoryRegionInfo(m_interpreter_base, info);
585 ModuleSpec module_spec(file, target.GetArchitecture());
587 // Don't notify that module is added here because its loading section
590 target.GetOrCreateModule(module_spec, /*notify=*/false)) {
597 target.ModulesDidLoad(module_list);
619 // This should be removed after we drop support for android-23.
620 if (m_process->GetTarget().GetArchitecture().GetTriple().isAndroid()) {
622 Status error = m_process->GetMemoryRegionInfo(base_addr, memory_info);
652 // The rendezvous class doesn't enumerate the main module, so track that
659 module_names.push_back(I->file_spec);
660 m_process->PrefetchModuleSpecs(
661 module_names, m_process->GetTarget().GetArchitecture().GetTriple());
665 LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr, true);
667 LLDB_LOG(log, "LoadAllCurrentModules loading module: {0}",
668 I->file_spec.GetFilename());
674 "DynamicLoaderPOSIXDYLD::%s failed loading module %s at 0x%" PRIx64,
675 __FUNCTION__, I->file_spec.GetPath().c_str(), I->base_addr);
679 m_process->GetTarget().ModulesDidLoad(module_list);
692 ModuleSP module = m_process->GetTarget().GetExecutableModule();
693 if (!module)
696 ObjectFile *exe = module->GetObjectFile();
700 Address file_entry = exe->GetEntryPointAddress();
705 m_load_offset = virt_entry - file_entry.GetFileAddress();
711 m_auxv->GetAuxValue(AuxVector::AUXV_AT_SYSINFO_EHDR))
715 m_auxv->GetAuxValue(AuxVector::AUXV_AT_BASE))
727 m_auxv->GetAuxValue(AuxVector::AUXV_AT_ENTRY);
733 const ArchSpec &arch = m_process->GetTarget().GetArchitecture();
750 log, "GetThreadLocalData error: module(%s) not found in loaded modules",
751 module_sp->GetObjectName().AsCString());
755 addr_t link_map = it->second;
779 addr_t tp = thread->GetThreadPointer();
785 // Find the module's modid.
786 int modid_size = 4; // FIXME(spucci): This isn't right for big-endian 64-bit
789 if (modid == -1) {
802 // Find the TLS block for this module.
808 "module=%s, link_map=0x%" PRIx64 ", tp=0x%" PRIx64
810 module_sp->GetObjectName().AsCString(""), link_map, tp,
827 auto &target = m_process->GetTarget();
828 const auto platform_sp = target.GetPlatform();
831 if (!m_process->GetProcessInfo(process_info)) {
833 "DynamicLoaderPOSIXDYLD::%s - failed to get process info for "
835 __FUNCTION__, m_process->GetID());
840 log, "DynamicLoaderPOSIXDYLD::%s - got executable by pid %" PRIu64 ": %s",
841 __FUNCTION__, m_process->GetID(),
846 if (module_sp && module_sp->MatchesModuleSpec(module_spec))
849 const auto executable_search_paths(Target::GetDefaultExecutableSearchPaths());
850 auto error = platform_sp->ResolveExecutable(
858 "DynamicLoaderPOSIXDYLD::%s - failed to resolve executable "
859 "with module spec \"%s\": %s",
864 target.SetExecutableModule(module_sp, eLoadDependentsNo);
871 module_sp = sym_ctx.symbol->GetAddressRef().GetModule();
874 sym_ctx.function->GetAddressRange().GetBaseAddress().GetModule();
878 return module_sp->GetFileSpec().GetPath() == "[vdso]";
882 return !m_process->IsLiveDebugSession();