LLDB  mainline
Module.cpp
Go to the documentation of this file.
1 //===-- Module.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 #include "lldb/Core/Module.h"
10 
11 #include "lldb/Core/AddressRange.h"
14 #include "lldb/Core/Debugger.h"
15 #include "lldb/Core/FileSpecList.h"
16 #include "lldb/Core/Mangled.h"
17 #include "lldb/Core/ModuleSpec.h"
18 #include "lldb/Core/SearchFilter.h"
19 #include "lldb/Core/Section.h"
20 #include "lldb/Host/FileSystem.h"
21 #include "lldb/Host/Host.h"
22 #include "lldb/Host/HostInfo.h"
26 #include "lldb/Symbol/Function.h"
28 #include "lldb/Symbol/ObjectFile.h"
29 #include "lldb/Symbol/Symbol.h"
31 #include "lldb/Symbol/SymbolFile.h"
33 #include "lldb/Symbol/Symtab.h"
34 #include "lldb/Symbol/Type.h"
35 #include "lldb/Symbol/TypeList.h"
36 #include "lldb/Symbol/TypeMap.h"
37 #include "lldb/Symbol/TypeSystem.h"
38 #include "lldb/Target/Language.h"
39 #include "lldb/Target/Process.h"
40 #include "lldb/Target/Target.h"
43 #include "lldb/Utility/LLDBLog.h"
44 #include "lldb/Utility/Log.h"
46 #include "lldb/Utility/Status.h"
47 #include "lldb/Utility/Stream.h"
49 #include "lldb/Utility/Timer.h"
50 
51 #if defined(_WIN32)
53 #endif
54 
57 
58 #include "llvm/ADT/STLExtras.h"
59 #include "llvm/Support/Compiler.h"
60 #include "llvm/Support/DJB.h"
61 #include "llvm/Support/FileSystem.h"
62 #include "llvm/Support/FormatVariadic.h"
63 #include "llvm/Support/JSON.h"
64 #include "llvm/Support/Signals.h"
65 #include "llvm/Support/raw_ostream.h"
66 
67 #include <cassert>
68 #include <cinttypes>
69 #include <cstdarg>
70 #include <cstdint>
71 #include <cstring>
72 #include <map>
73 #include <optional>
74 #include <type_traits>
75 #include <utility>
76 
77 namespace lldb_private {
79 }
80 namespace lldb_private {
81 class VariableList;
82 }
83 
84 using namespace lldb;
85 using namespace lldb_private;
86 
87 // Shared pointers to modules track module lifetimes in targets and in the
88 // global module, but this collection will track all module objects that are
89 // still alive
90 typedef std::vector<Module *> ModuleCollection;
91 
93  // This module collection needs to live past any module, so we could either
94  // make it a shared pointer in each module or just leak is. Since it is only
95  // an empty vector by the time all the modules have gone away, we just leak
96  // it for now. If we decide this is a big problem we can introduce a
97  // Finalize method that will tear everything down in a predictable order.
98 
99  static ModuleCollection *g_module_collection = nullptr;
100  if (g_module_collection == nullptr)
101  g_module_collection = new ModuleCollection();
102 
103  return *g_module_collection;
104 }
105 
106 std::recursive_mutex &Module::GetAllocationModuleCollectionMutex() {
107  // NOTE: The mutex below must be leaked since the global module list in
108  // the ModuleList class will get torn at some point, and we can't know if it
109  // will tear itself down before the "g_module_collection_mutex" below will.
110  // So we leak a Mutex object below to safeguard against that
111 
112  static std::recursive_mutex *g_module_collection_mutex = nullptr;
113  if (g_module_collection_mutex == nullptr)
114  g_module_collection_mutex = new std::recursive_mutex; // NOTE: known leak
115  return *g_module_collection_mutex;
116 }
117 
118 size_t Module::GetNumberAllocatedModules() {
119  std::lock_guard<std::recursive_mutex> guard(
120  GetAllocationModuleCollectionMutex());
121  return GetModuleCollection().size();
122 }
123 
124 Module *Module::GetAllocatedModuleAtIndex(size_t idx) {
125  std::lock_guard<std::recursive_mutex> guard(
126  GetAllocationModuleCollectionMutex());
128  if (idx < modules.size())
129  return modules[idx];
130  return nullptr;
131 }
132 
133 Module::Module(const ModuleSpec &module_spec)
134  : m_file_has_changed(false), m_first_file_changed_log(false) {
135  // Scope for locker below...
136  {
137  std::lock_guard<std::recursive_mutex> guard(
139  GetModuleCollection().push_back(this);
140  }
141 
143  if (log != nullptr)
144  LLDB_LOGF(log, "%p Module::Module((%s) '%s%s%s%s')",
145  static_cast<void *>(this),
146  module_spec.GetArchitecture().GetArchitectureName(),
147  module_spec.GetFileSpec().GetPath().c_str(),
148  module_spec.GetObjectName().IsEmpty() ? "" : "(",
149  module_spec.GetObjectName().AsCString(""),
150  module_spec.GetObjectName().IsEmpty() ? "" : ")");
151 
152  auto data_sp = module_spec.GetData();
153  lldb::offset_t file_size = 0;
154  if (data_sp)
155  file_size = data_sp->GetByteSize();
156 
157  // First extract all module specifications from the file using the local file
158  // path. If there are no specifications, then don't fill anything in
159  ModuleSpecList modules_specs;
161  module_spec.GetFileSpec(), 0, file_size, modules_specs, data_sp) == 0)
162  return;
163 
164  // Now make sure that one of the module specifications matches what we just
165  // extract. We might have a module specification that specifies a file
166  // "/usr/lib/dyld" with UUID XXX, but we might have a local version of
167  // "/usr/lib/dyld" that has
168  // UUID YYY and we don't want those to match. If they don't match, just don't
169  // fill any ivars in so we don't accidentally grab the wrong file later since
170  // they don't match...
171  ModuleSpec matching_module_spec;
172  if (!modules_specs.FindMatchingModuleSpec(module_spec,
173  matching_module_spec)) {
174  if (log) {
175  LLDB_LOGF(log, "Found local object file but the specs didn't match");
176  }
177  return;
178  }
179 
180  // Set m_data_sp if it was initially provided in the ModuleSpec. Note that
181  // we cannot use the data_sp variable here, because it will have been
182  // modified by GetModuleSpecifications().
183  if (auto module_spec_data_sp = module_spec.GetData()) {
184  m_data_sp = module_spec_data_sp;
185  m_mod_time = {};
186  } else {
187  if (module_spec.GetFileSpec())
188  m_mod_time =
190  else if (matching_module_spec.GetFileSpec())
192  matching_module_spec.GetFileSpec());
193  }
194 
195  // Copy the architecture from the actual spec if we got one back, else use
196  // the one that was specified
197  if (matching_module_spec.GetArchitecture().IsValid())
198  m_arch = matching_module_spec.GetArchitecture();
199  else if (module_spec.GetArchitecture().IsValid())
200  m_arch = module_spec.GetArchitecture();
201 
202  // Copy the file spec over and use the specified one (if there was one) so we
203  // don't use a path that might have gotten resolved a path in
204  // 'matching_module_spec'
205  if (module_spec.GetFileSpec())
206  m_file = module_spec.GetFileSpec();
207  else if (matching_module_spec.GetFileSpec())
208  m_file = matching_module_spec.GetFileSpec();
209 
210  // Copy the platform file spec over
211  if (module_spec.GetPlatformFileSpec())
212  m_platform_file = module_spec.GetPlatformFileSpec();
213  else if (matching_module_spec.GetPlatformFileSpec())
214  m_platform_file = matching_module_spec.GetPlatformFileSpec();
215 
216  // Copy the symbol file spec over
217  if (module_spec.GetSymbolFileSpec())
218  m_symfile_spec = module_spec.GetSymbolFileSpec();
219  else if (matching_module_spec.GetSymbolFileSpec())
220  m_symfile_spec = matching_module_spec.GetSymbolFileSpec();
221 
222  // Copy the object name over
223  if (matching_module_spec.GetObjectName())
224  m_object_name = matching_module_spec.GetObjectName();
225  else
226  m_object_name = module_spec.GetObjectName();
227 
228  // Always trust the object offset (file offset) and object modification time
229  // (for mod time in a BSD static archive) of from the matching module
230  // specification
231  m_object_offset = matching_module_spec.GetObjectOffset();
232  m_object_mod_time = matching_module_spec.GetObjectModificationTime();
233 }
234 
235 Module::Module(const FileSpec &file_spec, const ArchSpec &arch,
236  const ConstString *object_name, lldb::offset_t object_offset,
237  const llvm::sys::TimePoint<> &object_mod_time)
238  : m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)),
239  m_arch(arch), m_file(file_spec), m_object_offset(object_offset),
240  m_object_mod_time(object_mod_time), m_file_has_changed(false),
241  m_first_file_changed_log(false) {
242  // Scope for locker below...
243  {
244  std::lock_guard<std::recursive_mutex> guard(
246  GetModuleCollection().push_back(this);
247  }
248 
249  if (object_name)
250  m_object_name = *object_name;
251 
253  if (log != nullptr)
254  LLDB_LOGF(log, "%p Module::Module((%s) '%s%s%s%s')",
255  static_cast<void *>(this), m_arch.GetArchitectureName(),
256  m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(",
257  m_object_name.AsCString(""), m_object_name.IsEmpty() ? "" : ")");
258 }
259 
260 Module::Module() : m_file_has_changed(false), m_first_file_changed_log(false) {
261  std::lock_guard<std::recursive_mutex> guard(
263  GetModuleCollection().push_back(this);
264 }
265 
267  // Lock our module down while we tear everything down to make sure we don't
268  // get any access to the module while it is being destroyed
269  std::lock_guard<std::recursive_mutex> guard(m_mutex);
270  // Scope for locker below...
271  {
272  std::lock_guard<std::recursive_mutex> guard(
275  ModuleCollection::iterator end = modules.end();
276  ModuleCollection::iterator pos = std::find(modules.begin(), end, this);
277  assert(pos != end);
278  modules.erase(pos);
279  }
281  if (log != nullptr)
282  LLDB_LOGF(log, "%p Module::~Module((%s) '%s%s%s%s')",
283  static_cast<void *>(this), m_arch.GetArchitectureName(),
284  m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(",
285  m_object_name.AsCString(""), m_object_name.IsEmpty() ? "" : ")");
286  // Release any auto pointers before we start tearing down our member
287  // variables since the object file and symbol files might need to make
288  // function calls back into this module object. The ordering is important
289  // here because symbol files can require the module object file. So we tear
290  // down the symbol file first, then the object file.
291  m_sections_up.reset();
292  m_symfile_up.reset();
293  m_objfile_sp.reset();
294 }
295 
296 ObjectFile *Module::GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
297  lldb::addr_t header_addr, Status &error,
298  size_t size_to_read) {
299  if (m_objfile_sp) {
300  error.SetErrorString("object file already exists");
301  } else {
302  std::lock_guard<std::recursive_mutex> guard(m_mutex);
303  if (process_sp) {
304  m_did_load_objfile = true;
305  std::shared_ptr<DataBufferHeap> data_sp =
306  std::make_shared<DataBufferHeap>(size_to_read, 0);
307  Status readmem_error;
308  const size_t bytes_read =
309  process_sp->ReadMemory(header_addr, data_sp->GetBytes(),
310  data_sp->GetByteSize(), readmem_error);
311  if (bytes_read < size_to_read)
312  data_sp->SetByteSize(bytes_read);
313  if (data_sp->GetByteSize() > 0) {
314  m_objfile_sp = ObjectFile::FindPlugin(shared_from_this(), process_sp,
315  header_addr, data_sp);
316  if (m_objfile_sp) {
317  StreamString s;
318  s.Printf("0x%16.16" PRIx64, header_addr);
320 
321  // Once we get the object file, update our module with the object
322  // file's architecture since it might differ in vendor/os if some
323  // parts were unknown.
324  m_arch = m_objfile_sp->GetArchitecture();
325 
326  // Augment the arch with the target's information in case
327  // we are unable to extract the os/environment from memory.
328  m_arch.MergeFrom(process_sp->GetTarget().GetArchitecture());
329  } else {
330  error.SetErrorString("unable to find suitable object file plug-in");
331  }
332  } else {
333  error.SetErrorStringWithFormat("unable to read header from memory: %s",
334  readmem_error.AsCString());
335  }
336  } else {
337  error.SetErrorString("invalid process");
338  }
339  }
340  return m_objfile_sp.get();
341 }
342 
344  if (!m_did_set_uuid.load()) {
345  std::lock_guard<std::recursive_mutex> guard(m_mutex);
346  if (!m_did_set_uuid.load()) {
347  ObjectFile *obj_file = GetObjectFile();
348 
349  if (obj_file != nullptr) {
350  m_uuid = obj_file->GetUUID();
351  m_did_set_uuid = true;
352  }
353  }
354  }
355  return m_uuid;
356 }
357 
359  std::lock_guard<std::recursive_mutex> guard(m_mutex);
360  if (!m_did_set_uuid) {
361  m_uuid = uuid;
362  m_did_set_uuid = true;
363  } else {
364  lldbassert(0 && "Attempting to overwrite the existing module UUID");
365  }
366 }
367 
368 llvm::Expected<TypeSystemSP>
370  return m_type_system_map.GetTypeSystemForLanguage(language, this, true);
371 }
372 
374  llvm::function_ref<bool(lldb::TypeSystemSP)> callback) {
375  m_type_system_map.ForEach(callback);
376 }
377 
379  std::lock_guard<std::recursive_mutex> guard(m_mutex);
380  size_t num_comp_units = GetNumCompileUnits();
381  if (num_comp_units == 0)
382  return;
383 
384  SymbolFile *symbols = GetSymbolFile();
385 
386  for (size_t cu_idx = 0; cu_idx < num_comp_units; cu_idx++) {
387  SymbolContext sc;
388  sc.module_sp = shared_from_this();
389  sc.comp_unit = symbols->GetCompileUnitAtIndex(cu_idx).get();
390  if (!sc.comp_unit)
391  continue;
392 
393  symbols->ParseVariablesForContext(sc);
394 
395  symbols->ParseFunctions(*sc.comp_unit);
396 
397  sc.comp_unit->ForeachFunction([&sc, &symbols](const FunctionSP &f) {
398  symbols->ParseBlocksRecursive(*f);
399 
400  // Parse the variables for this function and all its blocks
401  sc.function = f.get();
402  symbols->ParseVariablesForContext(sc);
403  return false;
404  });
405 
406  // Parse all types for this compile unit
407  symbols->ParseTypes(*sc.comp_unit);
408  }
409 }
410 
412  sc->module_sp = shared_from_this();
413 }
414 
415 ModuleSP Module::CalculateSymbolContextModule() { return shared_from_this(); }
416 
418  s->Printf(", Module{%p}", static_cast<void *>(this));
419 }
420 
422  std::lock_guard<std::recursive_mutex> guard(m_mutex);
423  if (SymbolFile *symbols = GetSymbolFile())
424  return symbols->GetNumCompileUnits();
425  return 0;
426 }
427 
428 CompUnitSP Module::GetCompileUnitAtIndex(size_t index) {
429  std::lock_guard<std::recursive_mutex> guard(m_mutex);
430  size_t num_comp_units = GetNumCompileUnits();
431  CompUnitSP cu_sp;
432 
433  if (index < num_comp_units) {
434  if (SymbolFile *symbols = GetSymbolFile())
435  cu_sp = symbols->GetCompileUnitAtIndex(index);
436  }
437  return cu_sp;
438 }
439 
441  std::lock_guard<std::recursive_mutex> guard(m_mutex);
442  SectionList *section_list = GetSectionList();
443  if (section_list)
444  return so_addr.ResolveAddressUsingFileSections(vm_addr, section_list);
445  return false;
446 }
447 
449  const Address &so_addr, lldb::SymbolContextItem resolve_scope,
450  SymbolContext &sc, bool resolve_tail_call_address) {
451  std::lock_guard<std::recursive_mutex> guard(m_mutex);
452  uint32_t resolved_flags = 0;
453 
454  // Clear the result symbol context in case we don't find anything, but don't
455  // clear the target
456  sc.Clear(false);
457 
458  // Get the section from the section/offset address.
459  SectionSP section_sp(so_addr.GetSection());
460 
461  // Make sure the section matches this module before we try and match anything
462  if (section_sp && section_sp->GetModule().get() == this) {
463  // If the section offset based address resolved itself, then this is the
464  // right module.
465  sc.module_sp = shared_from_this();
466  resolved_flags |= eSymbolContextModule;
467 
468  SymbolFile *symfile = GetSymbolFile();
469  if (!symfile)
470  return resolved_flags;
471 
472  // Resolve the compile unit, function, block, line table or line entry if
473  // requested.
474  if (resolve_scope & eSymbolContextCompUnit ||
475  resolve_scope & eSymbolContextFunction ||
476  resolve_scope & eSymbolContextBlock ||
477  resolve_scope & eSymbolContextLineEntry ||
478  resolve_scope & eSymbolContextVariable) {
479  symfile->SetLoadDebugInfoEnabled();
480  resolved_flags |=
481  symfile->ResolveSymbolContext(so_addr, resolve_scope, sc);
482  }
483 
484  // Resolve the symbol if requested, but don't re-look it up if we've
485  // already found it.
486  if (resolve_scope & eSymbolContextSymbol &&
487  !(resolved_flags & eSymbolContextSymbol)) {
488  Symtab *symtab = symfile->GetSymtab();
489  if (symtab && so_addr.IsSectionOffset()) {
490  Symbol *matching_symbol = nullptr;
491 
493  so_addr.GetFileAddress(),
494  [&matching_symbol](Symbol *symbol) -> bool {
495  if (symbol->GetType() != eSymbolTypeInvalid) {
496  matching_symbol = symbol;
497  return false; // Stop iterating
498  }
499  return true; // Keep iterating
500  });
501  sc.symbol = matching_symbol;
502  if (!sc.symbol && resolve_scope & eSymbolContextFunction &&
503  !(resolved_flags & eSymbolContextFunction)) {
504  bool verify_unique = false; // No need to check again since
505  // ResolveSymbolContext failed to find a
506  // symbol at this address.
507  if (ObjectFile *obj_file = sc.module_sp->GetObjectFile())
508  sc.symbol =
509  obj_file->ResolveSymbolForAddress(so_addr, verify_unique);
510  }
511 
512  if (sc.symbol) {
513  if (sc.symbol->IsSynthetic()) {
514  // We have a synthetic symbol so lets check if the object file from
515  // the symbol file in the symbol vendor is different than the
516  // object file for the module, and if so search its symbol table to
517  // see if we can come up with a better symbol. For example dSYM
518  // files on MacOSX have an unstripped symbol table inside of them.
519  ObjectFile *symtab_objfile = symtab->GetObjectFile();
520  if (symtab_objfile && symtab_objfile->IsStripped()) {
521  ObjectFile *symfile_objfile = symfile->GetObjectFile();
522  if (symfile_objfile != symtab_objfile) {
523  Symtab *symfile_symtab = symfile_objfile->GetSymtab();
524  if (symfile_symtab) {
525  Symbol *symbol =
526  symfile_symtab->FindSymbolContainingFileAddress(
527  so_addr.GetFileAddress());
528  if (symbol && !symbol->IsSynthetic()) {
529  sc.symbol = symbol;
530  }
531  }
532  }
533  }
534  }
535  resolved_flags |= eSymbolContextSymbol;
536  }
537  }
538  }
539 
540  // For function symbols, so_addr may be off by one. This is a convention
541  // consistent with FDE row indices in eh_frame sections, but requires extra
542  // logic here to permit symbol lookup for disassembly and unwind.
543  if (resolve_scope & eSymbolContextSymbol &&
544  !(resolved_flags & eSymbolContextSymbol) && resolve_tail_call_address &&
545  so_addr.IsSectionOffset()) {
546  Address previous_addr = so_addr;
547  previous_addr.Slide(-1);
548 
549  bool do_resolve_tail_call_address = false; // prevent recursion
551  previous_addr, resolve_scope, sc, do_resolve_tail_call_address);
552  if (flags & eSymbolContextSymbol) {
553  AddressRange addr_range;
554  if (sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0,
555  false, addr_range)) {
556  if (addr_range.GetBaseAddress().GetSection() ==
557  so_addr.GetSection()) {
558  // If the requested address is one past the address range of a
559  // function (i.e. a tail call), or the decremented address is the
560  // start of a function (i.e. some forms of trampoline), indicate
561  // that the symbol has been resolved.
562  if (so_addr.GetOffset() ==
563  addr_range.GetBaseAddress().GetOffset() ||
564  so_addr.GetOffset() == addr_range.GetBaseAddress().GetOffset() +
565  addr_range.GetByteSize()) {
566  resolved_flags |= flags;
567  }
568  } else {
569  sc.symbol =
570  nullptr; // Don't trust the symbol if the sections didn't match.
571  }
572  }
573  }
574  }
575  }
576  return resolved_flags;
577 }
578 
579 uint32_t Module::ResolveSymbolContextForFilePath(
580  const char *file_path, uint32_t line, bool check_inlines,
581  lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
582  FileSpec file_spec(file_path);
583  return ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
584  resolve_scope, sc_list);
585 }
586 
588  const FileSpec &file_spec, uint32_t line, bool check_inlines,
589  lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
590  std::lock_guard<std::recursive_mutex> guard(m_mutex);
591  LLDB_SCOPED_TIMERF("Module::ResolveSymbolContextForFilePath (%s:%u, "
592  "check_inlines = %s, resolve_scope = 0x%8.8x)",
593  file_spec.GetPath().c_str(), line,
594  check_inlines ? "yes" : "no", resolve_scope);
595 
596  const uint32_t initial_count = sc_list.GetSize();
597 
598  if (SymbolFile *symbols = GetSymbolFile()) {
599  // TODO: Handle SourceLocationSpec column information
600  SourceLocationSpec location_spec(file_spec, line, /*column=*/std::nullopt,
601  check_inlines, /*exact_match=*/false);
602 
603  symbols->ResolveSymbolContext(location_spec, resolve_scope, sc_list);
604  }
605 
606  return sc_list.GetSize() - initial_count;
607 }
608 
610  const CompilerDeclContext &parent_decl_ctx,
611  size_t max_matches, VariableList &variables) {
612  if (SymbolFile *symbols = GetSymbolFile())
613  symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches, variables);
614 }
615 
617  size_t max_matches, VariableList &variables) {
618  SymbolFile *symbols = GetSymbolFile();
619  if (symbols)
620  symbols->FindGlobalVariables(regex, max_matches, variables);
621 }
622 
624  SymbolContextList &sc_list) {
625  const size_t num_compile_units = GetNumCompileUnits();
626  SymbolContext sc;
627  sc.module_sp = shared_from_this();
628  for (size_t i = 0; i < num_compile_units; ++i) {
629  sc.comp_unit = GetCompileUnitAtIndex(i).get();
630  if (sc.comp_unit) {
631  if (FileSpec::Match(path, sc.comp_unit->GetPrimaryFile()))
632  sc_list.Append(sc);
633  }
634  }
635 }
636 
638  FunctionNameType name_type_mask,
639  LanguageType language)
640  : m_name(name), m_lookup_name(), m_language(language) {
641  const char *name_cstr = name.GetCString();
642  llvm::StringRef basename;
643  llvm::StringRef context;
644 
645  if (name_type_mask & eFunctionNameTypeAuto) {
647  m_name_type_mask = eFunctionNameTypeFull;
648  else if ((language == eLanguageTypeUnknown ||
649  Language::LanguageIsObjC(language)) &&
651  m_name_type_mask = eFunctionNameTypeFull;
652  else if (Language::LanguageIsC(language)) {
653  m_name_type_mask = eFunctionNameTypeFull;
654  } else {
655  if ((language == eLanguageTypeUnknown ||
656  Language::LanguageIsObjC(language)) &&
658  m_name_type_mask |= eFunctionNameTypeSelector;
659 
660  CPlusPlusLanguage::MethodName cpp_method(name);
661  basename = cpp_method.GetBasename();
662  if (basename.empty()) {
663  if (CPlusPlusLanguage::ExtractContextAndIdentifier(name_cstr, context,
664  basename))
665  m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
666  else
667  m_name_type_mask |= eFunctionNameTypeFull;
668  } else {
669  m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
670  }
671  }
672  } else {
673  m_name_type_mask = name_type_mask;
674  if (name_type_mask & eFunctionNameTypeMethod ||
675  name_type_mask & eFunctionNameTypeBase) {
676  // If they've asked for a CPP method or function name and it can't be
677  // that, we don't even need to search for CPP methods or names.
678  CPlusPlusLanguage::MethodName cpp_method(name);
679  if (cpp_method.IsValid()) {
680  basename = cpp_method.GetBasename();
681 
682  if (!cpp_method.GetQualifiers().empty()) {
683  // There is a "const" or other qualifier following the end of the
684  // function parens, this can't be a eFunctionNameTypeBase
685  m_name_type_mask &= ~(eFunctionNameTypeBase);
686  if (m_name_type_mask == eFunctionNameTypeNone)
687  return;
688  }
689  } else {
690  // If the CPP method parser didn't manage to chop this up, try to fill
691  // in the base name if we can. If a::b::c is passed in, we need to just
692  // look up "c", and then we'll filter the result later.
694  basename);
695  }
696  }
697 
698  if (name_type_mask & eFunctionNameTypeSelector) {
699  if (!ObjCLanguage::IsPossibleObjCSelector(name_cstr)) {
700  m_name_type_mask &= ~(eFunctionNameTypeSelector);
701  if (m_name_type_mask == eFunctionNameTypeNone)
702  return;
703  }
704  }
705 
706  // Still try and get a basename in case someone specifies a name type mask
707  // of eFunctionNameTypeFull and a name like "A::func"
708  if (basename.empty()) {
709  if (name_type_mask & eFunctionNameTypeFull &&
711  CPlusPlusLanguage::MethodName cpp_method(name);
712  basename = cpp_method.GetBasename();
713  if (basename.empty())
715  basename);
716  }
717  }
718  }
719 
720  if (!basename.empty()) {
721  // The name supplied was a partial C++ path like "a::count". In this case
722  // we want to do a lookup on the basename "count" and then make sure any
723  // matching results contain "a::count" so that it would match "b::a::count"
724  // and "a::count". This is why we set "match_name_after_lookup" to true
725  m_lookup_name.SetString(basename);
726  m_match_name_after_lookup = true;
727  } else {
728  // The name is already correct, just use the exact name as supplied, and we
729  // won't need to check if any matches contain "name"
730  m_lookup_name = name;
731  m_match_name_after_lookup = false;
732  }
733 }
734 
736  ConstString function_name, LanguageType language_type) const {
737  // We always keep unnamed symbols
738  if (!function_name)
739  return true;
740 
741  // If we match exactly, we can return early
742  if (m_name == function_name)
743  return true;
744 
745  // If function_name is mangled, we'll need to demangle it.
746  // In the pathologial case where the function name "looks" mangled but is
747  // actually demangled (e.g. a method named _Zonk), this operation should be
748  // relatively inexpensive since no demangling is actually occuring. See
749  // Mangled::SetValue for more context.
750  const bool function_name_may_be_mangled =
751  Mangled::GetManglingScheme(function_name.GetStringRef()) !=
752  Mangled::eManglingSchemeNone;
753  ConstString demangled_function_name = function_name;
754  if (function_name_may_be_mangled) {
755  Mangled mangled_function_name(function_name);
756  demangled_function_name = mangled_function_name.GetDemangledName();
757  }
758 
759  // If the symbol has a language, then let the language make the match.
760  // Otherwise just check that the demangled function name contains the
761  // demangled user-provided name.
762  if (Language *language = Language::FindPlugin(language_type))
763  return language->DemangledNameContainsPath(m_name.GetStringRef(),
764  demangled_function_name);
765 
766  llvm::StringRef function_name_ref = demangled_function_name.GetStringRef();
767  return function_name_ref.contains(m_name.GetStringRef());
768 }
769 
771  size_t start_idx) const {
772  if (m_match_name_after_lookup && m_name) {
773  SymbolContext sc;
774  size_t i = start_idx;
775  while (i < sc_list.GetSize()) {
776  if (!sc_list.GetContextAtIndex(i, sc))
777  break;
778 
779  bool keep_it =
780  NameMatchesLookupInfo(sc.GetFunctionName(), sc.GetLanguage());
781  if (keep_it)
782  ++i;
783  else
784  sc_list.RemoveContextAtIndex(i);
785  }
786  }
787 
788  // If we have only full name matches we might have tried to set breakpoint on
789  // "func" and specified eFunctionNameTypeFull, but we might have found
790  // "a::func()", "a::b::func()", "c::func()", "func()" and "func". Only
791  // "func()" and "func" should end up matching.
792  if (m_name_type_mask == eFunctionNameTypeFull) {
793  SymbolContext sc;
794  size_t i = start_idx;
795  while (i < sc_list.GetSize()) {
796  if (!sc_list.GetContextAtIndex(i, sc))
797  break;
798  // Make sure the mangled and demangled names don't match before we try to
799  // pull anything out
800  ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
801  ConstString full_name(sc.GetFunctionName());
802  if (mangled_name != m_name && full_name != m_name) {
803  CPlusPlusLanguage::MethodName cpp_method(full_name);
804  if (cpp_method.IsValid()) {
805  if (cpp_method.GetContext().empty()) {
806  if (cpp_method.GetBasename().compare(m_name.GetStringRef()) != 0) {
807  sc_list.RemoveContextAtIndex(i);
808  continue;
809  }
810  } else {
811  std::string qualified_name;
812  llvm::StringRef anon_prefix("(anonymous namespace)");
813  if (cpp_method.GetContext() == anon_prefix)
814  qualified_name = cpp_method.GetBasename().str();
815  else
816  qualified_name = cpp_method.GetScopeQualifiedName();
817  if (qualified_name != m_name.GetCString()) {
818  sc_list.RemoveContextAtIndex(i);
819  continue;
820  }
821  }
822  }
823  }
824  ++i;
825  }
826  }
827 }
828 
830  const CompilerDeclContext &parent_decl_ctx,
831  const ModuleFunctionSearchOptions &options,
832  SymbolContextList &sc_list) {
833  // Find all the functions (not symbols, but debug information functions...
834  if (SymbolFile *symbols = GetSymbolFile()) {
835  symbols->FindFunctions(lookup_info, parent_decl_ctx,
836  options.include_inlines, sc_list);
837  // Now check our symbol table for symbols that are code symbols if
838  // requested
839  if (options.include_symbols) {
840  if (Symtab *symtab = symbols->GetSymtab()) {
841  symtab->FindFunctionSymbols(lookup_info.GetLookupName(),
842  lookup_info.GetNameTypeMask(), sc_list);
843  }
844  }
845  }
846 }
847 
849  const CompilerDeclContext &parent_decl_ctx,
850  FunctionNameType name_type_mask,
851  const ModuleFunctionSearchOptions &options,
852  SymbolContextList &sc_list) {
853  const size_t old_size = sc_list.GetSize();
854  LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
855  FindFunctions(lookup_info, parent_decl_ctx, options, sc_list);
856  if (name_type_mask & eFunctionNameTypeAuto) {
857  const size_t new_size = sc_list.GetSize();
858  if (old_size < new_size)
859  lookup_info.Prune(sc_list, old_size);
860  }
861 }
862 
864  const ModuleFunctionSearchOptions &options,
865  SymbolContextList &sc_list) {
866  const size_t start_size = sc_list.GetSize();
867 
868  if (SymbolFile *symbols = GetSymbolFile()) {
869  symbols->FindFunctions(regex, options.include_inlines, sc_list);
870 
871  // Now check our symbol table for symbols that are code symbols if
872  // requested
873  if (options.include_symbols) {
874  Symtab *symtab = symbols->GetSymtab();
875  if (symtab) {
876  std::vector<uint32_t> symbol_indexes;
879  symbol_indexes);
880  const size_t num_matches = symbol_indexes.size();
881  if (num_matches) {
882  SymbolContext sc(this);
883  const size_t end_functions_added_index = sc_list.GetSize();
884  size_t num_functions_added_to_sc_list =
885  end_functions_added_index - start_size;
886  if (num_functions_added_to_sc_list == 0) {
887  // No functions were added, just symbols, so we can just append
888  // them
889  for (size_t i = 0; i < num_matches; ++i) {
890  sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
891  SymbolType sym_type = sc.symbol->GetType();
892  if (sc.symbol && (sym_type == eSymbolTypeCode ||
893  sym_type == eSymbolTypeResolver))
894  sc_list.Append(sc);
895  }
896  } else {
897  typedef std::map<lldb::addr_t, uint32_t> FileAddrToIndexMap;
898  FileAddrToIndexMap file_addr_to_index;
899  for (size_t i = start_size; i < end_functions_added_index; ++i) {
900  const SymbolContext &sc = sc_list[i];
901  if (sc.block)
902  continue;
903  file_addr_to_index[sc.function->GetAddressRange()
904  .GetBaseAddress()
905  .GetFileAddress()] = i;
906  }
907 
908  FileAddrToIndexMap::const_iterator end = file_addr_to_index.end();
909  // Functions were added so we need to merge symbols into any
910  // existing function symbol contexts
911  for (size_t i = start_size; i < num_matches; ++i) {
912  sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
913  SymbolType sym_type = sc.symbol->GetType();
914  if (sc.symbol && sc.symbol->ValueIsAddress() &&
915  (sym_type == eSymbolTypeCode ||
916  sym_type == eSymbolTypeResolver)) {
917  FileAddrToIndexMap::const_iterator pos =
918  file_addr_to_index.find(
920  if (pos == end)
921  sc_list.Append(sc);
922  else
923  sc_list[pos->second].symbol = sc.symbol;
924  }
925  }
926  }
927  }
928  }
929  }
930  }
931 }
932 
933 void Module::FindAddressesForLine(const lldb::TargetSP target_sp,
934  const FileSpec &file, uint32_t line,
935  Function *function,
936  std::vector<Address> &output_local,
937  std::vector<Address> &output_extern) {
938  SearchFilterByModule filter(target_sp, m_file);
939 
940  // TODO: Handle SourceLocationSpec column information
941  SourceLocationSpec location_spec(file, line, /*column=*/std::nullopt,
942  /*check_inlines=*/true,
943  /*exact_match=*/false);
944  AddressResolverFileLine resolver(location_spec);
945  resolver.ResolveAddress(filter);
946 
947  for (size_t n = 0; n < resolver.GetNumberOfAddresses(); n++) {
948  Address addr = resolver.GetAddressRangeAtIndex(n).GetBaseAddress();
950  if (f && f == function)
951  output_local.push_back(addr);
952  else
953  output_extern.push_back(addr);
954  }
955 }
956 
958  ConstString name, const CompilerDeclContext &parent_decl_ctx,
959  size_t max_matches,
960  llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
961  TypeMap &types) {
962  if (SymbolFile *symbols = GetSymbolFile())
963  symbols->FindTypes(name, parent_decl_ctx, max_matches,
964  searched_symbol_files, types);
965 }
966 
968  const CompilerDeclContext &parent_decl_ctx,
969  size_t max_matches, TypeList &type_list) {
970  TypeMap types_map;
971  llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
972  FindTypes_Impl(type_name, parent_decl_ctx, max_matches, searched_symbol_files,
973  types_map);
974  if (types_map.GetSize()) {
975  SymbolContext sc;
976  sc.module_sp = shared_from_this();
977  sc.SortTypeList(types_map, type_list);
978  }
979 }
980 
981 lldb::TypeSP Module::FindFirstType(const SymbolContext &sc, ConstString name,
982  bool exact_match) {
983  TypeList type_list;
984  llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
985  FindTypes(name, exact_match, 1, searched_symbol_files, type_list);
986  if (type_list.GetSize())
987  return type_list.GetTypeAtIndex(0);
988  return TypeSP();
989 }
990 
992  ConstString name, bool exact_match, size_t max_matches,
993  llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
994  TypeList &types) {
995  const char *type_name_cstr = name.GetCString();
996  llvm::StringRef type_scope;
997  llvm::StringRef type_basename;
998  TypeClass type_class = eTypeClassAny;
999  TypeMap typesmap;
1000 
1001  if (Type::GetTypeScopeAndBasename(type_name_cstr, type_scope, type_basename,
1002  type_class)) {
1003  // Check if "name" starts with "::" which means the qualified type starts
1004  // from the root namespace and implies and exact match. The typenames we
1005  // get back from clang do not start with "::" so we need to strip this off
1006  // in order to get the qualified names to match
1007  exact_match = type_scope.consume_front("::");
1008 
1009  ConstString type_basename_const_str(type_basename);
1010  FindTypes_Impl(type_basename_const_str, CompilerDeclContext(), max_matches,
1011  searched_symbol_files, typesmap);
1012  if (typesmap.GetSize())
1013  typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
1014  exact_match);
1015  } else {
1016  // The type is not in a namespace/class scope, just search for it by
1017  // basename
1018  if (type_class != eTypeClassAny && !type_basename.empty()) {
1019  // The "type_name_cstr" will have been modified if we have a valid type
1020  // class prefix (like "struct", "class", "union", "typedef" etc).
1022  UINT_MAX, searched_symbol_files, typesmap);
1023  typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
1024  exact_match);
1025  } else {
1026  FindTypes_Impl(name, CompilerDeclContext(), UINT_MAX,
1027  searched_symbol_files, typesmap);
1028  if (exact_match) {
1029  typesmap.RemoveMismatchedTypes(type_scope, name.GetStringRef(),
1030  type_class, exact_match);
1031  }
1032  }
1033  }
1034  if (typesmap.GetSize()) {
1035  SymbolContext sc;
1036  sc.module_sp = shared_from_this();
1037  sc.SortTypeList(typesmap, types);
1038  }
1039 }
1040 
1042  llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
1043  llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
1044  TypeMap &types) {
1045  // If a scoped timer is needed, place it in a SymbolFile::FindTypes override.
1046  // A timer here is too high volume for some cases, for example when calling
1047  // FindTypes on each object file.
1048  if (SymbolFile *symbols = GetSymbolFile())
1049  symbols->FindTypes(pattern, languages, searched_symbol_files, types);
1050 }
1051 
1052 SymbolFile *Module::GetSymbolFile(bool can_create, Stream *feedback_strm) {
1053  if (!m_did_load_symfile.load()) {
1054  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1055  if (!m_did_load_symfile.load() && can_create) {
1056  ObjectFile *obj_file = GetObjectFile();
1057  if (obj_file != nullptr) {
1059  m_symfile_up.reset(
1060  SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
1061  m_did_load_symfile = true;
1062  }
1063  }
1064  }
1065  return m_symfile_up ? m_symfile_up->GetSymbolFile() : nullptr;
1066 }
1067 
1069  if (SymbolFile *symbols = GetSymbolFile())
1070  return symbols->GetSymtab();
1071  return nullptr;
1072 }
1073 
1075  ConstString object_name) {
1076  // Container objects whose paths do not specify a file directly can call this
1077  // function to correct the file and object names.
1078  m_file = file;
1080  m_object_name = object_name;
1081 }
1082 
1083 const ArchSpec &Module::GetArchitecture() const { return m_arch; }
1084 
1086  std::string spec(GetFileSpec().GetPath());
1087  if (m_object_name) {
1088  spec += '(';
1089  spec += m_object_name.GetCString();
1090  spec += ')';
1091  }
1092  return spec;
1093 }
1094 
1095 void Module::GetDescription(llvm::raw_ostream &s,
1096  lldb::DescriptionLevel level) {
1097  if (level >= eDescriptionLevelFull) {
1098  if (m_arch.IsValid())
1099  s << llvm::formatv("({0}) ", m_arch.GetArchitectureName());
1100  }
1101 
1102  if (level == eDescriptionLevelBrief) {
1103  const char *filename = m_file.GetFilename().GetCString();
1104  if (filename)
1105  s << filename;
1106  } else {
1107  char path[PATH_MAX];
1108  if (m_file.GetPath(path, sizeof(path)))
1109  s << path;
1110  }
1111 
1112  const char *object_name = m_object_name.GetCString();
1113  if (object_name)
1114  s << llvm::formatv("({0})", object_name);
1115 }
1116 
1118  // We have provided the DataBuffer for this module to avoid accessing the
1119  // filesystem. We never want to reload those files.
1120  if (m_data_sp)
1121  return false;
1122  if (!m_file_has_changed)
1125  return m_file_has_changed;
1126 }
1127 
1129  std::optional<lldb::user_id_t> debugger_id) {
1130  ConstString file_name = GetFileSpec().GetFilename();
1131  if (file_name.IsEmpty())
1132  return;
1133 
1134  StreamString ss;
1135  ss << file_name.GetStringRef()
1136  << " was compiled with optimization - stepping may behave "
1137  "oddly; variables may not be available.";
1138  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
1140 }
1141 
1143  LanguageType language, std::optional<lldb::user_id_t> debugger_id) {
1144  StreamString ss;
1145  ss << "This version of LLDB has no plugin for the language \""
1147  << "\". "
1148  "Inspection of frame variables will be limited.";
1149  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
1151 }
1152 
1154  const llvm::formatv_object_base &payload) {
1155  if (!m_first_file_changed_log) {
1156  if (FileHasChanged()) {
1157  m_first_file_changed_log = true;
1158  StreamString strm;
1159  strm.PutCString("the object file ");
1161  strm.PutCString(" has been modified\n");
1162  strm.PutCString(payload.str());
1163  strm.PutCString("The debug session should be aborted as the original "
1164  "debug information has been overwritten.");
1166  }
1167  }
1168 }
1169 
1170 void Module::ReportError(const llvm::formatv_object_base &payload) {
1171  StreamString strm;
1173  strm.PutChar(' ');
1174  strm.PutCString(payload.str());
1175  Debugger::ReportError(strm.GetString().str());
1176 }
1177 
1178 void Module::ReportWarning(const llvm::formatv_object_base &payload) {
1179  StreamString strm;
1181  strm.PutChar(' ');
1182  strm.PutCString(payload.str());
1184 }
1185 
1186 void Module::LogMessage(Log *log, const llvm::formatv_object_base &payload) {
1187  StreamString log_message;
1189  log_message.PutCString(": ");
1190  log_message.PutCString(payload.str());
1191  log->PutCString(log_message.GetData());
1192 }
1193 
1195  Log *log, const llvm::formatv_object_base &payload) {
1196  StreamString log_message;
1198  log_message.PutCString(": ");
1199  log_message.PutCString(payload.str());
1200  if (log->GetVerbose()) {
1201  std::string back_trace;
1202  llvm::raw_string_ostream stream(back_trace);
1203  llvm::sys::PrintStackTrace(stream);
1204  log_message.PutCString(back_trace);
1205  }
1206  log->PutCString(log_message.GetData());
1207 }
1208 
1210  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1211  // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
1212  s->Indent();
1213  s->Printf("Module %s%s%s%s\n", m_file.GetPath().c_str(),
1214  m_object_name ? "(" : "",
1216  m_object_name ? ")" : "");
1217 
1218  s->IndentMore();
1219 
1220  ObjectFile *objfile = GetObjectFile();
1221  if (objfile)
1222  objfile->Dump(s);
1223 
1224  if (SymbolFile *symbols = GetSymbolFile())
1225  symbols->Dump(*s);
1226 
1227  s->IndentLess();
1228 }
1229 
1231 
1233  if (!m_did_load_objfile.load()) {
1234  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1235  if (!m_did_load_objfile.load()) {
1236  LLDB_SCOPED_TIMERF("Module::GetObjectFile () module = %s",
1237  GetFileSpec().GetFilename().AsCString(""));
1238  lldb::offset_t data_offset = 0;
1239  lldb::offset_t file_size = 0;
1240 
1241  if (m_data_sp)
1242  file_size = m_data_sp->GetByteSize();
1243  else if (m_file)
1244  file_size = FileSystem::Instance().GetByteSize(m_file);
1245 
1246  if (file_size > m_object_offset) {
1247  m_did_load_objfile = true;
1248  // FindPlugin will modify its data_sp argument. Do not let it
1249  // modify our m_data_sp member.
1250  auto data_sp = m_data_sp;
1252  shared_from_this(), &m_file, m_object_offset,
1253  file_size - m_object_offset, data_sp, data_offset);
1254  if (m_objfile_sp) {
1255  // Once we get the object file, update our module with the object
1256  // file's architecture since it might differ in vendor/os if some
1257  // parts were unknown. But since the matching arch might already be
1258  // more specific than the generic COFF architecture, only merge in
1259  // those values that overwrite unspecified unknown values.
1260  m_arch.MergeFrom(m_objfile_sp->GetArchitecture());
1261  } else {
1262  ReportError("failed to load objfile for {0}",
1263  GetFileSpec().GetPath().c_str());
1264  }
1265  }
1266  }
1267  }
1268  return m_objfile_sp.get();
1269 }
1270 
1272  // Populate m_sections_up with sections from objfile.
1273  if (!m_sections_up) {
1274  ObjectFile *obj_file = GetObjectFile();
1275  if (obj_file != nullptr)
1276  obj_file->CreateSections(*GetUnifiedSectionList());
1277  }
1278  return m_sections_up.get();
1279 }
1280 
1282  ObjectFile *obj_file = GetObjectFile();
1283  if (obj_file)
1284  obj_file->SectionFileAddressesChanged();
1285  if (SymbolFile *symbols = GetSymbolFile())
1286  symbols->SectionFileAddressesChanged();
1287 }
1288 
1290  if (!m_unwind_table) {
1291  m_unwind_table.emplace(*this);
1292  if (!m_symfile_spec)
1294  }
1295  return *m_unwind_table;
1296 }
1297 
1299  if (!m_sections_up)
1300  m_sections_up = std::make_unique<SectionList>();
1301  return m_sections_up.get();
1302 }
1303 
1305  SymbolType symbol_type) {
1307  "Module::FindFirstSymbolWithNameAndType (name = %s, type = %i)",
1308  name.AsCString(), symbol_type);
1309  if (Symtab *symtab = GetSymtab())
1310  return symtab->FindFirstSymbolWithNameAndType(
1311  name, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny);
1312  return nullptr;
1313 }
1315  Symtab *symtab, std::vector<uint32_t> &symbol_indexes,
1316  SymbolContextList &sc_list) {
1317  // No need to protect this call using m_mutex all other method calls are
1318  // already thread safe.
1319 
1320  size_t num_indices = symbol_indexes.size();
1321  if (num_indices > 0) {
1322  SymbolContext sc;
1324  for (size_t i = 0; i < num_indices; i++) {
1325  sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
1326  if (sc.symbol)
1327  sc_list.Append(sc);
1328  }
1329  }
1330 }
1331 
1333  SymbolContextList &sc_list) {
1334  LLDB_SCOPED_TIMERF("Module::FindSymbolsFunctions (name = %s, mask = 0x%8.8x)",
1335  name.AsCString(), name_type_mask);
1336  if (Symtab *symtab = GetSymtab())
1337  symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
1338 }
1339 
1341  SymbolType symbol_type,
1342  SymbolContextList &sc_list) {
1343  // No need to protect this call using m_mutex all other method calls are
1344  // already thread safe.
1345  if (Symtab *symtab = GetSymtab()) {
1346  std::vector<uint32_t> symbol_indexes;
1347  symtab->FindAllSymbolsWithNameAndType(name, symbol_type, symbol_indexes);
1348  SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list);
1349  }
1350 }
1351 
1353  const RegularExpression &regex, SymbolType symbol_type,
1354  SymbolContextList &sc_list, Mangled::NamePreference mangling_preference) {
1355  // No need to protect this call using m_mutex all other method calls are
1356  // already thread safe.
1358  "Module::FindSymbolsMatchingRegExAndType (regex = %s, type = %i)",
1359  regex.GetText().str().c_str(), symbol_type);
1360  if (Symtab *symtab = GetSymtab()) {
1361  std::vector<uint32_t> symbol_indexes;
1362  symtab->FindAllSymbolsMatchingRexExAndType(
1363  regex, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny,
1364  symbol_indexes, mangling_preference);
1365  SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list);
1366  }
1367 }
1368 
1370  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1371  SymbolFile *sym_file = GetSymbolFile();
1372  if (!sym_file)
1373  return;
1374 
1375  // Load the object file symbol table and any symbols from the SymbolFile that
1376  // get appended using SymbolFile::AddSymbols(...).
1377  if (Symtab *symtab = sym_file->GetSymtab())
1378  symtab->PreloadSymbols();
1379 
1380  // Now let the symbol file preload its data and the symbol table will be
1381  // available without needing to take the module lock.
1382  sym_file->PreloadSymbols();
1383 }
1384 
1386  if (!FileSystem::Instance().Exists(file))
1387  return;
1388  if (m_symfile_up) {
1389  // Remove any sections in the unified section list that come from the
1390  // current symbol vendor.
1391  SectionList *section_list = GetSectionList();
1392  SymbolFile *symbol_file = GetSymbolFile();
1393  if (section_list && symbol_file) {
1394  ObjectFile *obj_file = symbol_file->GetObjectFile();
1395  // Make sure we have an object file and that the symbol vendor's objfile
1396  // isn't the same as the module's objfile before we remove any sections
1397  // for it...
1398  if (obj_file) {
1399  // Check to make sure we aren't trying to specify the file we already
1400  // have
1401  if (obj_file->GetFileSpec() == file) {
1402  // We are being told to add the exact same file that we already have
1403  // we don't have to do anything.
1404  return;
1405  }
1406 
1407  // Cleare the current symtab as we are going to replace it with a new
1408  // one
1409  obj_file->ClearSymtab();
1410 
1411  // Clear the unwind table too, as that may also be affected by the
1412  // symbol file information.
1413  m_unwind_table.reset();
1414 
1415  // The symbol file might be a directory bundle ("/tmp/a.out.dSYM")
1416  // instead of a full path to the symbol file within the bundle
1417  // ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to
1418  // check this
1419 
1420  if (FileSystem::Instance().IsDirectory(file)) {
1421  std::string new_path(file.GetPath());
1422  std::string old_path(obj_file->GetFileSpec().GetPath());
1423  if (llvm::StringRef(old_path).startswith(new_path)) {
1424  // We specified the same bundle as the symbol file that we already
1425  // have
1426  return;
1427  }
1428  }
1429 
1430  if (obj_file != m_objfile_sp.get()) {
1431  size_t num_sections = section_list->GetNumSections(0);
1432  for (size_t idx = num_sections; idx > 0; --idx) {
1433  lldb::SectionSP section_sp(
1434  section_list->GetSectionAtIndex(idx - 1));
1435  if (section_sp->GetObjectFile() == obj_file) {
1436  section_list->DeleteSection(idx - 1);
1437  }
1438  }
1439  }
1440  }
1441  }
1442  // Keep all old symbol files around in case there are any lingering type
1443  // references in any SBValue objects that might have been handed out.
1444  m_old_symfiles.push_back(std::move(m_symfile_up));
1445  }
1446  m_symfile_spec = file;
1447  m_symfile_up.reset();
1448  m_did_load_symfile = false;
1449 }
1450 
1452  if (GetObjectFile() == nullptr)
1453  return false;
1454  else
1455  return GetObjectFile()->IsExecutable();
1456 }
1457 
1459  ObjectFile *obj_file = GetObjectFile();
1460  if (obj_file) {
1461  SectionList *sections = GetSectionList();
1462  if (sections != nullptr) {
1463  size_t num_sections = sections->GetSize();
1464  for (size_t sect_idx = 0; sect_idx < num_sections; sect_idx++) {
1465  SectionSP section_sp = sections->GetSectionAtIndex(sect_idx);
1466  if (section_sp->GetLoadBaseAddress(target) != LLDB_INVALID_ADDRESS) {
1467  return true;
1468  }
1469  }
1470  }
1471  }
1472  return false;
1473 }
1474 
1476  Stream *feedback_stream) {
1477  if (!target) {
1478  error.SetErrorString("invalid destination Target");
1479  return false;
1480  }
1481 
1482  LoadScriptFromSymFile should_load =
1483  target->TargetProperties::GetLoadScriptFromSymbolFile();
1484 
1485  if (should_load == eLoadScriptFromSymFileFalse)
1486  return false;
1487 
1488  Debugger &debugger = target->GetDebugger();
1489  const ScriptLanguage script_language = debugger.GetScriptLanguage();
1490  if (script_language != eScriptLanguageNone) {
1491 
1492  PlatformSP platform_sp(target->GetPlatform());
1493 
1494  if (!platform_sp) {
1495  error.SetErrorString("invalid Platform");
1496  return false;
1497  }
1498 
1499  FileSpecList file_specs = platform_sp->LocateExecutableScriptingResources(
1500  target, *this, feedback_stream);
1501 
1502  const uint32_t num_specs = file_specs.GetSize();
1503  if (num_specs) {
1504  ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
1505  if (script_interpreter) {
1506  for (uint32_t i = 0; i < num_specs; ++i) {
1507  FileSpec scripting_fspec(file_specs.GetFileSpecAtIndex(i));
1508  if (scripting_fspec &&
1509  FileSystem::Instance().Exists(scripting_fspec)) {
1510  if (should_load == eLoadScriptFromSymFileWarn) {
1511  if (feedback_stream)
1512  feedback_stream->Printf(
1513  "warning: '%s' contains a debug script. To run this script "
1514  "in "
1515  "this debug session:\n\n command script import "
1516  "\"%s\"\n\n"
1517  "To run all discovered debug scripts in this session:\n\n"
1518  " settings set target.load-script-from-symbol-file "
1519  "true\n",
1520  GetFileSpec().GetFileNameStrippingExtension().GetCString(),
1521  scripting_fspec.GetPath().c_str());
1522  return false;
1523  }
1524  StreamString scripting_stream;
1525  scripting_fspec.Dump(scripting_stream.AsRawOstream());
1526  LoadScriptOptions options;
1527  bool did_load = script_interpreter->LoadScriptingModule(
1528  scripting_stream.GetData(), options, error);
1529  if (!did_load)
1530  return false;
1531  }
1532  }
1533  } else {
1534  error.SetErrorString("invalid ScriptInterpreter");
1535  return false;
1536  }
1537  }
1538  }
1539  return true;
1540 }
1541 
1542 bool Module::SetArchitecture(const ArchSpec &new_arch) {
1543  if (!m_arch.IsValid()) {
1544  m_arch = new_arch;
1545  return true;
1546  }
1547  return m_arch.IsCompatibleMatch(new_arch);
1548 }
1549 
1551  bool value_is_offset, bool &changed) {
1552  ObjectFile *object_file = GetObjectFile();
1553  if (object_file != nullptr) {
1554  changed = object_file->SetLoadAddress(target, value, value_is_offset);
1555  return true;
1556  } else {
1557  changed = false;
1558  }
1559  return false;
1560 }
1561 
1562 bool Module::MatchesModuleSpec(const ModuleSpec &module_ref) {
1563  const UUID &uuid = module_ref.GetUUID();
1564 
1565  if (uuid.IsValid()) {
1566  // If the UUID matches, then nothing more needs to match...
1567  return (uuid == GetUUID());
1568  }
1569 
1570  const FileSpec &file_spec = module_ref.GetFileSpec();
1571  if (!FileSpec::Match(file_spec, m_file) &&
1572  !FileSpec::Match(file_spec, m_platform_file))
1573  return false;
1574 
1575  const FileSpec &platform_file_spec = module_ref.GetPlatformFileSpec();
1576  if (!FileSpec::Match(platform_file_spec, GetPlatformFileSpec()))
1577  return false;
1578 
1579  const ArchSpec &arch = module_ref.GetArchitecture();
1580  if (arch.IsValid()) {
1581  if (!m_arch.IsCompatibleMatch(arch))
1582  return false;
1583  }
1584 
1585  ConstString object_name = module_ref.GetObjectName();
1586  if (object_name) {
1587  if (object_name != GetObjectName())
1588  return false;
1589  }
1590  return true;
1591 }
1592 
1593 bool Module::FindSourceFile(const FileSpec &orig_spec,
1594  FileSpec &new_spec) const {
1595  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1596  if (auto remapped = m_source_mappings.FindFile(orig_spec)) {
1597  new_spec = *remapped;
1598  return true;
1599  }
1600  return false;
1601 }
1602 
1603 std::optional<std::string> Module::RemapSourceFile(llvm::StringRef path) const {
1604  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1605  if (auto remapped = m_source_mappings.RemapPath(path))
1606  return remapped->GetPath();
1607  return {};
1608 }
1609 
1610 void Module::RegisterXcodeSDK(llvm::StringRef sdk_name,
1611  llvm::StringRef sysroot) {
1612  XcodeSDK sdk(sdk_name.str());
1613  auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(sdk);
1614 
1615  if (!sdk_path_or_err) {
1616  Debugger::ReportError("Error while searching for Xcode SDK: " +
1617  toString(sdk_path_or_err.takeError()));
1618  return;
1619  }
1620 
1621  auto sdk_path = *sdk_path_or_err;
1622  if (sdk_path.empty())
1623  return;
1624  // If the SDK changed for a previously registered source path, update it.
1625  // This could happend with -fdebug-prefix-map, otherwise it's unlikely.
1626  if (!m_source_mappings.Replace(sysroot, sdk_path, true))
1627  // In the general case, however, append it to the list.
1628  m_source_mappings.Append(sysroot, sdk_path, false);
1629 }
1630 
1631 bool Module::MergeArchitecture(const ArchSpec &arch_spec) {
1632  if (!arch_spec.IsValid())
1633  return false;
1635  "module has arch %s, merging/replacing with arch %s",
1636  m_arch.GetTriple().getTriple().c_str(),
1637  arch_spec.GetTriple().getTriple().c_str());
1638  if (!m_arch.IsCompatibleMatch(arch_spec)) {
1639  // The new architecture is different, we just need to replace it.
1640  return SetArchitecture(arch_spec);
1641  }
1642 
1643  // Merge bits from arch_spec into "merged_arch" and set our architecture.
1644  ArchSpec merged_arch(m_arch);
1645  merged_arch.MergeFrom(arch_spec);
1646  // SetArchitecture() is a no-op if m_arch is already valid.
1647  m_arch = ArchSpec();
1648  return SetArchitecture(merged_arch);
1649 }
1650 
1651 llvm::VersionTuple Module::GetVersion() {
1652  if (ObjectFile *obj_file = GetObjectFile())
1653  return obj_file->GetVersion();
1654  return llvm::VersionTuple();
1655 }
1656 
1658  ObjectFile *obj_file = GetObjectFile();
1659 
1660  if (obj_file)
1661  return obj_file->GetIsDynamicLinkEditor();
1662 
1663  return false;
1664 }
1665 
1667  std::string identifier;
1668  llvm::raw_string_ostream id_strm(identifier);
1669  id_strm << m_arch.GetTriple().str() << '-' << m_file.GetPath();
1670  if (m_object_name)
1671  id_strm << '(' << m_object_name.GetStringRef() << ')';
1672  if (m_object_offset > 0)
1673  id_strm << m_object_offset;
1674  const auto mtime = llvm::sys::toTimeT(m_object_mod_time);
1675  if (mtime > 0)
1676  id_strm << mtime;
1677  return llvm::djbHash(id_strm.str());
1678 }
1679 
1681  std::string key;
1682  llvm::raw_string_ostream strm(key);
1683  strm << m_arch.GetTriple().str() << '-' << m_file.GetFilename();
1684  if (m_object_name)
1685  strm << '(' << m_object_name.GetStringRef() << ')';
1686  strm << '-' << llvm::format_hex(Hash(), 10);
1687  return strm.str();
1688 }
1689 
1691  if (!ModuleList::GetGlobalModuleListProperties().GetEnableLLDBIndexCache())
1692  return nullptr;
1693  // NOTE: intentional leak so we don't crash if global destructor chain gets
1694  // called as other threads still use the result of this function
1695  static DataFileCache *g_data_file_cache =
1697  .GetLLDBIndexCachePath()
1698  .GetPath());
1699  return g_data_file_cache;
1700 }
lldb_private::toString
const char * toString(AppleArm64ExceptionClass EC)
Definition: AppleArm64ExceptionClass.h:38
RegularExpression.h
lldb_private::Module::SymbolIndicesToSymbolContextList
void SymbolIndicesToSymbolContextList(Symtab *symtab, std::vector< uint32_t > &symbol_indexes, SymbolContextList &sc_list)
Definition: Module.cpp:1314
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
lldb_private::Stream::IndentLess
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition: Stream.cpp:171
lldb_private::UUID
Definition: UUID.h:23
lldb_private::Module::GetObjectFile
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Definition: Module.cpp:1232
lldb_private::Symbols::DownloadSymbolFileAsync
static void DownloadSymbolFileAsync(const UUID &uuid)
Locate the symbol file for the given UUID on a background thread.
Definition: LocateSymbolFile.cpp:403
lldb_private::SymbolFile
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:47
lldb_private::SymbolContext::block
Block * block
The Block for a given query.
Definition: SymbolContext.h:321
lldb_private::Module::ReportError
void ReportError(const char *format, Args &&...args)
Definition: Module.h:846
lldb_private::SymbolContext::comp_unit
CompileUnit * comp_unit
The CompileUnit for a given query.
Definition: SymbolContext.h:319
lldb_private::ModuleList::GetGlobalModuleListProperties
static ModuleListProperties & GetGlobalModuleListProperties()
Definition: ModuleList.cpp:760
LLDB_SCOPED_TIMERF
#define LLDB_SCOPED_TIMERF(...)
Definition: Timer.h:86
lldb::ScriptLanguage
ScriptLanguage
Script interpreter types.
Definition: lldb-enumerations.h:217
lldb_private::ObjectFile::CreateSections
virtual void CreateSections(SectionList &unified_section_list)=0
lldb_private::ArchSpec
Definition: ArchSpec.h:32
Mangled.h
lldb_private::RegularExpression
Definition: RegularExpression.h:18
lldb_private::ObjectFile::GetFileSpec
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
Definition: ObjectFile.h:292
lldb_private::ModuleSpec::GetPlatformFileSpec
FileSpec & GetPlatformFileSpec()
Definition: ModuleSpec.h:65
FileSystem.h
lldb_private::Log::GetVerbose
bool GetVerbose() const
Definition: Log.cpp:301
lldb::eSymbolTypeCode
@ eSymbolTypeCode
Definition: lldb-enumerations.h:629
lldb_private::Module::CalculateSymbolContext
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
Definition: Module.cpp:411
CPlusPlusLanguage.h
lldb_private::Module::m_file_has_changed
bool m_file_has_changed
Definition: Module.h:1094
lldb_private::Module::FileHasChanged
bool FileHasChanged() const
Definition: Module.cpp:1117
lldb_private::AddressResolver::ResolveAddress
virtual void ResolveAddress(SearchFilter &filter)
Definition: AddressResolver.cpp:29
CompileUnit.h
lldb_private::Debugger::GetScriptInterpreter
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
Definition: Debugger.cpp:1496
lldb_private::Module::m_symfile_up
lldb::SymbolVendorUP m_symfile_up
A pointer to the symbol vendor for this module.
Definition: Module.h:1074
ModuleSpec.h
lldb_private::Address::CalculateSymbolContextFunction
Function * CalculateSymbolContextFunction() const
Definition: Address.cpp:865
lldb_private::Function::GetAddressRange
const AddressRange & GetAddressRange()
Definition: Function.h:457
lldb_private::Module::GetIsDynamicLinkEditor
bool GetIsDynamicLinkEditor()
Definition: Module.cpp:1657
lldb_private::ObjectFile::GetModuleSpecifications
static size_t GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, lldb::offset_t file_size, ModuleSpecList &specs, lldb::DataBufferSP data_sp=lldb::DataBufferSP())
TypeMap.h
lldb_private::Symbol
Definition: Symbol.h:20
lldb_private::Symbol::ValueIsAddress
bool ValueIsAddress() const
Definition: Symbol.cpp:117
lldb_private::Module::GetIndexCache
static DataFileCache * GetIndexCache()
Get the global index file cache.
Definition: Module.cpp:1690
lldb_private::SourceLocationSpec
Definition: SourceLocationSpec.h:27
Host.h
lldb_private::PathMappingList::FindFile
std::optional< FileSpec > FindFile(const FileSpec &orig_spec) const
Finds a source file given a file spec using the path remappings.
Definition: PathMappingList.cpp:242
lldb_private::SymbolContext::GetAddressRange
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.
Definition: SymbolContext.cpp:380
lldb_private::SymbolContextList::Append
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
Definition: SymbolContext.cpp:1184
lldb_private::Module::GetSymtab
Symtab * GetSymtab()
Definition: Module.cpp:1068
lldb_private::UUID::IsValid
bool IsValid() const
Definition: UUID.h:69
lldb_private::Module::ParseAllDebugSymbols
void ParseAllDebugSymbols()
A debugging function that will cause everything in a module to be parsed.
Definition: Module.cpp:378
lldb_private::SectionList::GetSize
size_t GetSize() const
Definition: Section.h:74
lldb_private::Module::m_platform_file
FileSpec m_platform_file
The path to the module on the platform on which it is being debugged.
Definition: Module.h:1048
lldb_private::ModuleSpecList
Definition: ModuleSpec.h:275
lldb_private::Module::m_objfile_sp
lldb::ObjectFileSP m_objfile_sp
A shared pointer to the object file parser for this module as it may or may not be shared with the Sy...
Definition: Module.h:1067
lldb_private::ScriptInterpreter::LoadScriptingModule
virtual bool LoadScriptingModule(const char *filename, const LoadScriptOptions &options, lldb_private::Status &error, StructuredData::ObjectSP *module_sp=nullptr, FileSpec extra_search_dir={})
Definition: ScriptInterpreter.cpp:56
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:344
lldb_private::Module::FindGlobalVariables
void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, VariableList &variable_list)
Find global and static variables by name.
Definition: Module.cpp:609
lldb_private::Module::LookupInfo::m_name
ConstString m_name
What the user originally typed.
Definition: Module.h:981
lldb_private::ArchSpec::MergeFrom
void MergeFrom(const ArchSpec &other)
Merges fields from another ArchSpec into this ArchSpec.
Definition: ArchSpec.cpp:812
lldb_private::SymbolFile::ParseFunctions
virtual size_t ParseFunctions(CompileUnit &comp_unit)=0
lldb_private::eLoadScriptFromSymFileFalse
@ eLoadScriptFromSymFileFalse
Definition: Target.h:52
lldb_private::SymbolFile::ParseBlocksRecursive
virtual size_t ParseBlocksRecursive(Function &func)=0
lldb_private::AddressRange::GetByteSize
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
Definition: AddressRange.h:221
lldb_private::ModuleSpec::GetObjectName
ConstString & GetObjectName()
Definition: ModuleSpec.h:103
lldb_private::ModuleSpec::GetData
lldb::DataBufferSP GetData() const
Definition: ModuleSpec.h:127
Module.h
lldb_private::ObjectFile::FindPlugin
static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file_spec, lldb::offset_t file_offset, lldb::offset_t file_size, lldb::DataBufferSP &data_sp, lldb::offset_t &data_offset)
Find a ObjectFile plug-in that can parse file_spec.
lldb_private::Module::MergeArchitecture
bool MergeArchitecture(const ArchSpec &arch_spec)
Update the ArchSpec to a more specific variant.
Definition: Module.cpp:1631
ModuleCollection
std::vector< Module * > ModuleCollection
Definition: Module.cpp:90
lldb_private::ObjectFile::IsExecutable
virtual bool IsExecutable() const =0
Tells whether this object file is capable of being the main executable for a process.
lldb_private::XcodeSDK
An abstraction for Xcode-style SDKs that works like ArchSpec.
Definition: XcodeSDK.h:24
lldb_private::CPlusPlusLanguage::MethodName::GetScopeQualifiedName
std::string GetScopeQualifiedName()
Definition: CPlusPlusLanguage.cpp:304
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:443
lldb_private::SymbolContextList
Definition: SymbolContext.h:379
lldb_private::Module::GetSymbolFile
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
Definition: Module.cpp:1052
lldb_private::SymbolContextList::GetContextAtIndex
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
Definition: SymbolContext.cpp:1258
lldb_private::Module
Definition: Module.h:87
lldb_private::CPlusPlusLanguage::MethodName::GetBasename
llvm::StringRef GetBasename()
Definition: CPlusPlusLanguage.cpp:274
lldb_private::CPlusPlusLanguage::MethodName::GetContext
llvm::StringRef GetContext()
Definition: CPlusPlusLanguage.cpp:280
lldb_private::UnwindTable
Definition: UnwindTable.h:24
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:192
lldb_private::FileSpec::GetFilename
const ConstString & GetFilename() const
Filename string const get accessor.
Definition: FileSpec.h:240
lldb_private::Module::Hash
uint32_t Hash()
Get a unique hash for this module.
Definition: Module.cpp:1666
lldb_private::Module::FindTypes_Impl
void FindTypes_Impl(ConstString name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, llvm::DenseSet< lldb_private::SymbolFile * > &searched_symbol_files, TypeMap &types)
Definition: Module.cpp:957
LocateSymbolFile.h
lldb_private::SectionList
Definition: Section.h:34
lldb_private::ObjCLanguage::IsPossibleObjCSelector
static bool IsPossibleObjCSelector(const char *name)
Definition: ObjCLanguage.h:146
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
lldb_private::TypeSystemMap::GetTypeSystemForLanguage
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language, Module *module, bool can_create)
Definition: TypeSystem.cpp:291
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Module::m_unwind_table
std::optional< UnwindTable > m_unwind_table
Table of FuncUnwinders objects created for this Module's functions.
Definition: Module.h:1070
lldb_private::FileSystem
Definition: FileSystem.h:28
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:463
lldb_private::TypeList::GetTypeAtIndex
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
Definition: TypeList.cpp:66
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
Language.h
lldb_private::Symtab::SymbolAtIndex
Symbol * SymbolAtIndex(size_t idx)
Definition: Symtab.cpp:217
lldb_private::SymbolContext::SortTypeList
void SortTypeList(TypeMap &type_map, TypeList &type_list) const
Sorts the types in TypeMap according to SymbolContext to TypeList.
Definition: SymbolContext.cpp:557
lldb_private::ArchSpec::IsCompatibleMatch
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
Definition: ArchSpec.h:515
lldb_private::ModuleFunctionSearchOptions::include_symbols
bool include_symbols
Include the symbol table.
Definition: Module.h:67
lldb_private::Debugger::GetScriptLanguage
lldb::ScriptLanguage GetScriptLanguage() const
Definition: Debugger.cpp:325
lldb_private::Module::m_optimization_warning
std::once_flag m_optimization_warning
Definition: Module.h:1106
lldb_private::Module::RegisterXcodeSDK
void RegisterXcodeSDK(llvm::StringRef sdk, llvm::StringRef sysroot)
This callback will be called by SymbolFile implementations when parsing a compile unit that contains ...
Definition: Module.cpp:1610
lldb_private::CPlusPlusLanguage::ExtractContextAndIdentifier
static bool ExtractContextAndIdentifier(const char *name, llvm::StringRef &context, llvm::StringRef &identifier)
Definition: CPlusPlusLanguage.cpp:397
lldb_private::Module::FindFirstType
lldb::TypeSP FindFirstType(const SymbolContext &sc, ConstString type_name, bool exact_match)
Definition: Module.cpp:981
lldb_private::Target::GetDebugger
Debugger & GetDebugger()
Definition: Target.h:1029
Debugger.h
lldb_private::SectionList::GetNumSections
size_t GetNumSections(uint32_t depth) const
Definition: Section.cpp:527
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:469
lldb_private::Module::~Module
~Module() override
Destructor.
Definition: Module.cpp:266
lldb_private::Module::CalculateSymbolContextModule
lldb::ModuleSP CalculateSymbolContextModule() override
Definition: Module.cpp:415
Section.h
lldb_private::TypeMap::GetSize
uint32_t GetSize() const
Definition: TypeMap.cpp:75
lldb_private::LLDBLog::Modules
@ Modules
lldb_private::Module::SetFileSpecAndObjectName
void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name)
Definition: Module.cpp:1074
lldb_private::VariableList
Definition: VariableList.h:18
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::ModuleSpec::GetSymbolFileSpec
FileSpec & GetSymbolFileSpec()
Definition: ModuleSpec.h:77
Process.h
lldb_private::Module::ForEachTypeSystem
void ForEachTypeSystem(llvm::function_ref< bool(lldb::TypeSystemSP)> callback)
Call callback for each TypeSystem in this Module.
Definition: Module.cpp:373
lldb::eScriptLanguageNone
@ eScriptLanguageNone
Definition: lldb-enumerations.h:218
lldb_private::ModuleFunctionSearchOptions::include_inlines
bool include_inlines
Include inlined functions.
Definition: Module.h:69
lldb_private::Module::FindTypesInNamespace
void FindTypesInNamespace(ConstString type_name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, TypeList &type_list)
Find types by name that are in a namespace.
Definition: Module.cpp:967
lldb_private::eLoadScriptFromSymFileWarn
@ eLoadScriptFromSymFileWarn
Definition: Target.h:53
DataFileCache.h
lldb_private::Module::GetPlatformFileSpec
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
Definition: Module.h:512
Target.h
lldb_private::Module::m_did_load_symfile
std::atomic< bool > m_did_load_symfile
Definition: Module.h:1092
lldb_private::ModuleSpec::GetUUID
UUID & GetUUID()
Definition: ModuleSpec.h:99
lldb_private::Module::SetSymbolFileFileSpec
void SetSymbolFileFileSpec(const FileSpec &file)
Definition: Module.cpp:1385
lldb_private::ObjectFile::GetSymtab
Symtab * GetSymtab()
Gets the symbol table for the currently selected architecture (and object for archives).
Definition: ObjectFile.cpp:725
lldb_private::Target::GetPlatform
lldb::PlatformSP GetPlatform()
Definition: Target.h:1403
lldb_private::Module::GetFileSpec
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition: Module.h:498
lldb_private::Module::LookupInfo
Definition: Module.h:950
lldb_private::Module::m_sections_up
lldb::SectionListUP m_sections_up
Unified section list for module that is used by the ObjectFile and and ObjectFile instances for the d...
Definition: Module.h:1087
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::Module::ReportWarningUnsupportedLanguage
void ReportWarningUnsupportedLanguage(lldb::LanguageType language, std::optional< lldb::user_id_t > debugger_id)
Definition: Module.cpp:1142
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb::eSymbolTypeAny
@ eSymbolTypeAny
Definition: lldb-enumerations.h:626
lldb_private::SymbolContext::symbol
Symbol * symbol
The Symbol for a given query.
Definition: SymbolContext.h:323
lldb_private::ObjectFile::GetIsDynamicLinkEditor
virtual bool GetIsDynamicLinkEditor()
Return true if this file is a dynamic link editor (dyld)
Definition: ObjectFile.h:634
lldb_private::Module::LookupInfo::NameMatchesLookupInfo
bool NameMatchesLookupInfo(ConstString function_name, lldb::LanguageType language_type=lldb::eLanguageTypeUnknown) const
Definition: Module.cpp:735
lldb_private::Function
Definition: Function.h:409
LLDBAssert.h
lldb_private::Module::GetDescription
void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
Definition: Module.cpp:1095
lldb_private::ConstString::SetString
void SetString(const llvm::StringRef &s)
Definition: ConstString.cpp:305
lldb_private::Stream::Indent
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:201
lldb_private::Module::m_uuid
UUID m_uuid
Each module is assumed to have a unique identifier to help match it up to debug symbols.
Definition: Module.h:1044
Log.h
lldb_private::Module::m_object_name
ConstString m_object_name
The name an object within this module that is selected, or empty of the module is represented by m_fi...
Definition: Module.h:1056
lldb_private::ModuleSpec::GetObjectModificationTime
llvm::sys::TimePoint & GetObjectModificationTime()
Definition: ModuleSpec.h:117
lldb_private::ConstString::IsEmpty
bool IsEmpty() const
Test for empty string.
Definition: ConstString.h:303
lldb_private::Language::LanguageIsC
static bool LanguageIsC(lldb::LanguageType language)
Definition: Language.cpp:273
SearchFilter.h
lldb_private::FileSpec::Match
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
Definition: FileSpec.cpp:300
GetModuleCollection
static ModuleCollection & GetModuleCollection()
Definition: Module.cpp:92
lldb_private::Module::GetTypeSystemForLanguage
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language)
Definition: Module.cpp:369
lldb_private::Module::m_object_mod_time
llvm::sys::TimePoint m_object_mod_time
Definition: Module.h:1060
lldb_private::TypeMap::RemoveMismatchedTypes
void RemoveMismatchedTypes(llvm::StringRef type_scope, llvm::StringRef type_basename, lldb::TypeClass type_class, bool exact_match)
Definition: TypeMap.cpp:130
lldb_private::Module::m_language_warning
std::once_flag m_language_warning
Definition: Module.h:1107
lldb_private::Module::FindSymbolsMatchingRegExAndType
void FindSymbolsMatchingRegExAndType(const RegularExpression &regex, lldb::SymbolType symbol_type, SymbolContextList &sc_list, Mangled::NamePreference mangling_preference=Mangled::ePreferDemangled)
Definition: Module.cpp:1352
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
lldb_private::SymbolFile::ParseTypes
virtual size_t ParseTypes(CompileUnit &comp_unit)=0
lldb_private::SymbolContext::function
Function * function
The Function for a given query.
Definition: SymbolContext.h:320
StreamString.h
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:291
lldb_private::Module::ResolveSymbolContextsForFileSpec
uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list)
Resolve items in the symbol context for a given file and line.
Definition: Module.cpp:587
Type.h
lldb_private::Symbol::GetAddressRef
Address & GetAddressRef()
Definition: Symbol.h:57
lldb_private::AddressResolver::GetAddressRangeAtIndex
AddressRange & GetAddressRangeAtIndex(size_t idx)
Definition: AddressResolver.cpp:41
lldb_private::Module::ReportErrorIfModifyDetected
void ReportErrorIfModifyDetected(const char *format, Args &&...args)
Definition: Module.h:853
lldb_private::ObjectFile::GetUUID
virtual UUID GetUUID()=0
Gets the UUID for this object file.
lldb_private::TypeList::GetSize
uint32_t GetSize() const
Definition: TypeList.cpp:60
lldb_private::Module::GetUnifiedSectionList
SectionList * GetUnifiedSectionList()
Definition: Module.cpp:1298
lldb_private::Module::ResolveFileAddress
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
Definition: Module.cpp:440
lldb_private::Module::GetVersion
llvm::VersionTuple GetVersion()
Definition: Module.cpp:1651
lldb_private::SymbolContextList::GetSize
uint32_t GetSize() const
Get accessor for a symbol context list size.
Definition: SymbolContext.cpp:1274
FileSpecList.h
lldb_private::AddressResolver::GetNumberOfAddresses
size_t GetNumberOfAddresses()
Definition: AddressResolver.cpp:37
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::Module::LoadScriptingResourceInTarget
bool LoadScriptingResourceInTarget(Target *target, Status &error, Stream *feedback_stream=nullptr)
Definition: Module.cpp:1475
lldb_private::Module::SectionFileAddressesChanged
virtual void SectionFileAddressesChanged()
Notify the module that the file addresses for the Sections have been updated.
Definition: Module.cpp:1281
lldb_private::Language::LanguageIsObjC
static bool LanguageIsObjC(lldb::LanguageType language)
Definition: Language.cpp:263
lldb_private::FileSystem::GetByteSize
uint64_t GetByteSize(const FileSpec &file_spec) const
Returns the on-disk size of the given file in bytes.
Definition: common/FileSystem.cpp:110
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::Symtab::FindSymbolContainingFileAddress
Symbol * FindSymbolContainingFileAddress(lldb::addr_t file_addr)
Definition: Symtab.cpp:1035
lldb::eDescriptionLevelFull
@ eDescriptionLevelFull
Definition: lldb-enumerations.h:210
lldb_private::AddressRange
Definition: AddressRange.h:25
Timer.h
lldb_private::SymbolContext::GetFunctionName
ConstString GetFunctionName(Mangled::NamePreference preference=Mangled::ePreferDemangled) const
Find a name of the innermost function for the symbol context.
Definition: SymbolContext.cpp:650
ObjCLanguage.h
lldb_private::Module::GetMemoryObjectFile
ObjectFile * GetMemoryObjectFile(const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, Status &error, size_t size_to_read=512)
Load an object file from memory.
Definition: Module.cpp:296
lldb_private::SectionList::GetSectionAtIndex
lldb::SectionSP GetSectionAtIndex(size_t idx) const
Definition: Section.cpp:538
lldb_private::Module::GetObjectName
ConstString GetObjectName() const
Definition: Module.cpp:1230
lldb_private::FileSystem::GetModificationTime
llvm::sys::TimePoint GetModificationTime(const FileSpec &file_spec) const
Returns the modification time of the given file.
Definition: common/FileSystem.cpp:97
LLDB_SCOPED_TIMER
#define LLDB_SCOPED_TIMER()
Definition: Timer.h:83
lldb_private::Module::SetLoadAddress
bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset, bool &changed)
Set the load address for all sections in a module to be the file address plus slide.
Definition: Module.cpp:1550
lldb_private::Symbol::IsSynthetic
bool IsSynthetic() const
Definition: Symbol.h:166
lldb_private::Debugger
Definition: Debugger.h:75
lldb_private::CompileUnit::GetPrimaryFile
const FileSpec & GetPrimaryFile() const
Return the primary source file associated with this compile unit.
Definition: CompileUnit.h:227
HostInfo.h
lldb_private::Module::FindFunctions
void FindFunctions(const LookupInfo &lookup_info, const CompilerDeclContext &parent_decl_ctx, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list)
Find functions by lookup info.
Definition: Module.cpp:829
lldb_private::PathMappingList::Replace
bool Replace(llvm::StringRef path, llvm::StringRef replacement, bool notify)
Definition: PathMappingList.cpp:253
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::SearchFilterByModule
Definition: SearchFilter.h:314
lldb_private::Module::m_data_sp
lldb::DataBufferSP m_data_sp
DataBuffer containing the module image, if it was provided at construction time.
Definition: Module.h:1065
lldb_private::Module::m_first_file_changed_log
bool m_first_file_changed_log
Definition: Module.h:1095
lldb_private::ObjectFile::IsStripped
virtual bool IsStripped()=0
Detect if this object file has been stripped of local symbols.
lldb_private::ArchSpec::IsValid
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:361
lldb_private::ModuleSpecList::FindMatchingModuleSpec
bool FindMatchingModuleSpec(const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
Definition: ModuleSpec.h:333
lldb_private::Address::GetSection
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:429
TypeSystem.h
lldb_private::Stream::PutChar
size_t PutChar(char ch)
Definition: Stream.cpp:104
lldb_private::PathMappingList::Append
void Append(llvm::StringRef path, llvm::StringRef replacement, bool notify)
Definition: PathMappingList.cpp:61
lldb_private::Module::GetUnwindTable
UnwindTable & GetUnwindTable()
Returns a reference to the UnwindTable for this Module.
Definition: Module.cpp:1289
lldb::SymbolType
SymbolType
Symbol types.
Definition: lldb-enumerations.h:625
lldb_private::Module::m_mod_time
llvm::sys::TimePoint m_mod_time
The modification time for this module when it was created.
Definition: Module.h:1041
lldb_private::ObjectFile::Dump
virtual void Dump(Stream *s)=0
Dump a description of this object to a Stream.
lldb_private::SymbolVendor::FindPlugin
static SymbolVendor * FindPlugin(const lldb::ModuleSP &module_sp, Stream *feedback_strm)
Definition: SymbolVendor.cpp:26
lldb_private::TypeMap
Definition: TypeMap.h:20
lldb_private::SectionList::DeleteSection
bool DeleteSection(size_t idx)
Definition: Section.cpp:480
lldb_private::CompilerDeclContext
Represents a generic declaration context in a program.
Definition: CompilerDeclContext.h:30
lldb_private::Language::FindPlugin
static Language * FindPlugin(lldb::LanguageType language)
Definition: Language.cpp:53
lldb_private::Module::FindCompileUnits
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list)
Find compile units by partial or full path.
Definition: Module.cpp:623
lldb_private::Module::GetNumCompileUnits
size_t GetNumCompileUnits()
Get the number of compile units for this module.
Definition: Module.cpp:421
ObjectFile.h
lldb_private::ModuleFunctionSearchOptions
Options used by Module::FindFunctions.
Definition: Module.h:65
lldb_private::Module::m_old_symfiles
std::vector< lldb::SymbolVendorUP > m_old_symfiles
If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file,.
Definition: Module.h:1076
lldb_private::SymbolFile::PreloadSymbols
virtual void PreloadSymbols()
Definition: SymbolFile.cpp:31
lldb_private::Module::m_symfile_spec
FileSpec m_symfile_spec
If this path is valid, then this is the file that will be used as the symbol file for this module.
Definition: Module.h:1053
lldb_private::CompileUnit::ForeachFunction
void ForeachFunction(llvm::function_ref< bool(const lldb::FunctionSP &)> lambda) const
Apply a lambda to each function in this compile unit.
Definition: CompileUnit.cpp:61
TypeList.h
Symbol.h
lldb_private::Module::GetSectionList
virtual SectionList * GetSectionList()
Get the unified section list for the module.
Definition: Module.cpp:1271
lldb_private::Module::SetArchitecture
bool SetArchitecture(const ArchSpec &new_arch)
Definition: Module.cpp:1542
lldbassert
#define lldbassert(x)
Definition: LLDBAssert.h:15
lldb_private::ModuleSpec::GetFileSpec
FileSpec & GetFileSpec()
Definition: ModuleSpec.h:53
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
PosixApi.h
lldb_private::Status
Definition: Status.h:44
lldb_private::Module::LookupInfo::GetLookupName
ConstString GetLookupName() const
Definition: Module.h:961
lldb_private::Module::GetSpecificationDescription
std::string GetSpecificationDescription() const
Get the module path and object name.
Definition: Module.cpp:1085
lldb_private::Module::RemapSourceFile
std::optional< std::string > RemapSourceFile(llvm::StringRef path) const
Remaps a source file given path into new_path.
Definition: Module.cpp:1603
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:547
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:444
lldb_private::Symtab
Definition: Symtab.h:22
uint32_t
lldb_private::Stream::IndentMore
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition: Stream.cpp:168
lldb_private::Language
Definition: Language.h:29
lldb_private::Module::LogMessageVerboseBacktrace
void LogMessageVerboseBacktrace(Log *log, const char *format, Args &&...args)
Definition: Module.h:834
lldb_private::Address
Definition: Address.h:59
lldb_private::Module::DumpSymbolContext
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
Definition: Module.cpp:417
lldb_private::CPlusPlusLanguage::MethodName
Definition: CPlusPlusLanguage.h:28
lldb_private::SymbolFile::SetLoadDebugInfoEnabled
virtual void SetLoadDebugInfoEnabled()
Specify debug info should be loaded.
Definition: SymbolFile.h:137
lldb_private::Module::LookupInfo::GetNameTypeMask
lldb::FunctionNameType GetNameTypeMask() const
Definition: Module.h:965
lldb_private::Module::PreloadSymbols
void PreloadSymbols()
Definition: Module.cpp:1369
lldb_private::LLDBLog::Object
@ Object
lldb_private::Module::GetCacheKey
std::string GetCacheKey()
Get a unique cache key for the current module.
Definition: Module.cpp:1680
Symtab.h
lldb_private::ObjectFile::ClearSymtab
virtual void ClearSymtab()
Frees the symbol table.
Definition: ObjectFile.cpp:574
lldb_private::Address::ResolveAddressUsingFileSections
bool ResolveAddressUsingFileSections(lldb::addr_t addr, const SectionList *sections)
Resolve a file virtual address using a section list.
Definition: Address.cpp:248
lldb_private::Symtab::AppendSymbolIndexesMatchingRegExAndType
uint32_t AppendSymbolIndexesMatchingRegExAndType(const RegularExpression &regex, lldb::SymbolType symbol_type, std::vector< uint32_t > &indexes, Mangled::NamePreference name_preference=Mangled::ePreferDemangled)
Definition: Symtab.cpp:745
lldb_private::Module::ResolveSymbolContextForAddress
uint32_t ResolveSymbolContextForAddress(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc, bool resolve_tail_call_address=false)
Resolve the symbol context for the given address.
Definition: Module.cpp:448
lldb_private::Stream::AsRawOstream
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:357
lldb_private::Module::m_object_offset
uint64_t m_object_offset
Definition: Module.h:1059
lldb_private::Module::SetUUID
void SetUUID(const lldb_private::UUID &uuid)
Definition: Module.cpp:358
lldb_private::Module::FindSourceFile
bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const
Finds a source file given a file spec using the module source path remappings (if any).
Definition: Module.cpp:1593
lldb_private::Module::MatchesModuleSpec
bool MatchesModuleSpec(const ModuleSpec &module_ref)
Definition: Module.cpp:1562
lldb_private::ObjectFile::SetLoadAddress
virtual bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset)
Sets the load address for an entire module, assuming a rigid slide of sections, if possible in the im...
Definition: ObjectFile.h:416
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
lldb_private::FileSpec::Dump
void Dump(llvm::raw_ostream &s) const
Dump this object to a Stream.
Definition: FileSpec.cpp:324
lldb_private::Module::m_arch
ArchSpec m_arch
The architecture for this module.
Definition: Module.h:1043
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
lldb_private::ModuleSpec::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:89
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:128
lldb_private::Module::FindAddressesForLine
void FindAddressesForLine(const lldb::TargetSP target_sp, const FileSpec &file, uint32_t line, Function *function, std::vector< Address > &output_local, std::vector< Address > &output_extern)
Find addresses by file/line.
Definition: Module.cpp:933
lldb_private::Module::m_type_system_map
TypeSystemMap m_type_system_map
A map of any type systems associated with this module.
Definition: Module.h:1080
Function.h
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::Module::IsLoadedInTarget
bool IsLoadedInTarget(Target *target)
Tells whether this module has been loaded in the target passed in.
Definition: Module.cpp:1458
lldb_private::FileSystem::Instance
static FileSystem & Instance()
Definition: common/FileSystem.cpp:47
lldb_private::Debugger::ReportWarning
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
Definition: Debugger.cpp:1396
lldb_private::DataFileCache
This class enables data to be cached into a directory using the llvm caching code.
Definition: DataFileCache.h:45
lldb_private::Module::FindTypes
void FindTypes(ConstString type_name, bool exact_match, size_t max_matches, llvm::DenseSet< lldb_private::SymbolFile * > &searched_symbol_files, TypeList &types)
Find types by name.
Definition: Module.cpp:991
Status.h
SymbolContext.h
lldb_private::SymbolContext::Clear
void Clear(bool clear_target)
Clear the object's state.
Definition: SymbolContext.cpp:56
lldb_private::CPlusPlusLanguage::IsCPPMangledName
static bool IsCPPMangledName(llvm::StringRef name)
Definition: CPlusPlusLanguage.cpp:379
lldb_private::SymbolFile::GetCompileUnitAtIndex
virtual lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx)=0
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::SymbolContext::GetLanguage
lldb::LanguageType GetLanguage() const
Definition: SymbolContext.cpp:418
lldb_private::SymbolFile::ResolveSymbolContext
virtual uint32_t ResolveSymbolContext(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc)=0
lldb_private::Symtab::eVisibilityAny
@ eVisibilityAny
Definition: Symtab.h:33
lldb_private::Module::ReportWarningOptimization
void ReportWarningOptimization(std::optional< lldb::user_id_t > debugger_id)
Definition: Module.cpp:1128
lldb_private::Module::LogMessage
void LogMessage(Log *log, const char *format, Args &&...args)
Definition: Module.h:829
lldb_private::AddressResolverFileLine
Definition: AddressResolverFileLine.h:29
lldb_private::SymbolFile::GetSymtab
virtual Symtab * GetSymtab()=0
lldb_private::Symtab::eDebugAny
@ eDebugAny
Definition: Symtab.h:30
lldb_private::TypeList
Definition: TypeList.h:20
lldb_private::Address::IsSectionOffset
bool IsSectionOffset() const
Check if an address is section offset.
Definition: Address.h:332
CommandInterpreter.h
lldb_private::Address::GetOffset
lldb::addr_t GetOffset() const
Get the section relative offset value.
Definition: Address.h:319
lldb_private::ObjCLanguage::IsPossibleObjCMethodName
static bool IsPossibleObjCMethodName(const char *name)
Definition: ObjCLanguage.h:138
lldb_private::Module::LookupInfo::LookupInfo
LookupInfo()=default
lldb_private::LanguageSet
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: TypeSystem.h:45
lldb_private::LoadScriptOptions
Definition: ScriptInterpreter.h:77
lldb_private::Module::FindSymbolsWithNameAndType
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
Definition: Module.cpp:1340
lldb_private::Module::LookupInfo::Prune
void Prune(SymbolContextList &sc_list, size_t start_idx) const
Definition: Module.cpp:770
lldb_private::Module::FindFirstSymbolWithNameAndType
const Symbol * FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type=lldb::eSymbolTypeAny)
Find a symbol in the object file's symbol table.
Definition: Module.cpp:1304
Stream.h
lldb_private::Log
Definition: Log.h:115
lldb_private::Module::m_source_mappings
PathMappingList m_source_mappings
Module specific source remappings for when you have debug info for a module that doesn't match where ...
Definition: Module.h:1084
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::Module::GetArchitecture
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
Definition: Module.cpp:1083
lldb::eSymbolTypeResolver
@ eSymbolTypeResolver
Definition: lldb-enumerations.h:630
lldb_private::Module::GetUUID
const lldb_private::UUID & GetUUID()
Get a reference to the UUID value contained in this object.
Definition: Module.cpp:343
lldb_private::CPlusPlusLanguage::MethodName::IsValid
bool IsValid()
Definition: CPlusPlusLanguage.h:39
lldb_private::Module::Dump
void Dump(Stream *s)
Dump a description of this object to a Stream.
Definition: Module.cpp:1209
lldb_private::RegularExpression::GetText
llvm::StringRef GetText() const
Access the regular expression text.
Definition: RegularExpression.cpp:33
SymbolVendor.h
lldb_private::ModuleSpec::GetObjectOffset
uint64_t GetObjectOffset() const
Definition: ModuleSpec.h:107
PATH_MAX
#define PATH_MAX
Definition: windows/PosixApi.h:25
lldb_private::Language::GetNameForLanguageType
static const char * GetNameForLanguageType(lldb::LanguageType language)
Definition: Language.cpp:217
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb_private::Module::FindFunctionSymbols
void FindFunctionSymbols(ConstString name, uint32_t name_type_mask, SymbolContextList &sc_list)
Find a function symbols in the object file's symbol table.
Definition: Module.cpp:1332
lldb_private::ObjectFile::SectionFileAddressesChanged
virtual void SectionFileAddressesChanged()
Notify the ObjectFile that the file addresses in the Sections for this module have been changed.
Definition: ObjectFile.h:322
lldb_private::SymbolFile::GetObjectFile
virtual ObjectFile * GetObjectFile()=0
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:366
ScriptInterpreter.h
AddressResolverFileLine.h
lldb_private::Debugger::ReportError
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
Definition: Debugger.cpp:1403
lldb_private::Module::m_mutex
std::recursive_mutex m_mutex
A mutex to keep this object happy in multi-threaded environments.
Definition: Module.h:1037
AddressRange.h
lldb_private::Symbol::GetType
lldb::SymbolType GetType() const
Definition: Symbol.h:153
lldb_private::Address::Slide
bool Slide(int64_t offset)
Definition: Address.h:449
lldb_private::Symtab::GetObjectFile
ObjectFile * GetObjectFile() const
Definition: Symtab.h:137
lldb
Definition: SBAddress.h:15
lldb_private::SymbolFile::FindGlobalVariables
virtual void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, VariableList &variables)
Definition: SymbolFile.cpp:114
lldb_private::Module::GetAllocationModuleCollectionMutex
static std::recursive_mutex & GetAllocationModuleCollectionMutex()
Definition: Module.cpp:106
lldb_private::Module::ReportWarning
void ReportWarning(const char *format, Args &&...args)
Definition: Module.h:841
lldb_private::TypeSystemMap::ForEach
void ForEach(std::function< bool(lldb::TypeSystemSP)> const &callback)
Definition: TypeSystem.cpp:217
lldb_private::Module::IsExecutable
bool IsExecutable()
Tells whether this module is capable of being the main executable for a process.
Definition: Module.cpp:1451
LLDBLog.h
SymbolFile.h
lldb_private::ObjectFile
Definition: ObjectFile.h:60
lldb::eDescriptionLevelBrief
@ eDescriptionLevelBrief
Definition: lldb-enumerations.h:209
lldb_private::SymbolFile::ParseVariablesForContext
virtual size_t ParseVariablesForContext(const SymbolContext &sc)=0
DataBufferHeap.h
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:208
lldb_private::Module::Module
Module()
Definition: Module.cpp:260
lldb_private::Module::GetCompileUnitAtIndex
lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx)
Definition: Module.cpp:428
lldb_private::Module::m_file
FileSpec m_file
The file representation on disk for this module (if there is one).
Definition: Module.h:1046
lldb_private::Module::m_did_set_uuid
std::atomic< bool > m_did_set_uuid
Definition: Module.h:1093
lldb_private::Status::AsCString
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
lldb_private::Symtab::ForEachSymbolContainingFileAddress
void ForEachSymbolContainingFileAddress(lldb::addr_t file_addr, std::function< bool(Symbol *)> const &callback)
Definition: Symtab.cpp:1051
lldb_private::LoadScriptFromSymFile
LoadScriptFromSymFile
Definition: Target.h:50
lldb_private::SymbolContextList::RemoveContextAtIndex
bool RemoveContextAtIndex(size_t idx)
Definition: SymbolContext.cpp:1266
lldb_private::PathMappingList::RemapPath
bool RemapPath(ConstString path, ConstString &new_path) const
Definition: PathMappingList.cpp:166
lldb_private::Log::PutCString
void PutCString(const char *cstr)
Definition: Log.cpp:134
lldb_private::Module::m_did_load_objfile
std::atomic< bool > m_did_load_objfile
Definition: Module.h:1091
lldb_private::Type::GetTypeScopeAndBasename
static bool GetTypeScopeAndBasename(llvm::StringRef name, llvm::StringRef &scope, llvm::StringRef &basename, lldb::TypeClass &type_class)
Definition: Type.cpp:676