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