LLDB  mainline
DynamicLoaderHexagonDYLD.cpp
Go to the documentation of this file.
1 //===-- DynamicLoaderHexagonDYLD.cpp ----------------------------*- C++ -*-===//
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 
10 #include "lldb/Core/Module.h"
11 #include "lldb/Core/ModuleSpec.h"
13 #include "lldb/Core/Section.h"
14 #include "lldb/Symbol/ObjectFile.h"
15 #include "lldb/Target/Process.h"
16 #include "lldb/Target/Target.h"
17 #include "lldb/Target/Thread.h"
19 #include "lldb/Utility/Log.h"
20 
22 
23 #include <memory>
24 
25 using namespace lldb;
26 using namespace lldb_private;
27 
28 // Aidan 21/05/2014
29 //
30 // Notes about hexagon dynamic loading:
31 //
32 // When we connect to a target we find the dyld breakpoint address. We put
33 // a
34 // breakpoint there with a callback 'RendezvousBreakpointHit()'.
35 //
36 // It is possible to find the dyld structure address from the ELF symbol
37 // table,
38 // but in the case of the simulator it has not been initialized before the
39 // target calls dlinit().
40 //
41 // We can only safely parse the dyld structure after we hit the dyld
42 // breakpoint
43 // since at that time we know dlinit() must have been called.
44 //
45 
46 // Find the load address of a symbol
48  assert(proc != nullptr);
49 
50  ModuleSP module = proc->GetTarget().GetExecutableModule();
51  assert(module.get() != nullptr);
52 
53  ObjectFile *exe = module->GetObjectFile();
54  assert(exe != nullptr);
55 
56  lldb_private::Symtab *symtab = exe->GetSymtab();
57  assert(symtab != nullptr);
58 
59  for (size_t i = 0; i < symtab->GetNumSymbols(); i++) {
60  const Symbol *sym = symtab->SymbolAtIndex(i);
61  assert(sym != nullptr);
62  ConstString symName = sym->GetName();
63 
64  if (ConstString::Compare(findName, symName) == 0) {
65  Address addr = sym->GetAddress();
66  return addr.GetLoadAddress(&proc->GetTarget());
67  }
68  }
69  return LLDB_INVALID_ADDRESS;
70 }
71 
73  PluginManager::RegisterPlugin(GetPluginNameStatic(),
74  GetPluginDescriptionStatic(), CreateInstance);
75 }
76 
78 
80  return GetPluginNameStatic();
81 }
82 
84  static ConstString g_name("hexagon-dyld");
85  return g_name;
86 }
87 
89  return "Dynamic loader plug-in that watches for shared library "
90  "loads/unloads in Hexagon processes.";
91 }
92 
94 
96  bool force) {
97  bool create = force;
98  if (!create) {
99  const llvm::Triple &triple_ref =
100  process->GetTarget().GetArchitecture().GetTriple();
101  if (triple_ref.getArch() == llvm::Triple::hexagon)
102  create = true;
103  }
104 
105  if (create)
106  return new DynamicLoaderHexagonDYLD(process);
107  return NULL;
108 }
109 
111  : DynamicLoader(process), m_rendezvous(process),
112  m_load_offset(LLDB_INVALID_ADDRESS), m_entry_point(LLDB_INVALID_ADDRESS),
113  m_dyld_bid(LLDB_INVALID_BREAK_ID) {}
114 
119  }
120 }
121 
123  ModuleSP executable;
124  addr_t load_offset;
125 
126  executable = GetTargetExecutable();
127 
128  // Find the difference between the desired load address in the elf file and
129  // the real load address in memory
130  load_offset = ComputeLoadOffset();
131 
132  // Check that there is a valid executable
133  if (executable.get() == nullptr)
134  return;
135 
136  // Disable JIT for hexagon targets because its not supported
137  m_process->SetCanJIT(false);
138 
139  // Enable Interpreting of function call expressions
141 
142  // Add the current executable to the module list
143  ModuleList module_list;
144  module_list.Append(executable);
145 
146  // Map the loaded sections of this executable
147  if (load_offset != LLDB_INVALID_ADDRESS)
148  UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, load_offset, true);
149 
150  // AD: confirm this?
151  // Load into LLDB all of the currently loaded executables in the stub
153 
154  // AD: confirm this?
155  // Callback for the target to give it the loaded module list
156  m_process->GetTarget().ModulesDidLoad(module_list);
157 
158  // Try to set a breakpoint at the rendezvous breakpoint. DidLaunch uses
159  // ProbeEntry() instead. That sets a breakpoint, at the dyld breakpoint
160  // address, with a callback so that when hit, the dyld structure can be
161  // parsed.
162  if (!SetRendezvousBreakpoint()) {
163  // fail
164  }
165 }
166 
168 
169 /// Checks to see if the target module has changed, updates the target
170 /// accordingly and returns the target executable module.
172  Target &target = m_process->GetTarget();
173  ModuleSP executable = target.GetExecutableModule();
174 
175  // There is no executable
176  if (!executable.get())
177  return executable;
178 
179  // The target executable file does not exits
180  if (!FileSystem::Instance().Exists(executable->GetFileSpec()))
181  return executable;
182 
183  // Prep module for loading
184  ModuleSpec module_spec(executable->GetFileSpec(),
185  executable->GetArchitecture());
186  ModuleSP module_sp(new Module(module_spec));
187 
188  // Check if the executable has changed and set it to the target executable if
189  // they differ.
190  if (module_sp.get() && module_sp->GetUUID().IsValid() &&
191  executable->GetUUID().IsValid()) {
192  // if the executable has changed ??
193  if (module_sp->GetUUID() != executable->GetUUID())
194  executable.reset();
195  } else if (executable->FileHasChanged())
196  executable.reset();
197 
198  if (executable.get())
199  return executable;
200 
201  // TODO: What case is this code used?
202  executable = target.GetOrCreateModule(module_spec, true /* notify */);
203  if (executable.get() != target.GetExecutableModulePointer()) {
204  // Don't load dependent images since we are in dyld where we will know and
205  // find out about all images that are loaded
206  target.SetExecutableModule(executable, eLoadDependentsNo);
207  }
208 
209  return executable;
210 }
211 
212 // AD: Needs to be updated?
214 
216  addr_t link_map_addr,
217  addr_t base_addr,
218  bool base_addr_is_offset) {
219  Target &target = m_process->GetTarget();
220  const SectionList *sections = GetSectionListFromModule(module);
221 
222  assert(sections && "SectionList missing from loaded module.");
223 
224  m_loaded_modules[module] = link_map_addr;
225 
226  const size_t num_sections = sections->GetSize();
227 
228  for (unsigned i = 0; i < num_sections; ++i) {
229  SectionSP section_sp(sections->GetSectionAtIndex(i));
230  lldb::addr_t new_load_addr = section_sp->GetFileAddress() + base_addr;
231 
232  // AD: 02/05/14
233  // since our memory map starts from address 0, we must not ignore
234  // sections that load to address 0. This violates the reference
235  // ELF spec, however is used for Hexagon.
236 
237  // If the file address of the section is zero then this is not an
238  // allocatable/loadable section (property of ELF sh_addr). Skip it.
239  // if (new_load_addr == base_addr)
240  // continue;
241 
242  target.SetSectionLoadAddress(section_sp, new_load_addr);
243  }
244 }
245 
246 /// Removes the loaded sections from the target in \p module.
247 ///
248 /// \param module The module to traverse.
249 void DynamicLoaderHexagonDYLD::UnloadSections(const ModuleSP module) {
250  Target &target = m_process->GetTarget();
251  const SectionList *sections = GetSectionListFromModule(module);
252 
253  assert(sections && "SectionList missing from unloaded module.");
254 
255  m_loaded_modules.erase(module);
256 
257  const size_t num_sections = sections->GetSize();
258  for (size_t i = 0; i < num_sections; ++i) {
259  SectionSP section_sp(sections->GetSectionAtIndex(i));
260  target.SetSectionUnloaded(section_sp);
261  }
262 }
263 
264 // Place a breakpoint on <_rtld_debug_state>
267 
268  // This is the original code, which want to look in the rendezvous structure
269  // to find the breakpoint address. Its backwards for us, since we can easily
270  // find the breakpoint address, since it is exported in our executable. We
271  // however know that we cant read the Rendezvous structure until we have hit
272  // the breakpoint once.
273  const ConstString dyldBpName("_rtld_debug_state");
274  addr_t break_addr = findSymbolAddress(m_process, dyldBpName);
275 
276  Target &target = m_process->GetTarget();
277 
278  // Do not try to set the breakpoint if we don't know where to put it
279  if (break_addr == LLDB_INVALID_ADDRESS) {
280  if (log)
281  log->Printf("Unable to locate _rtld_debug_state breakpoint address");
282 
283  return false;
284  }
285 
286  // Save the address of the rendezvous structure
287  m_rendezvous.SetBreakAddress(break_addr);
288 
289  // If we haven't set the breakpoint before then set it
291  Breakpoint *dyld_break =
292  target.CreateBreakpoint(break_addr, true, false).get();
293  dyld_break->SetCallback(RendezvousBreakpointHit, this, true);
294  dyld_break->SetBreakpointKind("shared-library-event");
295  m_dyld_bid = dyld_break->GetID();
296 
297  // Make sure our breakpoint is at the right address.
298  assert(target.GetBreakpointByID(m_dyld_bid)
299  ->FindLocationByAddress(break_addr)
300  ->GetBreakpoint()
301  .GetID() == m_dyld_bid);
302 
303  if (log && dyld_break == nullptr)
304  log->Printf("Failed to create _rtld_debug_state breakpoint");
305 
306  // check we have successfully set bp
307  return (dyld_break != nullptr);
308  } else
309  // rendezvous already set
310  return true;
311 }
312 
313 // We have just hit our breakpoint at <_rtld_debug_state>
315  void *baton, StoppointCallbackContext *context, user_id_t break_id,
316  user_id_t break_loc_id) {
318 
319  if (log)
320  log->Printf("Rendezvous breakpoint hit!");
321 
322  DynamicLoaderHexagonDYLD *dyld_instance = nullptr;
323  dyld_instance = static_cast<DynamicLoaderHexagonDYLD *>(baton);
324 
325  // if the dyld_instance is still not valid then try to locate it on the
326  // symbol table
327  if (!dyld_instance->m_rendezvous.IsValid()) {
328  Process *proc = dyld_instance->m_process;
329 
330  const ConstString dyldStructName("_rtld_debug");
331  addr_t structAddr = findSymbolAddress(proc, dyldStructName);
332 
333  if (structAddr != LLDB_INVALID_ADDRESS) {
334  dyld_instance->m_rendezvous.SetRendezvousAddress(structAddr);
335 
336  if (log)
337  log->Printf("Found _rtld_debug structure @ 0x%08" PRIx64, structAddr);
338  } else {
339  if (log)
340  log->Printf("Unable to resolve the _rtld_debug structure");
341  }
342  }
343 
344  dyld_instance->RefreshModules();
345 
346  // Return true to stop the target, false to just let the target run.
347  return dyld_instance->GetStopWhenImagesChange();
348 }
349 
350 /// Helper method for RendezvousBreakpointHit. Updates LLDB's current set
351 /// of loaded modules.
354 
355  if (!m_rendezvous.Resolve())
356  return;
357 
360 
361  ModuleList &loaded_modules = m_process->GetTarget().GetImages();
362 
364  ModuleList new_modules;
365 
366  E = m_rendezvous.loaded_end();
367  for (I = m_rendezvous.loaded_begin(); I != E; ++I) {
368  FileSpec file(I->path);
369  FileSystem::Instance().Resolve(file);
370  ModuleSP module_sp =
371  LoadModuleAtAddress(file, I->link_addr, I->base_addr, true);
372  if (module_sp.get()) {
373  loaded_modules.AppendIfNeeded(module_sp);
374  new_modules.Append(module_sp);
375  }
376 
377  if (log) {
378  log->Printf("Target is loading '%s'", I->path.c_str());
379  if (!module_sp.get())
380  log->Printf("LLDB failed to load '%s'", I->path.c_str());
381  else
382  log->Printf("LLDB successfully loaded '%s'", I->path.c_str());
383  }
384  }
385  m_process->GetTarget().ModulesDidLoad(new_modules);
386  }
387 
389  ModuleList old_modules;
390 
392  for (I = m_rendezvous.unloaded_begin(); I != E; ++I) {
393  FileSpec file(I->path);
394  FileSystem::Instance().Resolve(file);
395  ModuleSpec module_spec(file);
396  ModuleSP module_sp = loaded_modules.FindFirstModule(module_spec);
397 
398  if (module_sp.get()) {
399  old_modules.Append(module_sp);
400  UnloadSections(module_sp);
401  }
402 
403  if (log)
404  log->Printf("Target is unloading '%s'", I->path.c_str());
405  }
406  loaded_modules.Remove(old_modules);
407  m_process->GetTarget().ModulesDidUnload(old_modules, false);
408  }
409 }
410 
411 // AD: This is very different to the Static Loader code.
412 // It may be wise to look over this and its relation to stack
413 // unwinding.
414 ThreadPlanSP
416  bool stop) {
417  ThreadPlanSP thread_plan_sp;
418 
419  StackFrame *frame = thread.GetStackFrameAtIndex(0).get();
420  const SymbolContext &context = frame->GetSymbolContext(eSymbolContextSymbol);
421  Symbol *sym = context.symbol;
422 
423  if (sym == NULL || !sym->IsTrampoline())
424  return thread_plan_sp;
425 
426  const ConstString sym_name = sym->GetMangled().GetName(
427  lldb::eLanguageTypeUnknown, Mangled::ePreferMangled);
428  if (!sym_name)
429  return thread_plan_sp;
430 
431  SymbolContextList target_symbols;
432  Target &target = thread.GetProcess()->GetTarget();
433  const ModuleList &images = target.GetImages();
434 
435  images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols);
436  size_t num_targets = target_symbols.GetSize();
437  if (!num_targets)
438  return thread_plan_sp;
439 
440  typedef std::vector<lldb::addr_t> AddressVector;
441  AddressVector addrs;
442  for (size_t i = 0; i < num_targets; ++i) {
443  SymbolContext context;
444  AddressRange range;
445  if (target_symbols.GetContextAtIndex(i, context)) {
446  context.GetAddressRange(eSymbolContextEverything, 0, false, range);
447  lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(&target);
448  if (addr != LLDB_INVALID_ADDRESS)
449  addrs.push_back(addr);
450  }
451  }
452 
453  if (addrs.size() > 0) {
454  AddressVector::iterator start = addrs.begin();
455  AddressVector::iterator end = addrs.end();
456 
457  llvm::sort(start, end);
458  addrs.erase(std::unique(start, end), end);
459  thread_plan_sp =
460  std::make_shared<ThreadPlanRunToAddress>(thread, addrs, stop);
461  }
462 
463  return thread_plan_sp;
464 }
465 
466 /// Helper for the entry breakpoint callback. Resolves the load addresses
467 /// of all dependent modules.
471  ModuleList module_list;
472 
473  if (!m_rendezvous.Resolve()) {
475  if (log)
476  log->Printf(
477  "DynamicLoaderHexagonDYLD::%s unable to resolve rendezvous address",
478  __FUNCTION__);
479  return;
480  }
481 
482  // The rendezvous class doesn't enumerate the main module, so track that
483  // ourselves here.
484  ModuleSP executable = GetTargetExecutable();
486 
487  for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) {
488  const char *module_path = I->path.c_str();
489  FileSpec file(module_path);
490  ModuleSP module_sp =
491  LoadModuleAtAddress(file, I->link_addr, I->base_addr, true);
492  if (module_sp.get()) {
493  module_list.Append(module_sp);
494  } else {
496  if (log)
497  log->Printf("DynamicLoaderHexagonDYLD::%s failed loading module %s at "
498  "0x%" PRIx64,
499  __FUNCTION__, module_path, I->base_addr);
500  }
501  }
502 
503  m_process->GetTarget().ModulesDidLoad(module_list);
504 }
505 
506 /// Computes a value for m_load_offset returning the computed address on
507 /// success and LLDB_INVALID_ADDRESS on failure.
509  // Here we could send a GDB packet to know the load offset
510  //
511  // send: $qOffsets#4b
512  // get: Text=0;Data=0;Bss=0
513  //
514  // Currently qOffsets is not supported by pluginProcessGDBRemote
515  //
516  return 0;
517 }
518 
519 // Here we must try to read the entry point directly from the elf header. This
520 // is possible if the process is not relocatable or dynamically linked.
521 //
522 // an alternative is to look at the PC if we can be sure that we have connected
523 // when the process is at the entry point.
524 // I dont think that is reliable for us.
527  return m_entry_point;
528  // check we have a valid process
529  if (m_process == nullptr)
530  return LLDB_INVALID_ADDRESS;
531  // Get the current executable module
532  Module &module = *(m_process->GetTarget().GetExecutableModule().get());
533  // Get the object file (elf file) for this module
534  lldb_private::ObjectFile &object = *(module.GetObjectFile());
535  // Check if the file is executable (ie, not shared object or relocatable)
536  if (object.IsExecutable()) {
537  // Get the entry point address for this object
538  lldb_private::Address entry = object.GetEntryPointAddress();
539  // Return the entry point address
540  return entry.GetFileAddress();
541  }
542  // No idea so back out
543  return LLDB_INVALID_ADDRESS;
544 }
545 
546 const SectionList *DynamicLoaderHexagonDYLD::GetSectionListFromModule(
547  const ModuleSP module) const {
548  SectionList *sections = nullptr;
549  if (module.get()) {
550  ObjectFile *obj_file = module->GetObjectFile();
551  if (obj_file) {
552  sections = obj_file->GetSectionList();
553  }
554  }
555  return sections;
556 }
557 
558 static int ReadInt(Process *process, addr_t addr) {
559  Status error;
560  int value = (int)process->ReadUnsignedIntegerFromMemory(
561  addr, sizeof(uint32_t), 0, error);
562  if (error.Fail())
563  return -1;
564  else
565  return value;
566 }
567 
570  const lldb::ThreadSP thread,
571  lldb::addr_t tls_file_addr) {
572  auto it = m_loaded_modules.find(module);
573  if (it == m_loaded_modules.end())
574  return LLDB_INVALID_ADDRESS;
575 
576  addr_t link_map = it->second;
577  if (link_map == LLDB_INVALID_ADDRESS)
578  return LLDB_INVALID_ADDRESS;
579 
580  const HexagonDYLDRendezvous::ThreadInfo &metadata =
582  if (!metadata.valid)
583  return LLDB_INVALID_ADDRESS;
584 
585  // Get the thread pointer.
586  addr_t tp = thread->GetThreadPointer();
587  if (tp == LLDB_INVALID_ADDRESS)
588  return LLDB_INVALID_ADDRESS;
589 
590  // Find the module's modid.
591  int modid = ReadInt(m_process, link_map + metadata.modid_offset);
592  if (modid == -1)
593  return LLDB_INVALID_ADDRESS;
594 
595  // Lookup the DTV structure for this thread.
596  addr_t dtv_ptr = tp + metadata.dtv_offset;
597  addr_t dtv = ReadPointer(dtv_ptr);
598  if (dtv == LLDB_INVALID_ADDRESS)
599  return LLDB_INVALID_ADDRESS;
600 
601  // Find the TLS block for this module.
602  addr_t dtv_slot = dtv + metadata.dtv_slot_size * modid;
603  addr_t tls_block = ReadPointer(dtv_slot + metadata.tls_offset);
604 
605  Module *mod = module.get();
607  if (log)
608  log->Printf("DynamicLoaderHexagonDYLD::Performed TLS lookup: "
609  "module=%s, link_map=0x%" PRIx64 ", tp=0x%" PRIx64
610  ", modid=%i, tls_block=0x%" PRIx64,
611  mod->GetObjectName().AsCString(""), link_map, tp, modid,
612  tls_block);
613 
614  if (tls_block == LLDB_INVALID_ADDRESS)
615  return LLDB_INVALID_ADDRESS;
616  else
617  return tls_block + tls_file_addr;
618 }
lldb_private::ConstString GetPluginName() override
lldb_private::Status CanLoadImage() override
Ask if it is ok to try and load or unload an shared library (image).
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...
bool RemoveBreakpointByID(lldb::break_id_t break_id)
Definition: Target.cpp:940
Defines a list of symbol context objects.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
const ArchSpec & GetArchitecture() const
Definition: Target.h:941
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:224
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
bool IsTrampoline() const
Definition: Symbol.cpp:170
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:292
void UnloadSections(const lldb::ModuleSP module) override
Removes the loaded sections from the target in module.
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 ...
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:78
iterator unloaded_begin() const
Iterators over all modules unloaded from the inferior since the last call to Resolve().
DynamicLoaderHexagonDYLD(lldb_private::Process *process)
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Definition: Module.cpp:1251
HexagonDYLDRendezvous m_rendezvous
Runtime linker rendezvous structure.
A file utility class.
Definition: FileSpec.h:55
bool GetStopWhenImagesChange() const
Get whether the process should stop when images change.
lldb::addr_t GetEntryPoint()
Computes a value for m_entry_point returning the computed address on success and LLDB_INVALID_ADDRESS...
bool SetSectionLoadAddress(const lldb::SectionSP &section, lldb::addr_t load_addr, bool warn_multiple=false)
Definition: Target.cpp:2756
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:272
size_t GetNumSymbols() const
Definition: Symtab.cpp:63
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:58
void SetBreakpointKind(const char *kind)
Set the "kind" description for a breakpoint.
Definition: Breakpoint.h:456
static int ReadInt(Process *process, addr_t addr)
Address GetAddress() const
Definition: Symbol.h:72
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.
void DidAttach() override
Called after attaching a process.
lldb::addr_t m_entry_point
Virtual entry address of the inferior process.
lldb::addr_t GetLinkMapAddress() const
Module * GetExecutableModulePointer()
Definition: Target.cpp:1394
Symbol * symbol
The Symbol for a given query.
static lldb_private::DynamicLoader * CreateInstance(lldb_private::Process *process, bool force)
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:431
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...
uint32_t GetSize() const
Get accessor for a symbol context list size.
void RefreshModules()
Helper method for RendezvousBreakpointHit.
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame&#39;s current pc value.
Definition: StackFrame.cpp:267
void SetCanInterpretFunctionCalls(bool can_interpret_function_calls)
Sets whether executing function calls using the interpreter is possible for this process.
Definition: Process.h:1843
SOEntryList::const_iterator iterator
void SetCallback(BreakpointHitCallback callback, void *baton, bool is_synchronous=false)
Set the callback action invoked when the breakpoint is hit.
Definition: Breakpoint.cpp:421
bool Remove(const lldb::ModuleSP &module_sp, bool notify=true)
Remove a module from the module list.
void LoadAllCurrentModules()
Helper for the entry breakpoint callback.
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
uint64_t user_id_t
Definition: lldb-types.h:84
lldb::addr_t ReadPointer(lldb::addr_t addr)
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Definition: Target.cpp:297
static lldb_private::ConstString GetPluginNameStatic()
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
std::map< lldb::ModuleWP, lldb::addr_t, std::owner_less< lldb::ModuleWP > > m_loaded_modules
Loaded module list. (link map for each module)
A collection class for Module objects.
Definition: ModuleList.h:91
Process * m_process
The process that this dynamic loader plug-in is tracking.
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:109
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Definition: ModuleList.cpp:599
lldb::break_id_t GetID() const
Definition: Stoppoint.cpp:22
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
Definition: ObjectFile.cpp:605
size_t FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list, bool append=false) const
Definition: ModuleList.cpp:457
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:1999
A plug-in interface definition class for debugging a process.
Definition: Process.h:353
lldb::SectionSP GetSectionAtIndex(size_t idx) const
Definition: Section.cpp:497
bool SetRendezvousBreakpoint()
Enables a breakpoint on a function called by the runtime linker each time a module is loaded or unloa...
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition: Target.cpp:1380
A section + offset based address class.
Definition: Address.h:80
void ModulesDidLoad(ModuleList &module_list)
Definition: Target.cpp:1651
void SetRendezvousAddress(lldb::addr_t)
Provide the dyld structure address.
Symbol * SymbolAtIndex(size_t idx)
Definition: Symtab.cpp:203
const ThreadInfo & GetThreadInfo()
lldb::ProcessSP GetProcess() const
Definition: Thread.h:154
ConstString GetObjectName() const
Definition: Module.cpp:1249
A plug-in interface definition class for dynamic loaders.
Definition: DynamicLoader.h:64
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
static const char * GetPluginDescriptionStatic()
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:899
#define LIBLLDB_LOG_DYNAMIC_LOADER
Definition: Logging.h:17
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1194
lldb::addr_t ComputeLoadOffset()
Computes a value for m_load_offset returning the computed address on success and LLDB_INVALID_ADDRESS...
uint64_t addr_t
Definition: lldb-types.h:83
lldb::break_id_t m_dyld_bid
Rendezvous breakpoint.
bool SetSectionUnloaded(const lldb::SectionSP &section_sp)
Definition: Target.cpp:2805
A uniqued constant string class.
Definition: ConstString.h:38
Unknown or invalid language value.
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
void DidLaunch() override
Called after launching a process.
Log * GetLogIfAnyCategoriesSet(uint32_t mask)
Definition: Logging.cpp:61
static bool Compare(BreakpointLocationSP lhs, lldb::break_id_t val)
Definition: SBAddress.h:15
ConstString GetName() const
Definition: Symbol.cpp:494
size_t GetSize() const
Definition: Section.h:83
void ModulesDidUnload(ModuleList &module_list, bool delete_locations)
Definition: Target.cpp:1686
iterator begin() const
Iterators over all currently loaded modules.
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.
bool Resolve()
Update the internal snapshot of runtime linker rendezvous and recompute the currently loaded modules...
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:220
#define LLDB_INVALID_BREAK_ID
Definition: lldb-defines.h:49
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...
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
Definition: Thread.h:395
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.
Definition: Process.cpp:2150
bool AppendIfNeeded(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list, if it is not already there.
void SetExecutableModule(lldb::ModuleSP &module_sp, LoadDependentFiles load_dependent_files=eLoadDependentsDefault)
Set the main executable module.
Definition: Target.cpp:1431
void Printf(const char *format,...) __attribute__((format(printf
Definition: Log.cpp:113
void SetCanJIT(bool can_jit)
Sets whether executing JIT-compiled code in this process is possible.
Definition: Process.cpp:2406
A section + offset based address range class.
Definition: AddressRange.h:32
lldb::ModuleSP GetTargetExecutable()
Checks to see if the target module has changed, updates the target accordingly and returns the target...
iterator loaded_begin() const
Iterators over all modules loaded into the inferior since the last call to Resolve().
This base class provides an interface to stack frames.
Definition: StackFrame.h:40
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:325
static lldb::addr_t findSymbolAddress(Process *proc, ConstString findName)
An error handling class.
Definition: Status.h:44
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.
Mangled & GetMangled()
Definition: Symbol.h:120