LLDB mainline
DynamicLoaderPOSIXDYLD.cpp
Go to the documentation of this file.
1//===-- DynamicLoaderPOSIXDYLD.cpp ----------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// Main header include
11
15#include "lldb/Core/Debugger.h"
16#include "lldb/Core/Module.h"
19#include "lldb/Core/Section.h"
25#include "lldb/Target/Target.h"
26#include "lldb/Target/Thread.h"
29#include "lldb/Utility/Log.h"
31#include "llvm/BinaryFormat/ELF.h"
32#include "llvm/Support/ThreadPool.h"
33
34#include <memory>
35#include <optional>
36
37using namespace lldb;
38using namespace lldb_private;
39
41
46
50
52 return "Dynamic loader plug-in that watches for shared library "
53 "loads/unloads in POSIX processes.";
54}
55
57 bool force) {
58 bool create = force;
59 if (!create) {
60 const llvm::Triple &triple_ref =
61 process->GetTarget().GetArchitecture().GetTriple();
62 if (triple_ref.getOS() == llvm::Triple::FreeBSD ||
63 triple_ref.getOS() == llvm::Triple::Linux ||
64 triple_ref.getOS() == llvm::Triple::NetBSD ||
65 triple_ref.getOS() == llvm::Triple::OpenBSD)
66 create = true;
67 }
68
69 if (create)
70 return new DynamicLoaderPOSIXDYLD(process);
71 return nullptr;
72}
73
81
88
91 LLDB_LOGF(log, "DynamicLoaderPOSIXDYLD::%s() pid %" PRIu64, __FUNCTION__,
93 m_auxv = std::make_unique<AuxVector>(m_process->GetAuxvData());
94
96 log, "DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " reloaded auxv data",
97 __FUNCTION__, m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID);
98
99 ModuleSP executable_sp = GetTargetExecutable();
100 ResolveExecutableModule(executable_sp);
101 m_rendezvous.UpdateExecutablePath();
102
103 // find the main process load offset
104 addr_t load_offset = ComputeLoadOffset();
105 LLDB_LOGF(log,
106 "DynamicLoaderPOSIXDYLD::%s pid %" PRIu64
107 " executable '%s', load_offset 0x%" PRIx64,
108 __FUNCTION__,
110 executable_sp ? executable_sp->GetFileSpec().GetPath().c_str()
111 : "<null executable>",
112 load_offset);
113
115
116 // if we dont have a load address we cant re-base
117 bool rebase_exec = load_offset != LLDB_INVALID_ADDRESS;
118
119 // if the target executable should be re-based
120 if (rebase_exec) {
121 ModuleList module_list;
122
123 module_list.Append(executable_sp);
124 LLDB_LOGF(log,
125 "DynamicLoaderPOSIXDYLD::%s pid %" PRIu64
126 " added executable '%s' to module load list",
127 __FUNCTION__,
129 executable_sp->GetFileSpec().GetPath().c_str());
130
131 UpdateLoadedSections(executable_sp, LLDB_INVALID_ADDRESS, load_offset,
132 true);
133
135
136 m_process->GetTarget().ModulesDidLoad(module_list);
137 if (log) {
138 LLDB_LOGF(log,
139 "DynamicLoaderPOSIXDYLD::%s told the target about the "
140 "modules that loaded:",
141 __FUNCTION__);
142 for (auto module_sp : module_list.Modules()) {
143 LLDB_LOGF(log, "-- [module] %s (pid %" PRIu64 ")",
144 module_sp ? module_sp->GetFileSpec().GetPath().c_str()
145 : "<null>",
147 }
148 }
149 }
150
151 if (executable_sp.get()) {
153 // If we cannot establish rendezvous breakpoint right now we'll try again
154 // at entry point.
155 ProbeEntry();
156 }
157 }
158}
159
162 LLDB_LOGF(log, "DynamicLoaderPOSIXDYLD::%s()", __FUNCTION__);
163
164 ModuleSP executable;
165 addr_t load_offset;
166
167 m_auxv = std::make_unique<AuxVector>(m_process->GetAuxvData());
168
169 executable = GetTargetExecutable();
170 load_offset = ComputeLoadOffset();
172
173 if (executable.get() && load_offset != LLDB_INVALID_ADDRESS) {
174 ModuleList module_list;
175 module_list.Append(executable);
176 UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, load_offset, true);
177
178 LLDB_LOGF(log, "DynamicLoaderPOSIXDYLD::%s about to call ProbeEntry()",
179 __FUNCTION__);
180
182 // If we cannot establish rendezvous breakpoint right now we'll try again
183 // at entry point.
184 ProbeEntry();
185 }
186
187 LoadVDSO();
188 m_process->GetTarget().ModulesDidLoad(module_list);
189 }
190}
191
193
195 addr_t link_map_addr) {
196 llvm::sys::ScopedWriter lock(m_loaded_modules_rw_mutex);
197 m_loaded_modules[module_sp] = link_map_addr;
198}
199
201 llvm::sys::ScopedWriter lock(m_loaded_modules_rw_mutex);
202 m_loaded_modules.erase(module_sp);
203}
204
205std::optional<lldb::addr_t>
207 llvm::sys::ScopedReader lock(m_loaded_modules_rw_mutex);
208 auto it = m_loaded_modules.find(module_sp);
209 if (it != m_loaded_modules.end())
210 return it->second;
211 return std::nullopt;
212}
213
215 addr_t link_map_addr,
216 addr_t base_addr,
217 bool base_addr_is_offset) {
218 SetLoadedModule(module, link_map_addr);
219
220 UpdateLoadedSectionsCommon(module, base_addr, base_addr_is_offset);
221}
222
224 UnloadModule(module);
225
226 UnloadSectionsCommon(module);
227}
228
231
232 // If we have a core file, we don't need any breakpoints.
233 if (IsCoreFile())
234 return;
235
236 const addr_t entry = GetEntryPoint();
237 if (entry == LLDB_INVALID_ADDRESS) {
238 LLDB_LOGF(
239 log,
240 "DynamicLoaderPOSIXDYLD::%s pid %" PRIu64
241 " GetEntryPoint() returned no address, not setting entry breakpoint",
242 __FUNCTION__, m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID);
243 return;
244 }
245
246 LLDB_LOGF(log,
247 "DynamicLoaderPOSIXDYLD::%s pid %" PRIu64
248 " GetEntryPoint() returned address 0x%" PRIx64
249 ", setting entry breakpoint",
250 __FUNCTION__,
251 m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID, entry);
252
253 if (m_process) {
254 Breakpoint *const entry_break =
255 m_process->GetTarget().CreateBreakpoint(entry, true, false).get();
256 entry_break->SetCallback(EntryBreakpointHit, this, true);
257 entry_break->SetBreakpointKind("shared-library-event");
258
259 // Shoudn't hit this more than once.
260 entry_break->SetOneShot(true);
261 }
262}
263
264// The runtime linker has run and initialized the rendezvous structure once the
265// process has hit its entry point. When we hit the corresponding breakpoint
266// we interrogate the rendezvous structure to get the load addresses of all
267// dependent modules for the process. Similarly, we can discover the runtime
268// linker function and setup a breakpoint to notify us of any dynamically
269// loaded modules (via dlopen).
271 void *baton, StoppointCallbackContext *context, user_id_t break_id,
272 user_id_t break_loc_id) {
273 assert(baton && "null baton");
274 if (!baton)
275 return false;
276
278 DynamicLoaderPOSIXDYLD *const dyld_instance =
279 static_cast<DynamicLoaderPOSIXDYLD *>(baton);
280 LLDB_LOGF(log, "DynamicLoaderPOSIXDYLD::%s called for pid %" PRIu64,
281 __FUNCTION__,
282 dyld_instance->m_process ? dyld_instance->m_process->GetID()
284
285 // Disable the breakpoint --- if a stop happens right after this, which we've
286 // seen on occasion, we don't want the breakpoint stepping thread-plan logic
287 // to show a breakpoint instruction at the disassembled entry point to the
288 // program. Disabling it prevents it. (One-shot is not enough - one-shot
289 // removal logic only happens after the breakpoint goes public, which wasn't
290 // happening in our scenario).
291 if (dyld_instance->m_process) {
292 BreakpointSP breakpoint_sp =
293 dyld_instance->m_process->GetTarget().GetBreakpointByID(break_id);
294 if (breakpoint_sp) {
295 LLDB_LOGF(log,
296 "DynamicLoaderPOSIXDYLD::%s pid %" PRIu64
297 " disabling breakpoint id %" PRIu64,
298 __FUNCTION__, dyld_instance->m_process->GetID(), break_id);
299 breakpoint_sp->SetEnabled(false);
300 } else {
301 LLDB_LOGF(log,
302 "DynamicLoaderPOSIXDYLD::%s pid %" PRIu64
303 " failed to find breakpoint for breakpoint id %" PRIu64,
304 __FUNCTION__, dyld_instance->m_process->GetID(), break_id);
305 }
306 } else {
307 LLDB_LOGF(log,
308 "DynamicLoaderPOSIXDYLD::%s breakpoint id %" PRIu64
309 " no Process instance! Cannot disable breakpoint",
310 __FUNCTION__, break_id);
311 }
312
313 dyld_instance->LoadAllCurrentModules();
314 dyld_instance->SetRendezvousBreakpoint();
315 return false; // Continue running.
316}
317
320
321 // If we have a core file, we don't need any breakpoints.
322 if (IsCoreFile())
323 return false;
324
326 LLDB_LOG(log,
327 "Rendezvous breakpoint breakpoint id {0} for pid {1}"
328 "is already set.",
331 return true;
332 }
333
334 addr_t break_addr;
335 Target &target = m_process->GetTarget();
336 BreakpointSP dyld_break;
337 if (m_rendezvous.IsValid() && m_rendezvous.GetBreakAddress() != 0) {
338 break_addr = m_rendezvous.GetBreakAddress();
339 LLDB_LOG(log, "Setting rendezvous break address for pid {0} at {1:x}",
341 break_addr);
342 dyld_break = target.CreateBreakpoint(break_addr, true, false);
343 } else {
344 LLDB_LOG(log, "Rendezvous structure is not set up yet. "
345 "Trying to locate rendezvous breakpoint in the interpreter "
346 "by symbol name.");
347 // Function names from different dynamic loaders that are known to be
348 // used as rendezvous between the loader and debuggers.
349 static std::vector<std::string> DebugStateCandidates{
350 "_dl_debug_state", "rtld_db_dlactivity", "__dl_rtld_db_dlactivity",
351 "r_debug_state", "_r_debug_state", "_rtld_debug_state",
352 };
353
354 ModuleSP interpreter = LoadInterpreterModule();
355 FileSpecList containingModules;
356 if (interpreter)
357 containingModules.Append(interpreter->GetFileSpec());
358 else
359 containingModules.Append(
360 m_process->GetTarget().GetExecutableModulePointer()->GetFileSpec());
361
362 dyld_break = target.CreateBreakpoint(
363 &containingModules, /*containingSourceFiles=*/nullptr,
364 DebugStateCandidates, eFunctionNameTypeFull, eLanguageTypeC,
365 /*m_offset=*/0,
366 /*skip_prologue=*/eLazyBoolNo,
367 /*internal=*/true,
368 /*request_hardware=*/false);
369 }
370
371 if (dyld_break->GetNumResolvedLocations() != 1) {
372 LLDB_LOG(
373 log,
374 "Rendezvous breakpoint has abnormal number of"
375 " resolved locations ({0}) in pid {1}. It's supposed to be exactly 1.",
376 dyld_break->GetNumResolvedLocations(),
378
379 target.RemoveBreakpointByID(dyld_break->GetID());
380 return false;
381 }
382
383 BreakpointLocationSP location = dyld_break->GetLocationAtIndex(0);
384 LLDB_LOG(log,
385 "Successfully set rendezvous breakpoint at address {0:x} "
386 "for pid {1}",
387 location->GetLoadAddress(),
389
390 dyld_break->SetCallback(RendezvousBreakpointHit, this, true);
391 dyld_break->SetBreakpointKind("shared-library-event");
392 m_dyld_bid = dyld_break->GetID();
393 return true;
394}
395
397 void *baton, StoppointCallbackContext *context, user_id_t break_id,
398 user_id_t break_loc_id) {
399 assert(baton && "null baton");
400 if (!baton)
401 return false;
402
404 DynamicLoaderPOSIXDYLD *const dyld_instance =
405 static_cast<DynamicLoaderPOSIXDYLD *>(baton);
406 LLDB_LOGF(log, "DynamicLoaderPOSIXDYLD::%s called for pid %" PRIu64,
407 __FUNCTION__,
408 dyld_instance->m_process ? dyld_instance->m_process->GetID()
410
411 dyld_instance->RefreshModules();
412
413 // Return true to stop the target, false to just let the target run.
414 const bool stop_when_images_change = dyld_instance->GetStopWhenImagesChange();
415 LLDB_LOGF(log,
416 "DynamicLoaderPOSIXDYLD::%s pid %" PRIu64
417 " stop_when_images_change=%s",
418 __FUNCTION__,
419 dyld_instance->m_process ? dyld_instance->m_process->GetID()
421 stop_when_images_change ? "true" : "false");
422 return stop_when_images_change;
423}
424
426 if (!m_rendezvous.Resolve())
427 return;
428
429 // The rendezvous class doesn't enumerate the main module, so track that
430 // ourselves here.
431 ModuleSP executable = GetTargetExecutable();
432 SetLoadedModule(executable, m_rendezvous.GetLinkMapAddress());
433
436
437 ModuleList &loaded_modules = m_process->GetTarget().GetImages();
438
439 if (m_rendezvous.ModulesDidLoad() || !m_initial_modules_added) {
440 ModuleList new_modules;
441
442 // If this is the first time rendezvous breakpoint fires, we need
443 // to take care of adding all the initial modules reported by
444 // the loader. This is necessary to list ld-linux.so on Linux,
445 // and all DT_NEEDED entries on *BSD.
447 I = m_rendezvous.loaded_begin();
448 E = m_rendezvous.loaded_end();
449 } else {
450 I = m_rendezvous.begin();
451 E = m_rendezvous.end();
453 }
454
455 // Synchronize reading and writing of `m_interpreter_module`.
456 std::mutex interpreter_module_mutex;
457 // We should be able to take SOEntry as reference since the data
458 // exists for the duration of this call in `m_rendezvous`.
459 auto load_module_fn =
460 [this, &loaded_modules, &new_modules,
461 &interpreter_module_mutex](const DYLDRendezvous::SOEntry &so_entry) {
462 // Don't load a duplicate copy of ld.so if we have already loaded it
463 // earlier in LoadInterpreterModule. If we instead loaded then
464 // unloaded it later, the section information for ld.so would be
465 // removed. That information is required for placing breakpoints on
466 // Arm/Thumb systems.
467 {
468 // `m_interpreter_module` may be modified by another thread at the
469 // same time, so we guard the access here.
470 std::lock_guard<std::mutex> lock(interpreter_module_mutex);
471 if ((m_interpreter_module.lock() != nullptr) &&
472 (so_entry.base_addr == m_interpreter_base))
473 return;
474 }
475
476 ModuleSP module_sp = LoadModuleAtAddress(
477 so_entry.file_spec, so_entry.link_addr, so_entry.base_addr,
478 /*base_addr_is_offset=*/true);
479 if (!module_sp.get())
480 return;
481
482 {
483 // `m_interpreter_module` may be modified by another thread at the
484 // same time, so we guard the access here.
485 std::lock_guard<std::mutex> lock(interpreter_module_mutex);
486 // Set the interpreter module, if this is the interpreter.
487 if (module_sp->GetObjectFile()->GetBaseAddress().GetLoadAddress(
488 &m_process->GetTarget()) == m_interpreter_base) {
489 ModuleSP interpreter_sp = m_interpreter_module.lock();
490 if (m_interpreter_module.lock() == nullptr) {
491 m_interpreter_module = module_sp;
492 } else if (module_sp == interpreter_sp) {
493 // Module already loaded.
494 return;
495 }
496 }
497 }
498
499 // Note: in a multi-threaded environment, these module lists may be
500 // appended to out-of-order. This is fine, since there's no
501 // expectation for `loaded_modules` or `new_modules` to be in any
502 // particular order, and appending to each module list is thread-safe.
503 // Also, `new_modules` is only used for the `ModulesDidLoad` call at
504 // the end of this function.
505 loaded_modules.AppendIfNeeded(module_sp);
506 new_modules.Append(module_sp);
507 };
508
509 if (m_process->GetTarget().GetParallelModuleLoad()) {
510 llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
511 for (; I != E; ++I)
512 task_group.async(load_module_fn, *I);
513 task_group.wait();
514 } else {
515 for (; I != E; ++I)
516 load_module_fn(*I);
517 }
518
519 m_process->GetTarget().ModulesDidLoad(new_modules);
520 }
521
522 if (m_rendezvous.ModulesDidUnload()) {
523 ModuleList old_modules;
524
525 E = m_rendezvous.unloaded_end();
526 for (I = m_rendezvous.unloaded_begin(); I != E; ++I) {
527 ModuleSpec module_spec{I->file_spec};
528 ModuleSP module_sp = loaded_modules.FindFirstModule(module_spec);
529
530 if (module_sp.get()) {
531 old_modules.Append(module_sp);
532 UnloadSections(module_sp);
533 }
534 }
535 loaded_modules.Remove(old_modules);
536 m_process->GetTarget().ModulesDidUnload(old_modules, false);
537 }
538}
539
542 bool stop) {
543 ThreadPlanSP thread_plan_sp;
544
545 StackFrame *frame = thread.GetStackFrameAtIndex(0).get();
546 const SymbolContext &context = frame->GetSymbolContext(eSymbolContextSymbol);
547 const Symbol *sym = context.symbol;
548
549 if (sym == nullptr || !sym->IsTrampoline())
550 return thread_plan_sp;
551
553 if (!sym_name)
554 return thread_plan_sp;
555
556 SymbolContextList target_symbols;
557 Target &target = thread.GetProcess()->GetTarget();
558 const ModuleList &images = target.GetImages();
559
560 llvm::StringRef target_name = sym_name.GetStringRef();
561 // On AArch64, the trampoline name has a prefix (__AArch64ADRPThunk_ or
562 // __AArch64AbsLongThunk_) added to the function name. If we detect a
563 // trampoline with the prefix, we need to remove the prefix to find the
564 // function symbol.
565 if (target_name.consume_front("__AArch64ADRPThunk_") ||
566 target_name.consume_front("__AArch64AbsLongThunk_")) {
567 // An empty target name can happen for trampolines generated for
568 // section-referencing relocations.
569 if (!target_name.empty()) {
570 sym_name = ConstString(target_name);
571 }
572 }
573 images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols);
574 if (!target_symbols.GetSize())
575 return thread_plan_sp;
576
577 typedef std::vector<lldb::addr_t> AddressVector;
578 AddressVector addrs;
579 for (const SymbolContext &context : target_symbols) {
580 addr_t addr = context.GetFunctionOrSymbolAddress().GetLoadAddress(&target);
581 if (addr != LLDB_INVALID_ADDRESS)
582 addrs.push_back(addr);
583 }
584
585 if (addrs.size() > 0) {
586 AddressVector::iterator start = addrs.begin();
587 AddressVector::iterator end = addrs.end();
588
589 llvm::sort(start, end);
590 addrs.erase(std::unique(start, end), end);
591 thread_plan_sp =
592 std::make_shared<ThreadPlanRunToAddress>(thread, addrs, stop);
593 }
594
595 return thread_plan_sp;
596}
597
600 return;
601
602 FileSpec file("[vdso]");
603
605 MemoryRegionInfo info;
606 Status status = m_process->GetMemoryRegionInfo(m_vdso_base, info);
607 if (status.Fail()) {
608 LLDB_LOG(log, "Failed to get vdso region info: {0}", status);
609 return;
610 }
611
612 llvm::Expected<ModuleSP> module_sp_or_err = m_process->ReadModuleFromMemory(
613 file, m_vdso_base, info.GetRange().GetByteSize());
614 if (auto err = module_sp_or_err.takeError()) {
615 LLDB_LOG_ERROR(log, std::move(err),
616 "Failed to read module from memory: {0}");
617 } else if (ModuleSP module_sp = *module_sp_or_err) {
619 m_process->GetTarget().GetImages().AppendIfNeeded(module_sp);
620 }
621}
622
625 return nullptr;
626
627 MemoryRegionInfo info;
628 Target &target = m_process->GetTarget();
629 Status status = m_process->GetMemoryRegionInfo(m_interpreter_base, info);
630 if (status.Fail() || info.GetMapped() != eLazyBoolYes ||
631 info.GetName().IsEmpty()) {
633 LLDB_LOG(log, "Failed to get interpreter region info: {0}", status);
634 return nullptr;
635 }
636
637 FileSpec file(info.GetName().GetCString());
638 ModuleSpec module_spec(file, target.GetArchitecture());
639
640 // Don't notify that module is added here because its loading section
641 // addresses are not updated yet. We manually notify it below.
642 if (ModuleSP module_sp =
643 target.GetOrCreateModule(module_spec, /*notify=*/false)) {
645 false);
646 // Manually notify that dynamic linker is loaded after updating load section
647 // addersses so that breakpoints can be resolved.
648 ModuleList module_list;
649 module_list.Append(module_sp);
650 target.ModulesDidLoad(module_list);
651 m_interpreter_module = module_sp;
652 return module_sp;
653 }
654 return nullptr;
655}
656
658 addr_t link_map_addr,
659 addr_t base_addr,
660 bool base_addr_is_offset) {
662 file, link_map_addr, base_addr, base_addr_is_offset))
663 return module_sp;
664
665 // This works around an dynamic linker "bug" on android <= 23, where the
666 // dynamic linker would report the application name
667 // (e.g. com.example.myapplication) instead of the main process binary
668 // (/system/bin/app_process(32)). The logic is not sound in general (it
669 // assumes base_addr is the real address, even though it actually is a load
670 // bias), but it happens to work on android because app_process has a file
671 // address of zero.
672 // This should be removed after we drop support for android-23.
673 if (m_process->GetTarget().GetArchitecture().GetTriple().isAndroid()) {
674 MemoryRegionInfo memory_info;
675 Status error = m_process->GetMemoryRegionInfo(base_addr, memory_info);
676 if (error.Success() && memory_info.GetMapped() &&
677 memory_info.GetRange().GetRangeBase() == base_addr &&
678 !(memory_info.GetName().IsEmpty())) {
680 FileSpec(memory_info.GetName().GetStringRef()), link_map_addr,
681 base_addr, base_addr_is_offset))
682 return module_sp;
683 }
684 }
685
686 return nullptr;
687}
688
692 ModuleList module_list;
694
695 LoadVDSO();
696
697 if (!m_rendezvous.Resolve()) {
698 LLDB_LOGF(log,
699 "DynamicLoaderPOSIXDYLD::%s unable to resolve POSIX DYLD "
700 "rendezvous address",
701 __FUNCTION__);
702 return;
703 }
704
705 // The rendezvous class doesn't enumerate the main module, so track that
706 // ourselves here.
707 ModuleSP executable = GetTargetExecutable();
708 SetLoadedModule(executable, m_rendezvous.GetLinkMapAddress());
709
710 Target &target = m_process->GetTarget();
711 std::vector<FileSpec> module_names;
712 for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I)
713 module_names.push_back(I->file_spec);
714 m_process->PrefetchModuleSpecs(module_names,
715 target.GetArchitecture().GetTriple());
716
717 auto load_module_fn = [this, &module_list, &target,
718 &log](const DYLDRendezvous::SOEntry &so_entry) {
719 ModuleSP module_sp = LoadModuleAtAddress(
720 so_entry.file_spec, so_entry.link_addr, so_entry.base_addr, true);
721 if (!module_sp && !m_process->IsLiveDebugSession()) {
722 // Create placeholder modules for any modules we couldn't load from disk
723 // or from memory.
724 ModuleSpec module_spec(so_entry.file_spec, target.GetArchitecture());
725 if (UUID uuid = m_process->FindModuleUUID(so_entry.file_spec.GetPath()))
726 module_spec.GetUUID() = uuid;
728 module_spec, so_entry.base_addr, 512);
729 bool load_addr_changed = false;
730 target.GetImages().Append(module_sp, false);
731 module_sp->SetLoadAddress(target, so_entry.base_addr, false,
732 load_addr_changed);
733 }
734 if (module_sp.get()) {
735 LLDB_LOG(log, "LoadAllCurrentModules loading module: {0}",
736 so_entry.file_spec.GetFilename());
737 module_list.Append(module_sp);
738 } else {
739 LLDB_LOGF(
740 log,
741 "DynamicLoaderPOSIXDYLD::%s failed loading module %s at 0x%" PRIx64,
742 __FUNCTION__, so_entry.file_spec.GetPath().c_str(),
743 so_entry.base_addr);
744 }
745 };
746 if (m_process->GetTarget().GetParallelModuleLoad()) {
747 llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
748 for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I)
749 task_group.async(load_module_fn, *I);
750 task_group.wait();
751 } else {
752 for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I)
753 load_module_fn(*I);
754 }
755
756 m_process->GetTarget().ModulesDidLoad(module_list);
758}
759
761 addr_t virt_entry;
762
764 return m_load_offset;
765
766 if ((virt_entry = GetEntryPoint()) == LLDB_INVALID_ADDRESS)
768
769 ModuleSP module = m_process->GetTarget().GetExecutableModule();
770 if (!module)
772
773 ObjectFile *exe = module->GetObjectFile();
774 if (!exe)
776
777 Address file_entry = exe->GetEntryPointAddress();
778
779 if (!file_entry.IsValid())
781
782 m_load_offset = virt_entry - file_entry.GetFileAddress();
783 return m_load_offset;
784}
785
787 if (std::optional<uint64_t> vdso_base =
789 m_vdso_base = *vdso_base;
790
791 if (std::optional<uint64_t> interpreter_base =
792 m_auxv->GetAuxValue(AuxVector::AUXV_AT_BASE))
793 m_interpreter_base = *interpreter_base;
794}
795
798 return m_entry_point;
799
800 if (m_auxv == nullptr)
802
803 std::optional<uint64_t> entry_point =
804 m_auxv->GetAuxValue(AuxVector::AUXV_AT_ENTRY);
805 if (!entry_point)
807
808 m_entry_point = static_cast<addr_t>(*entry_point);
809
810 const ArchSpec &arch = m_process->GetTarget().GetArchitecture();
811
812 // On ppc64, the entry point is actually a descriptor. Dereference it.
813 if (arch.GetMachine() == llvm::Triple::ppc64)
815
816 return m_entry_point;
817}
818
819static lldb::addr_t GetPTTLSVAddr(const lldb::ModuleSP &module_sp) {
820 if (!module_sp)
822
823 ObjectFile *objfile = module_sp->GetObjectFile();
824 if (!objfile)
826
827 auto *elf_obj = llvm::dyn_cast<ObjectFileELF>(objfile);
828 if (!elf_obj)
830
831 for (const auto &phdr : elf_obj->ProgramHeaders()) {
832 if (phdr.p_type == llvm::ELF::PT_TLS)
833 return phdr.p_vaddr;
834 }
835
837}
838
841 const lldb::ThreadSP thread,
842 lldb::addr_t tls_file_addr) {
844 std::optional<addr_t> link_map_addr_opt = GetLoadedModuleLinkAddr(module_sp);
845 if (!link_map_addr_opt.has_value()) {
846 LLDB_LOG(
847 log,
848 "GetThreadLocalData error: module({0}) not found in loaded modules",
849 module_sp->GetObjectName());
851 }
852
853 addr_t link_map = link_map_addr_opt.value();
854 if (link_map == LLDB_INVALID_ADDRESS || link_map == 0) {
855 LLDB_LOGF(log,
856 "GetThreadLocalData error: invalid link map address=0x%" PRIx64,
857 link_map);
859 }
860
861 const DYLDRendezvous::ThreadInfo &metadata = m_rendezvous.GetThreadInfo();
862 if (!metadata.valid) {
863 LLDB_LOGF(log,
864 "GetThreadLocalData error: fail to read thread info metadata");
866 }
867
868 LLDB_LOGF(log,
869 "GetThreadLocalData info: link_map=0x%" PRIx64
870 ", thread info metadata: "
871 "modid_offset=0x%" PRIx32 ", pthread_size=0x%" PRIx32
872 ", dtv_offset=0x%" PRIx32 ", tls_offset=0x%" PRIx32
873 ", dtv_slot_size=%" PRIx32 "\n",
874 link_map, metadata.modid_offset, metadata.pthread_size,
875 metadata.dtv_offset, metadata.tls_offset, metadata.dtv_slot_size);
876
877 // Get the thread pointer.
878 addr_t tp = thread->GetThreadPointer();
879 if (tp == LLDB_INVALID_ADDRESS) {
880 LLDB_LOGF(log, "GetThreadLocalData error: fail to read thread pointer");
882 }
883
884 // Find the module's modid.
885 int modid_size = 4; // FIXME(spucci): This isn't right for big-endian 64-bit
886 int64_t modid = ReadUnsignedIntWithSizeInBytes(
887 link_map + metadata.modid_offset, modid_size);
888 if (modid == -1) {
889 LLDB_LOGF(log, "GetThreadLocalData error: fail to read modid");
891 }
892
893 // Lookup the DTV structure for this thread.
895 if (metadata.dtv_offset < metadata.pthread_size) {
896 // The DTV pointer field lies within `pthread`. This indicates that `libc`
897 // placed `tcbhead_t header`, which contains the `dtv` field, inside
898 // `pthread`, so, for this architecture, `TLS_TCB_AT_TP` is set to `1` and
899 // `TLS_DTV_AT_TP` is `0`. This corresponds to the "Variant II" memory
900 // layout described in Ulrich Drepper's ELF TLS document
901 // (https://akkadia.org/drepper/tls.pdf). The thread pointer points to the
902 // start of `pthread`, and the address of the `dtv` field can be calculated
903 // by adding its offset.
904 dtv_ptr = tp + metadata.dtv_offset;
905 } else if (metadata.dtv_offset == metadata.pthread_size) {
906 // The DTV pointer field is located right after `pthread`. This means that,
907 // for this architecture, `TLS_DTV_AT_TP` is set to `1` in `libc`, which may
908 // correspond to the "Variant I" memory layout, in which the thread pointer
909 // points directly to the `dtv` field. However, for different architectures,
910 // the position of the `dtv` field relative to the thread pointer may vary,
911 // so the following calculations must be adjusted for each platform.
912 //
913 // On AArch64 and ARM, `tp` is known to point directly to `dtv`.
914 const llvm::Triple &triple = module_sp->GetArchitecture().GetTriple();
915 if (triple.isAArch64() || triple.isARM()) {
916 dtv_ptr = tp;
917 }
918 }
919 const llvm::Triple &triple = module_sp->GetArchitecture().GetTriple();
920
921 // On RISC-V with glibc the TLS layout uses Variant I (TLS_DTV_AT_TP).
922 // The thread pointer (tp) points just past a tcbhead_t header which
923 // contains two pointers: { dtv, private }. This means the DTV pointer
924 // itself is located two pointer-sized slots before tp, so dtv_ptr must
925 // be computed as tp - 2 * sizeof(void*). See MaskRay, “All about
926 // thread-local storage” (RISC-V/glibc section) and glibc's RISC-V
927 // TLS port (__tls_get_addr / THREAD_DTV).
928 if (triple.isRISCV())
929 dtv_ptr = tp - 2 * triple.getArchPointerBitWidth() / 8;
930
931 addr_t dtv = (dtv_ptr != LLDB_INVALID_ADDRESS) ? ReadPointer(dtv_ptr)
933 if (dtv == LLDB_INVALID_ADDRESS) {
934 LLDB_LOGF(log, "GetThreadLocalData error: fail to read dtv");
936 }
937
938 // Find the TLS block for this module.
939 addr_t dtv_slot = dtv + metadata.dtv_slot_size * modid;
940 addr_t tls_block = ReadPointer(dtv_slot + metadata.tls_offset);
941
942 LLDB_LOGF(log,
943 "DynamicLoaderPOSIXDYLD::Performed TLS lookup: "
944 "module=%s, link_map=0x%" PRIx64 ", tp=0x%" PRIx64
945 ", modid=%" PRId64 ", tls_block=0x%" PRIx64 "\n",
946 module_sp->GetObjectName().AsCString(""), link_map, tp,
947 (int64_t)modid, tls_block);
948
949 if (tls_block == LLDB_INVALID_ADDRESS) {
950 LLDB_LOGF(log, "GetThreadLocalData error: fail to read tls_block");
952 }
953
954 // DW_OP_GNU_push_tls_address gives us a value in tls_file_addr that can be
955 // either:
956 // - a pure offset inside the TLS block (e.g. x86_64/glibc), or
957 // - a virtual address inside the PT_TLS segment (e.g. RISC-V/glibc),
958 // roughly PT_TLS.p_vaddr + TPOFF(sym).
959 // To handle both cases, we try to normalize it to a plain offset (tpoff)
960 // by subtracting PT_TLS.p_vaddr when available.
961 addr_t pt_tls_vaddr = GetPTTLSVAddr(module_sp);
962 addr_t tpoff = tls_file_addr;
963
964 // If the module has a PT_TLS segment and the DWARF value lies at or above
965 // its p_vaddr, treat tls_file_addr as a VMA within PT_TLS and convert it
966 // to an offset. Otherwise, keep the original value (it is already an offset
967 // on targets like x86_64).
968 if (pt_tls_vaddr != LLDB_INVALID_ADDRESS && tls_file_addr >= pt_tls_vaddr)
969 tpoff = tls_file_addr - pt_tls_vaddr;
970
971 return tls_block + tpoff;
972}
973
975 lldb::ModuleSP &module_sp) {
977
978 if (m_process == nullptr)
979 return;
980
981 auto &target = m_process->GetTarget();
982 const auto platform_sp = target.GetPlatform();
983
984 ProcessInstanceInfo process_info;
985 if (!m_process->GetProcessInfo(process_info)) {
986 LLDB_LOGF(log,
987 "DynamicLoaderPOSIXDYLD::%s - failed to get process info for "
988 "pid %" PRIu64,
989 __FUNCTION__, m_process->GetID());
990 return;
991 }
992
993 LLDB_LOGF(
994 log, "DynamicLoaderPOSIXDYLD::%s - got executable by pid %" PRIu64 ": %s",
995 __FUNCTION__, m_process->GetID(),
996 process_info.GetExecutableFile().GetPath().c_str());
997
998 ModuleSpec module_spec(process_info.GetExecutableFile(),
999 process_info.GetArchitecture());
1000 if (module_sp && module_sp->MatchesModuleSpec(module_spec))
1001 return;
1002
1003 module_spec.SetTarget(target.shared_from_this());
1004 const auto executable_search_paths(Target::GetDefaultExecutableSearchPaths());
1005 auto error = platform_sp->ResolveExecutable(module_spec, module_sp);
1006 if (error.Fail()) {
1007 StreamString stream;
1008 module_spec.Dump(stream);
1009
1010 LLDB_LOGF(log,
1011 "DynamicLoaderPOSIXDYLD::%s - failed to resolve executable "
1012 "with module spec \"%s\": %s",
1013 __FUNCTION__, stream.GetData(), error.AsCString());
1014 return;
1015 }
1016
1017 target.SetExecutableModule(module_sp, eLoadDependentsNo);
1018}
1019
1021 lldb_private::SymbolContext &sym_ctx) {
1022 ModuleSP module_sp;
1023 if (sym_ctx.symbol)
1024 module_sp = sym_ctx.symbol->GetAddressRef().GetModule();
1025 if (!module_sp && sym_ctx.function)
1026 module_sp = sym_ctx.function->GetAddress().GetModule();
1027 if (!module_sp)
1028 return false;
1029
1030 return module_sp->GetFileSpec().GetPath() == "[vdso]";
1031}
1032
1034 return !m_process->IsLiveDebugSession();
1035}
1036
1037// For our ELF/POSIX builds save off the fs_base/gs_base regions
1038static void AddThreadLocalMemoryRegions(Process &process, ThreadSP &thread_sp,
1039 std::vector<MemoryRegionInfo> &ranges) {
1040 lldb::RegisterContextSP reg_ctx = thread_sp->GetRegisterContext();
1041 if (!reg_ctx)
1042 return;
1043
1044 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
1046 if (!reg_info)
1047 return;
1048
1049 lldb_private::RegisterValue thread_local_register_value;
1050 bool success = reg_ctx->ReadRegister(reg_info, thread_local_register_value);
1051 if (!success)
1052 return;
1053
1054 const uint64_t fail_value = UINT64_MAX;
1055 bool readSuccess = false;
1056 const lldb::addr_t reg_value_addr =
1057 thread_local_register_value.GetAsUInt64(fail_value, &readSuccess);
1058 if (!readSuccess || reg_value_addr == fail_value)
1059 return;
1060
1061 MemoryRegionInfo thread_local_region;
1062 Status err = process.GetMemoryRegionInfo(reg_value_addr, thread_local_region);
1063 if (err.Fail())
1064 return;
1065
1066 ranges.push_back(thread_local_region);
1067}
1068
1069// Save off the link map for core files.
1070static void AddLinkMapSections(Process &process,
1071 std::vector<MemoryRegionInfo> &ranges) {
1072 ModuleList &module_list = process.GetTarget().GetImages();
1073 Target *target = &process.GetTarget();
1074 for (size_t idx = 0; idx < module_list.GetSize(); idx++) {
1075 ModuleSP module_sp = module_list.GetModuleAtIndex(idx);
1076 if (!module_sp)
1077 continue;
1078
1079 ObjectFile *obj = module_sp->GetObjectFile();
1080 if (!obj)
1081 continue;
1082 Address addr = obj->GetImageInfoAddress(target);
1083 addr_t load_addr = addr.GetLoadAddress(target);
1084 if (load_addr == LLDB_INVALID_ADDRESS)
1085 continue;
1086
1087 MemoryRegionInfo link_map_section;
1088 Status err = process.GetMemoryRegionInfo(load_addr, link_map_section);
1089 if (err.Fail())
1090 continue;
1091
1092 ranges.push_back(link_map_section);
1093 }
1094}
1095
1097 lldb_private::Process &process,
1098 std::vector<lldb_private::MemoryRegionInfo> &ranges,
1099 llvm::function_ref<bool(const lldb_private::Thread &)>
1100 save_thread_predicate) {
1101 ThreadList &thread_list = process.GetThreadList();
1102 for (size_t idx = 0; idx < thread_list.GetSize(); idx++) {
1103 ThreadSP thread_sp = thread_list.GetThreadAtIndex(idx);
1104 if (!thread_sp)
1105 continue;
1106
1107 if (!save_thread_predicate(*thread_sp))
1108 continue;
1109
1110 AddThreadLocalMemoryRegions(process, thread_sp, ranges);
1111 }
1112
1113 AddLinkMapSections(process, ranges);
1114}
static llvm::raw_ostream & error(Stream &strm)
static lldb::addr_t GetPTTLSVAddr(const lldb::ModuleSP &module_sp)
static void AddLinkMapSections(Process &process, std::vector< MemoryRegionInfo > &ranges)
static void AddThreadLocalMemoryRegions(Process &process, ThreadSP &thread_sp, std::vector< MemoryRegionInfo > &ranges)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:364
#define LLDB_LOGF(log,...)
Definition Log.h:378
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:394
#define LLDB_PLUGIN_DEFINE_ADV(ClassName, PluginName)
@ AUXV_AT_SYSINFO_EHDR
Definition AuxVector.h:64
@ AUXV_AT_ENTRY
Program entry point.
Definition AuxVector.h:36
@ AUXV_AT_BASE
Interpreter base address.
Definition AuxVector.h:34
SOEntryList::const_iterator iterator
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...
std::map< lldb::ModuleWP, lldb::addr_t, std::owner_less< lldb::ModuleWP > > m_loaded_modules
Loaded module list.
static lldb_private::DynamicLoader * CreateInstance(lldb_private::Process *process, bool force)
llvm::sys::RWMutex m_loaded_modules_rw_mutex
bool m_initial_modules_added
Indicates whether the initial set of modules was reported added.
lldb::addr_t m_load_offset
Virtual load address of the inferior process.
lldb::break_id_t m_dyld_bid
Rendezvous breakpoint.
lldb::addr_t GetEntryPoint()
Computes a value for m_entry_point returning the computed address on success and LLDB_INVALID_ADDRESS...
std::unique_ptr< AuxVector > m_auxv
Auxiliary vector of the inferior process.
static llvm::StringRef GetPluginDescriptionStatic()
void EvalSpecialModulesStatus()
Evaluate if Aux vectors contain vDSO and LD information in case they do, read and assign the address ...
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.
bool SetRendezvousBreakpoint()
If possible sets a breakpoint on a function called by the runtime linker each time a module is loaded...
void RefreshModules()
Helper method for RendezvousBreakpointHit.
bool AlwaysRelyOnEHUnwindInfo(lldb_private::SymbolContext &sym_ctx) override
Ask if the eh_frame information for the given SymbolContext should be relied on even when it's the fi...
lldb::addr_t m_interpreter_base
Contains AT_BASE, which means a dynamic loader has been mapped to the address space.
void ProbeEntry()
Resolves the entry point for the current inferior process and sets a breakpoint at that address.
lldb_private::Status CanLoadImage() override
Ask if it is ok to try and load or unload an shared library (image).
lldb::addr_t m_vdso_base
Contains AT_SYSINFO_EHDR, which means a vDSO has been mapped to the address space.
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.
lldb::addr_t ComputeLoadOffset()
Computes a value for m_load_offset returning the computed address on success and LLDB_INVALID_ADDRESS...
void SetLoadedModule(const lldb::ModuleSP &module_sp, lldb::addr_t link_map_addr)
void UnloadSections(const lldb::ModuleSP module) override
Removes the loaded sections from the target in module.
std::optional< lldb::addr_t > GetLoadedModuleLinkAddr(const lldb::ModuleSP &module_sp)
DYLDRendezvous m_rendezvous
Runtime linker rendezvous structure.
void DidLaunch() override
Called after launching a process.
lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset) override
Locates or creates a module given by file and updates/loads the resulting module at the virtual base ...
static bool EntryBreakpointHit(void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Callback routine invoked when we hit the breakpoint on process entry.
void DidAttach() override
Called after attaching a process.
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.
static llvm::StringRef GetPluginNameStatic()
void ResolveExecutableModule(lldb::ModuleSP &module_sp)
Loads Module from inferior process.
lldb::addr_t m_entry_point
Virtual entry address of the inferior process.
virtual void LoadAllCurrentModules()
Helper for the entry breakpoint callback.
std::weak_ptr< lldb_private::Module > m_interpreter_module
Contains the pointer to the interpret module, if loaded.
bool IsCoreFile() const
Returns true if the process is for a core file.
DynamicLoaderPOSIXDYLD(lldb_private::Process *process)
void CalculateDynamicSaveCoreRanges(lldb_private::Process &process, std::vector< lldb_private::MemoryRegionInfo > &ranges, llvm::function_ref< bool(const lldb_private::Thread &)> save_thread_predicate) override
void UnloadModule(const lldb::ModuleSP &module_sp)
A section + offset based address class.
Definition Address.h:62
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition Address.cpp:301
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
Definition Address.cpp:273
lldb::addr_t GetFileAddress() const
Get the file address.
Definition Address.cpp:281
bool IsValid() const
Check if the object state is valid.
Definition Address.h:355
An architecture specification class.
Definition ArchSpec.h:32
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition ArchSpec.h:457
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition ArchSpec.cpp:673
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition Breakpoint.h:81
void SetOneShot(bool one_shot)
If one_shot is true, breakpoint will be deleted on first hit.
void SetBreakpointKind(const char *kind)
Set the "kind" description for a breakpoint.
Definition Breakpoint.h:482
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.
Definition ConstString.h:40
bool IsEmpty() const
Test for empty string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
static llvm::ThreadPoolInterface & GetThreadPool()
Shared thread pool. Use only with ThreadPoolTaskGroup.
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 ...
DynamicLoader(Process *process)
Construct with a process.
void UnloadSectionsCommon(const lldb::ModuleSP module)
A file collection class.
void Append(const FileSpec &file)
Append a FileSpec object to the list.
A file utility class.
Definition FileSpec.h:57
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:374
const Address & GetAddress() const
Return the address of the function (its entry point).
Definition Function.h:453
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
Definition Mangled.cpp:369
A collection class for Module objects.
Definition ModuleList.h:125
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.
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
ModuleIterable Modules() const
Definition ModuleList.h:570
size_t GetSize() const
Gets the size of the module list.
void Dump(Stream &strm) const
Definition ModuleSpec.h:187
void SetTarget(lldb::TargetSP target)
Set the target to be used when resolving a module.
Definition ModuleSpec.h:141
static lldb::ModuleSP CreateModuleFromObjectFile(Args &&...args)
Definition Module.h:135
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:46
virtual lldb_private::Address GetImageInfoAddress(Target *target)
Similar to Process::GetImageInfoAddress().
Definition ObjectFile.h:442
virtual lldb_private::Address GetEntryPointAddress()
Returns the address of the Entry Point in this object file - if the object file doesn't have an entry...
Definition ObjectFile.h:452
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
FileSpec & GetExecutableFile()
Definition ProcessInfo.h:43
ArchSpec & GetArchitecture()
Definition ProcessInfo.h:62
A plug-in interface definition class for debugging a process.
Definition Process.h:355
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
Definition Process.h:538
ThreadList & GetThreadList()
Definition Process.h:2312
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
Locate the memory region that contains load_addr.
Definition Process.cpp:6417
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1251
uint64_t GetAsUInt64(uint64_t fail_value=UINT64_MAX, bool *success_ptr=nullptr) const
This base class provides an interface to stack frames.
Definition StackFrame.h:44
virtual const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
An error handling class.
Definition Status.h:118
bool Fail() const
Test for error condition.
Definition Status.cpp:293
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
const char * GetData() 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.
Function * function
The Function for a given query.
Symbol * symbol
The Symbol for a given query.
Address GetFunctionOrSymbolAddress() const
Get the address of the function or symbol represented by this symbol context.
Mangled & GetMangled()
Definition Symbol.h:147
bool IsTrampoline() const
Definition Symbol.cpp:221
Address & GetAddressRef()
Definition Symbol.h:73
void ModulesDidLoad(ModuleList &module_list)
This call may preload module symbols, and may do so in parallel depending on the following target set...
Definition Target.cpp:1841
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:423
bool RemoveBreakpointByID(lldb::break_id_t break_id)
Definition Target.cpp:1107
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...
Definition Target.cpp:2338
static FileSpecList GetDefaultExecutableSearchPaths()
Definition Target.cpp:2786
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)
Definition Target.cpp:490
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition Target.h:1157
const ArchSpec & GetArchitecture() const
Definition Target.h:1199
uint32_t GetSize(bool can_update=true)
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
Represents UUID's of various sizes.
Definition UUID.h:27
#define UINT64_MAX
#define LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_ADDRESS
#define LLDB_REGNUM_GENERIC_TP
#define LLDB_INVALID_PROCESS_ID
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.
Definition Log.h:327
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
std::shared_ptr< lldb_private::Thread > ThreadSP
@ eLanguageTypeC
Non-standardized C, such as K&R.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
uint64_t user_id_t
Definition lldb-types.h:82
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
std::shared_ptr< lldb_private::Module > ModuleSP
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
Structure representing the shared objects currently loaded into the inferior process.
BaseType GetRangeBase() const
Definition RangeMap.h:45
SizeType GetByteSize() const
Definition RangeMap.h:87
Every register is described in detail including its name, alternate name (optional),...