LLDB  mainline
ModuleList.cpp
Go to the documentation of this file.
1 //===-- ModuleList.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/ModuleList.h"
10 #include "lldb/Core/FileSpecList.h"
11 #include "lldb/Core/Module.h"
12 #include "lldb/Core/ModuleSpec.h"
13 #include "lldb/Host/FileSystem.h"
19 #include "lldb/Symbol/ObjectFile.h"
21 #include "lldb/Symbol/TypeList.h"
23 #include "lldb/Utility/ArchSpec.h"
25 #include "lldb/Utility/LLDBLog.h"
26 #include "lldb/Utility/Log.h"
27 #include "lldb/Utility/UUID.h"
28 #include "lldb/lldb-defines.h"
29 
30 #if defined(_WIN32)
32 #endif
33 
34 #include "clang/Driver/Driver.h"
35 #include "llvm/ADT/StringRef.h"
36 #include "llvm/Support/FileSystem.h"
37 #include "llvm/Support/Threading.h"
38 #include "llvm/Support/raw_ostream.h"
39 
40 #include <chrono>
41 #include <memory>
42 #include <mutex>
43 #include <string>
44 #include <utility>
45 
46 namespace lldb_private {
47 class Function;
48 }
49 namespace lldb_private {
50 class RegularExpression;
51 }
52 namespace lldb_private {
53 class Stream;
54 }
55 namespace lldb_private {
56 class SymbolFile;
57 }
58 namespace lldb_private {
59 class Target;
60 }
61 
62 using namespace lldb;
63 using namespace lldb_private;
64 
65 namespace {
66 
67 #define LLDB_PROPERTIES_modulelist
68 #include "CoreProperties.inc"
69 
70 enum {
71 #define LLDB_PROPERTIES_modulelist
72 #include "CorePropertiesEnum.inc"
73 };
74 
75 } // namespace
76 
77 ModuleListProperties::ModuleListProperties() {
78  m_collection_sp =
79  std::make_shared<OptionValueProperties>(ConstString("symbols"));
80  m_collection_sp->Initialize(g_modulelist_properties);
81  m_collection_sp->SetValueChangedCallback(ePropertySymLinkPaths,
82  [this] { UpdateSymlinkMappings(); });
83 
84  llvm::SmallString<128> path;
85  if (clang::driver::Driver::getDefaultModuleCachePath(path)) {
86  lldbassert(SetClangModulesCachePath(FileSpec(path)));
87  }
88 
89  path.clear();
90  if (llvm::sys::path::cache_directory(path)) {
91  llvm::sys::path::append(path, "lldb");
92  llvm::sys::path::append(path, "IndexCache");
93  lldbassert(SetLLDBIndexCachePath(FileSpec(path)));
94  }
95 
96 }
97 
98 bool ModuleListProperties::GetEnableExternalLookup() const {
99  const uint32_t idx = ePropertyEnableExternalLookup;
100  return m_collection_sp->GetPropertyAtIndexAsBoolean(
101  nullptr, idx, g_modulelist_properties[idx].default_uint_value != 0);
102 }
103 
104 bool ModuleListProperties::SetEnableExternalLookup(bool new_value) {
105  return m_collection_sp->SetPropertyAtIndexAsBoolean(
106  nullptr, ePropertyEnableExternalLookup, new_value);
107 }
108 
109 bool ModuleListProperties::GetEnableBackgroundLookup() const {
110  const uint32_t idx = ePropertyEnableBackgroundLookup;
111  return m_collection_sp->GetPropertyAtIndexAsBoolean(
112  nullptr, idx, g_modulelist_properties[idx].default_uint_value != 0);
113 }
114 
115 FileSpec ModuleListProperties::GetClangModulesCachePath() const {
116  return m_collection_sp
117  ->GetPropertyAtIndexAsOptionValueFileSpec(nullptr, false,
118  ePropertyClangModulesCachePath)
119  ->GetCurrentValue();
120 }
121 
122 bool ModuleListProperties::SetClangModulesCachePath(const FileSpec &path) {
123  return m_collection_sp->SetPropertyAtIndexAsFileSpec(
124  nullptr, ePropertyClangModulesCachePath, path);
125 }
126 
127 FileSpec ModuleListProperties::GetLLDBIndexCachePath() const {
128  return m_collection_sp
129  ->GetPropertyAtIndexAsOptionValueFileSpec(nullptr, false,
130  ePropertyLLDBIndexCachePath)
131  ->GetCurrentValue();
132 }
133 
134 bool ModuleListProperties::SetLLDBIndexCachePath(const FileSpec &path) {
135  return m_collection_sp->SetPropertyAtIndexAsFileSpec(
136  nullptr, ePropertyLLDBIndexCachePath, path);
137 }
138 
139 bool ModuleListProperties::GetEnableLLDBIndexCache() const {
140  const uint32_t idx = ePropertyEnableLLDBIndexCache;
141  return m_collection_sp->GetPropertyAtIndexAsBoolean(
142  nullptr, idx, g_modulelist_properties[idx].default_uint_value != 0);
143 }
144 
145 bool ModuleListProperties::SetEnableLLDBIndexCache(bool new_value) {
146  return m_collection_sp->SetPropertyAtIndexAsBoolean(
147  nullptr, ePropertyEnableLLDBIndexCache, new_value);
148 }
149 
150 uint64_t ModuleListProperties::GetLLDBIndexCacheMaxByteSize() {
151  const uint32_t idx = ePropertyLLDBIndexCacheMaxByteSize;
152  return m_collection_sp->GetPropertyAtIndexAsUInt64(
153  nullptr, idx, g_modulelist_properties[idx].default_uint_value);
154 }
155 
156 uint64_t ModuleListProperties::GetLLDBIndexCacheMaxPercent() {
157  const uint32_t idx = ePropertyLLDBIndexCacheMaxPercent;
158  return m_collection_sp->GetPropertyAtIndexAsUInt64(
159  nullptr, idx, g_modulelist_properties[idx].default_uint_value);
160 }
161 
162 uint64_t ModuleListProperties::GetLLDBIndexCacheExpirationDays() {
163  const uint32_t idx = ePropertyLLDBIndexCacheExpirationDays;
164  return m_collection_sp->GetPropertyAtIndexAsUInt64(
165  nullptr, idx, g_modulelist_properties[idx].default_uint_value);
166 }
167 
168 void ModuleListProperties::UpdateSymlinkMappings() {
169  FileSpecList list = m_collection_sp
170  ->GetPropertyAtIndexAsOptionValueFileSpecList(
171  nullptr, false, ePropertySymLinkPaths)
172  ->GetCurrentValue();
173  llvm::sys::ScopedWriter lock(m_symlink_paths_mutex);
174  const bool notify = false;
175  m_symlink_paths.Clear(notify);
176  for (FileSpec symlink : list) {
177  FileSpec resolved;
178  Status status = FileSystem::Instance().Readlink(symlink, resolved);
179  if (status.Success())
180  m_symlink_paths.Append(symlink.GetPath(), resolved.GetPath(), notify);
181  }
182 }
183 
184 PathMappingList ModuleListProperties::GetSymlinkMappings() const {
185  llvm::sys::ScopedReader lock(m_symlink_paths_mutex);
186  return m_symlink_paths;
187 }
188 
189 bool ModuleListProperties::GetLoadSymbolOnDemand() {
190  const uint32_t idx = ePropertyLoadSymbolOnDemand;
191  return m_collection_sp->GetPropertyAtIndexAsBoolean(
192  nullptr, idx, g_modulelist_properties[idx].default_uint_value != 0);
193 }
194 
195 ModuleList::ModuleList() : m_modules(), m_modules_mutex() {}
196 
197 ModuleList::ModuleList(const ModuleList &rhs) : m_modules(), m_modules_mutex() {
198  std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex);
199  std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex);
200  m_modules = rhs.m_modules;
201 }
202 
204  : m_modules(), m_modules_mutex(), m_notifier(notifier) {}
205 
207  if (this != &rhs) {
208  std::lock(m_modules_mutex, rhs.m_modules_mutex);
209  std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex,
210  std::adopt_lock);
211  std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex,
212  std::adopt_lock);
213  m_modules = rhs.m_modules;
214  }
215  return *this;
216 }
217 
218 ModuleList::~ModuleList() = default;
219 
220 void ModuleList::AppendImpl(const ModuleSP &module_sp, bool use_notifier) {
221  if (module_sp) {
222  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
223  m_modules.push_back(module_sp);
224  if (use_notifier && m_notifier)
225  m_notifier->NotifyModuleAdded(*this, module_sp);
226  }
227 }
228 
229 void ModuleList::Append(const ModuleSP &module_sp, bool notify) {
230  AppendImpl(module_sp, notify);
231 }
232 
234  const ModuleSP &module_sp,
236  if (module_sp) {
237  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
238 
239  // First remove any equivalent modules. Equivalent modules are modules
240  // whose path, platform path and architecture match.
241  ModuleSpec equivalent_module_spec(module_sp->GetFileSpec(),
242  module_sp->GetArchitecture());
243  equivalent_module_spec.GetPlatformFileSpec() =
244  module_sp->GetPlatformFileSpec();
245 
246  size_t idx = 0;
247  while (idx < m_modules.size()) {
248  ModuleSP test_module_sp(m_modules[idx]);
249  if (test_module_sp->MatchesModuleSpec(equivalent_module_spec)) {
250  if (old_modules)
251  old_modules->push_back(test_module_sp);
252  RemoveImpl(m_modules.begin() + idx);
253  } else {
254  ++idx;
255  }
256  }
257  // Now add the new module to the list
258  Append(module_sp);
259  }
260 }
261 
262 bool ModuleList::AppendIfNeeded(const ModuleSP &new_module, bool notify) {
263  if (new_module) {
264  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
265  for (const ModuleSP &module_sp : m_modules) {
266  if (module_sp.get() == new_module.get())
267  return false; // Already in the list
268  }
269  // Only push module_sp on the list if it wasn't already in there.
270  Append(new_module, notify);
271  return true;
272  }
273  return false;
274 }
275 
276 void ModuleList::Append(const ModuleList &module_list) {
277  for (auto pos : module_list.m_modules)
278  Append(pos);
279 }
280 
281 bool ModuleList::AppendIfNeeded(const ModuleList &module_list) {
282  bool any_in = false;
283  for (auto pos : module_list.m_modules) {
284  if (AppendIfNeeded(pos))
285  any_in = true;
286  }
287  return any_in;
288 }
289 
290 bool ModuleList::RemoveImpl(const ModuleSP &module_sp, bool use_notifier) {
291  if (module_sp) {
292  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
293  collection::iterator pos, end = m_modules.end();
294  for (pos = m_modules.begin(); pos != end; ++pos) {
295  if (pos->get() == module_sp.get()) {
296  m_modules.erase(pos);
297  if (use_notifier && m_notifier)
298  m_notifier->NotifyModuleRemoved(*this, module_sp);
299  return true;
300  }
301  }
302  }
303  return false;
304 }
305 
306 ModuleList::collection::iterator
307 ModuleList::RemoveImpl(ModuleList::collection::iterator pos,
308  bool use_notifier) {
309  ModuleSP module_sp(*pos);
310  collection::iterator retval = m_modules.erase(pos);
311  if (use_notifier && m_notifier)
312  m_notifier->NotifyModuleRemoved(*this, module_sp);
313  return retval;
314 }
315 
316 bool ModuleList::Remove(const ModuleSP &module_sp, bool notify) {
317  return RemoveImpl(module_sp, notify);
318 }
319 
320 bool ModuleList::ReplaceModule(const lldb::ModuleSP &old_module_sp,
321  const lldb::ModuleSP &new_module_sp) {
322  if (!RemoveImpl(old_module_sp, false))
323  return false;
324  AppendImpl(new_module_sp, false);
325  if (m_notifier)
326  m_notifier->NotifyModuleUpdated(*this, old_module_sp, new_module_sp);
327  return true;
328 }
329 
330 bool ModuleList::RemoveIfOrphaned(const Module *module_ptr) {
331  if (module_ptr) {
332  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
333  collection::iterator pos, end = m_modules.end();
334  for (pos = m_modules.begin(); pos != end; ++pos) {
335  if (pos->get() == module_ptr) {
336  if (pos->unique()) {
337  pos = RemoveImpl(pos);
338  return true;
339  } else
340  return false;
341  }
342  }
343  }
344  return false;
345 }
346 
347 size_t ModuleList::RemoveOrphans(bool mandatory) {
348  std::unique_lock<std::recursive_mutex> lock(m_modules_mutex, std::defer_lock);
349 
350  if (mandatory) {
351  lock.lock();
352  } else {
353  // Not mandatory, remove orphans if we can get the mutex
354  if (!lock.try_lock())
355  return 0;
356  }
357  size_t remove_count = 0;
358  // Modules might hold shared pointers to other modules, so removing one
359  // module might make other other modules orphans. Keep removing modules until
360  // there are no further modules that can be removed.
361  bool made_progress = true;
362  while (made_progress) {
363  // Keep track if we make progress this iteration.
364  made_progress = false;
365  collection::iterator pos = m_modules.begin();
366  while (pos != m_modules.end()) {
367  if (pos->unique()) {
368  pos = RemoveImpl(pos);
369  ++remove_count;
370  // We did make progress.
371  made_progress = true;
372  } else {
373  ++pos;
374  }
375  }
376  }
377  return remove_count;
378 }
379 
380 size_t ModuleList::Remove(ModuleList &module_list) {
381  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
382  size_t num_removed = 0;
383  collection::iterator pos, end = module_list.m_modules.end();
384  for (pos = module_list.m_modules.begin(); pos != end; ++pos) {
385  if (Remove(*pos, false /* notify */))
386  ++num_removed;
387  }
388  if (m_notifier)
389  m_notifier->NotifyModulesRemoved(module_list);
390  return num_removed;
391 }
392 
394 
396 
397 void ModuleList::ClearImpl(bool use_notifier) {
398  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
399  if (use_notifier && m_notifier)
401  m_modules.clear();
402 }
403 
405  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
406  if (idx < m_modules.size())
407  return m_modules[idx].get();
408  return nullptr;
409 }
410 
411 ModuleSP ModuleList::GetModuleAtIndex(size_t idx) const {
412  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
413  return GetModuleAtIndexUnlocked(idx);
414 }
415 
416 ModuleSP ModuleList::GetModuleAtIndexUnlocked(size_t idx) const {
417  ModuleSP module_sp;
418  if (idx < m_modules.size())
419  module_sp = m_modules[idx];
420  return module_sp;
421 }
422 
424  FunctionNameType name_type_mask,
425  const ModuleFunctionSearchOptions &options,
426  SymbolContextList &sc_list) const {
427  const size_t old_size = sc_list.GetSize();
428 
429  if (name_type_mask & eFunctionNameTypeAuto) {
430  Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
431 
432  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
433  for (const ModuleSP &module_sp : m_modules) {
434  module_sp->FindFunctions(lookup_info, CompilerDeclContext(), options,
435  sc_list);
436  }
437 
438  const size_t new_size = sc_list.GetSize();
439 
440  if (old_size < new_size)
441  lookup_info.Prune(sc_list, old_size);
442  } else {
443  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
444  for (const ModuleSP &module_sp : m_modules) {
445  module_sp->FindFunctions(name, CompilerDeclContext(), name_type_mask,
446  options, sc_list);
447  }
448  }
449 }
450 
452  lldb::FunctionNameType name_type_mask,
453  SymbolContextList &sc_list) {
454  const size_t old_size = sc_list.GetSize();
455 
456  if (name_type_mask & eFunctionNameTypeAuto) {
457  Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
458 
459  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
460  for (const ModuleSP &module_sp : m_modules) {
461  module_sp->FindFunctionSymbols(lookup_info.GetLookupName(),
462  lookup_info.GetNameTypeMask(), sc_list);
463  }
464 
465  const size_t new_size = sc_list.GetSize();
466 
467  if (old_size < new_size)
468  lookup_info.Prune(sc_list, old_size);
469  } else {
470  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
471  for (const ModuleSP &module_sp : m_modules) {
472  module_sp->FindFunctionSymbols(name, name_type_mask, sc_list);
473  }
474  }
475 }
476 
478  const ModuleFunctionSearchOptions &options,
479  SymbolContextList &sc_list) {
480  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
481  for (const ModuleSP &module_sp : m_modules)
482  module_sp->FindFunctions(name, options, sc_list);
483 }
484 
486  SymbolContextList &sc_list) const {
487  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
488  for (const ModuleSP &module_sp : m_modules)
489  module_sp->FindCompileUnits(path, sc_list);
490 }
491 
492 void ModuleList::FindGlobalVariables(ConstString name, size_t max_matches,
493  VariableList &variable_list) const {
494  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
495  for (const ModuleSP &module_sp : m_modules) {
496  module_sp->FindGlobalVariables(name, CompilerDeclContext(), max_matches,
497  variable_list);
498  }
499 }
500 
502  size_t max_matches,
503  VariableList &variable_list) const {
504  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
505  for (const ModuleSP &module_sp : m_modules)
506  module_sp->FindGlobalVariables(regex, max_matches, variable_list);
507 }
508 
510  SymbolType symbol_type,
511  SymbolContextList &sc_list) const {
512  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
513  for (const ModuleSP &module_sp : m_modules)
514  module_sp->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
515 }
516 
518  const RegularExpression &regex, lldb::SymbolType symbol_type,
519  SymbolContextList &sc_list) const {
520  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
521  for (const ModuleSP &module_sp : m_modules)
522  module_sp->FindSymbolsMatchingRegExAndType(regex, symbol_type, sc_list);
523 }
524 
525 void ModuleList::FindModules(const ModuleSpec &module_spec,
526  ModuleList &matching_module_list) const {
527  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
528  for (const ModuleSP &module_sp : m_modules) {
529  if (module_sp->MatchesModuleSpec(module_spec))
530  matching_module_list.Append(module_sp);
531  }
532 }
533 
534 ModuleSP ModuleList::FindModule(const Module *module_ptr) const {
535  ModuleSP module_sp;
536 
537  // Scope for "locker"
538  {
539  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
540  collection::const_iterator pos, end = m_modules.end();
541 
542  for (pos = m_modules.begin(); pos != end; ++pos) {
543  if ((*pos).get() == module_ptr) {
544  module_sp = (*pos);
545  break;
546  }
547  }
548  }
549  return module_sp;
550 }
551 
552 ModuleSP ModuleList::FindModule(const UUID &uuid) const {
553  ModuleSP module_sp;
554 
555  if (uuid.IsValid()) {
556  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
557  collection::const_iterator pos, end = m_modules.end();
558 
559  for (pos = m_modules.begin(); pos != end; ++pos) {
560  if ((*pos)->GetUUID() == uuid) {
561  module_sp = (*pos);
562  break;
563  }
564  }
565  }
566  return module_sp;
567 }
568 
569 void ModuleList::FindTypes(Module *search_first, ConstString name,
570  bool name_is_fully_qualified, size_t max_matches,
571  llvm::DenseSet<SymbolFile *> &searched_symbol_files,
572  TypeList &types) const {
573  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
574 
575  collection::const_iterator pos, end = m_modules.end();
576  if (search_first) {
577  for (pos = m_modules.begin(); pos != end; ++pos) {
578  if (search_first == pos->get()) {
579  search_first->FindTypes(name, name_is_fully_qualified, max_matches,
580  searched_symbol_files, types);
581 
582  if (types.GetSize() >= max_matches)
583  return;
584  }
585  }
586  }
587 
588  for (pos = m_modules.begin(); pos != end; ++pos) {
589  // Search the module if the module is not equal to the one in the symbol
590  // context "sc". If "sc" contains a empty module shared pointer, then the
591  // comparison will always be true (valid_module_ptr != nullptr).
592  if (search_first != pos->get())
593  (*pos)->FindTypes(name, name_is_fully_qualified, max_matches,
594  searched_symbol_files, types);
595 
596  if (types.GetSize() >= max_matches)
597  return;
598  }
599 }
600 
601 bool ModuleList::FindSourceFile(const FileSpec &orig_spec,
602  FileSpec &new_spec) const {
603  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
604  for (const ModuleSP &module_sp : m_modules) {
605  if (module_sp->FindSourceFile(orig_spec, new_spec))
606  return true;
607  }
608  return false;
609 }
610 
611 void ModuleList::FindAddressesForLine(const lldb::TargetSP target_sp,
612  const FileSpec &file, uint32_t line,
613  Function *function,
614  std::vector<Address> &output_local,
615  std::vector<Address> &output_extern) {
616  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
617  for (const ModuleSP &module_sp : m_modules) {
618  module_sp->FindAddressesForLine(target_sp, file, line, function,
619  output_local, output_extern);
620  }
621 }
622 
623 ModuleSP ModuleList::FindFirstModule(const ModuleSpec &module_spec) const {
624  ModuleSP module_sp;
625  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
626  collection::const_iterator pos, end = m_modules.end();
627  for (pos = m_modules.begin(); pos != end; ++pos) {
628  ModuleSP module_sp(*pos);
629  if (module_sp->MatchesModuleSpec(module_spec))
630  return module_sp;
631  }
632  return module_sp;
633 }
634 
635 size_t ModuleList::GetSize() const {
636  size_t size = 0;
637  {
638  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
639  size = m_modules.size();
640  }
641  return size;
642 }
643 
644 void ModuleList::Dump(Stream *s) const {
645  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
646  for (const ModuleSP &module_sp : m_modules)
647  module_sp->Dump(s);
648 }
649 
650 void ModuleList::LogUUIDAndPaths(Log *log, const char *prefix_cstr) {
651  if (log != nullptr) {
652  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
653  collection::const_iterator pos, begin = m_modules.begin(),
654  end = m_modules.end();
655  for (pos = begin; pos != end; ++pos) {
656  Module *module = pos->get();
657  const FileSpec &module_file_spec = module->GetFileSpec();
658  LLDB_LOGF(log, "%s[%u] %s (%s) \"%s\"", prefix_cstr ? prefix_cstr : "",
659  (uint32_t)std::distance(begin, pos),
660  module->GetUUID().GetAsString().c_str(),
662  module_file_spec.GetPath().c_str());
663  }
664  }
665 }
666 
668  Address &so_addr) const {
669  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
670  for (const ModuleSP &module_sp : m_modules) {
671  if (module_sp->ResolveFileAddress(vm_addr, so_addr))
672  return true;
673  }
674 
675  return false;
676 }
677 
678 uint32_t
680  SymbolContextItem resolve_scope,
681  SymbolContext &sc) const {
682  // The address is already section offset so it has a module
683  uint32_t resolved_flags = 0;
684  ModuleSP module_sp(so_addr.GetModule());
685  if (module_sp) {
686  resolved_flags =
687  module_sp->ResolveSymbolContextForAddress(so_addr, resolve_scope, sc);
688  } else {
689  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
690  collection::const_iterator pos, end = m_modules.end();
691  for (pos = m_modules.begin(); pos != end; ++pos) {
692  resolved_flags =
693  (*pos)->ResolveSymbolContextForAddress(so_addr, resolve_scope, sc);
694  if (resolved_flags != 0)
695  break;
696  }
697  }
698 
699  return resolved_flags;
700 }
701 
703  const char *file_path, uint32_t line, bool check_inlines,
704  SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
705  FileSpec file_spec(file_path);
706  return ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
707  resolve_scope, sc_list);
708 }
709 
711  const FileSpec &file_spec, uint32_t line, bool check_inlines,
712  SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
713  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
714  for (const ModuleSP &module_sp : m_modules) {
715  module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
716  resolve_scope, sc_list);
717  }
718 
719  return sc_list.GetSize();
720 }
721 
722 size_t ModuleList::GetIndexForModule(const Module *module) const {
723  if (module) {
724  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
725  collection::const_iterator pos;
726  collection::const_iterator begin = m_modules.begin();
727  collection::const_iterator end = m_modules.end();
728  for (pos = begin; pos != end; ++pos) {
729  if ((*pos).get() == module)
730  return std::distance(begin, pos);
731  }
732  }
733  return LLDB_INVALID_INDEX32;
734 }
735 
736 namespace {
737 struct SharedModuleListInfo {
738  ModuleList module_list;
739  ModuleListProperties module_list_properties;
740 };
741 }
742 static SharedModuleListInfo &GetSharedModuleListInfo()
743 {
744  static SharedModuleListInfo *g_shared_module_list_info = nullptr;
745  static llvm::once_flag g_once_flag;
746  llvm::call_once(g_once_flag, []() {
747  // NOTE: Intentionally leak the module list so a program doesn't have to
748  // cleanup all modules and object files as it exits. This just wastes time
749  // doing a bunch of cleanup that isn't required.
750  if (g_shared_module_list_info == nullptr)
751  g_shared_module_list_info = new SharedModuleListInfo();
752  });
753  return *g_shared_module_list_info;
754 }
755 
757  return GetSharedModuleListInfo().module_list;
758 }
759 
761  return GetSharedModuleListInfo().module_list_properties;
762 }
763 
764 bool ModuleList::ModuleIsInCache(const Module *module_ptr) {
765  if (module_ptr) {
766  ModuleList &shared_module_list = GetSharedModuleList();
767  return shared_module_list.FindModule(module_ptr).get() != nullptr;
768  }
769  return false;
770 }
771 
773  ModuleList &matching_module_list) {
774  GetSharedModuleList().FindModules(module_spec, matching_module_list);
775 }
776 
777 lldb::ModuleSP ModuleList::FindSharedModule(const UUID &uuid) {
778  return GetSharedModuleList().FindModule(uuid);
779 }
780 
782  return GetSharedModuleList().RemoveOrphans(mandatory);
783 }
784 
785 Status
786 ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
787  const FileSpecList *module_search_paths_ptr,
789  bool *did_create_ptr, bool always_create) {
790  ModuleList &shared_module_list = GetSharedModuleList();
791  std::lock_guard<std::recursive_mutex> guard(
792  shared_module_list.m_modules_mutex);
793  char path[PATH_MAX];
794 
795  Status error;
796 
797  module_sp.reset();
798 
799  if (did_create_ptr)
800  *did_create_ptr = false;
801 
802  const UUID *uuid_ptr = module_spec.GetUUIDPtr();
803  const FileSpec &module_file_spec = module_spec.GetFileSpec();
804  const ArchSpec &arch = module_spec.GetArchitecture();
805 
806  // Make sure no one else can try and get or create a module while this
807  // function is actively working on it by doing an extra lock on the global
808  // mutex list.
809  if (!always_create) {
810  ModuleList matching_module_list;
811  shared_module_list.FindModules(module_spec, matching_module_list);
812  const size_t num_matching_modules = matching_module_list.GetSize();
813 
814  if (num_matching_modules > 0) {
815  for (size_t module_idx = 0; module_idx < num_matching_modules;
816  ++module_idx) {
817  module_sp = matching_module_list.GetModuleAtIndex(module_idx);
818 
819  // Make sure the file for the module hasn't been modified
820  if (module_sp->FileHasChanged()) {
821  if (old_modules)
822  old_modules->push_back(module_sp);
823 
824  Log *log = GetLog(LLDBLog::Modules);
825  if (log != nullptr)
826  LLDB_LOGF(
827  log, "%p '%s' module changed: removing from global module list",
828  static_cast<void *>(module_sp.get()),
829  module_sp->GetFileSpec().GetFilename().GetCString());
830 
831  shared_module_list.Remove(module_sp);
832  module_sp.reset();
833  } else {
834  // The module matches and the module was not modified from when it
835  // was last loaded.
836  return error;
837  }
838  }
839  }
840  }
841 
842  if (module_sp)
843  return error;
844 
845  module_sp = std::make_shared<Module>(module_spec);
846  // Make sure there are a module and an object file since we can specify a
847  // valid file path with an architecture that might not be in that file. By
848  // getting the object file we can guarantee that the architecture matches
849  if (module_sp->GetObjectFile()) {
850  // If we get in here we got the correct arch, now we just need to verify
851  // the UUID if one was given
852  if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) {
853  module_sp.reset();
854  } else {
855  if (module_sp->GetObjectFile() &&
856  module_sp->GetObjectFile()->GetType() ==
858  module_sp.reset();
859  } else {
860  if (did_create_ptr) {
861  *did_create_ptr = true;
862  }
863 
864  shared_module_list.ReplaceEquivalent(module_sp, old_modules);
865  return error;
866  }
867  }
868  } else {
869  module_sp.reset();
870  }
871 
872  if (module_search_paths_ptr) {
873  const auto num_directories = module_search_paths_ptr->GetSize();
874  for (size_t idx = 0; idx < num_directories; ++idx) {
875  auto search_path_spec = module_search_paths_ptr->GetFileSpecAtIndex(idx);
876  FileSystem::Instance().Resolve(search_path_spec);
877  namespace fs = llvm::sys::fs;
878  if (!FileSystem::Instance().IsDirectory(search_path_spec))
879  continue;
880  search_path_spec.AppendPathComponent(
881  module_spec.GetFileSpec().GetFilename().GetStringRef());
882  if (!FileSystem::Instance().Exists(search_path_spec))
883  continue;
884 
885  auto resolved_module_spec(module_spec);
886  resolved_module_spec.GetFileSpec() = search_path_spec;
887  module_sp = std::make_shared<Module>(resolved_module_spec);
888  if (module_sp->GetObjectFile()) {
889  // If we get in here we got the correct arch, now we just need to
890  // verify the UUID if one was given
891  if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) {
892  module_sp.reset();
893  } else {
894  if (module_sp->GetObjectFile()->GetType() ==
896  module_sp.reset();
897  } else {
898  if (did_create_ptr)
899  *did_create_ptr = true;
900 
901  shared_module_list.ReplaceEquivalent(module_sp, old_modules);
902  return Status();
903  }
904  }
905  } else {
906  module_sp.reset();
907  }
908  }
909  }
910 
911  // Either the file didn't exist where at the path, or no path was given, so
912  // we now have to use more extreme measures to try and find the appropriate
913  // module.
914 
915  // Fixup the incoming path in case the path points to a valid file, yet the
916  // arch or UUID (if one was passed in) don't match.
917  ModuleSpec located_binary_modulespec =
919 
920  // Don't look for the file if it appears to be the same one we already
921  // checked for above...
922  if (located_binary_modulespec.GetFileSpec() != module_file_spec) {
923  if (!FileSystem::Instance().Exists(
924  located_binary_modulespec.GetFileSpec())) {
925  located_binary_modulespec.GetFileSpec().GetPath(path, sizeof(path));
926  if (path[0] == '\0')
927  module_file_spec.GetPath(path, sizeof(path));
928  // How can this check ever be true? This branch it is false, and we
929  // haven't modified file_spec.
930  if (FileSystem::Instance().Exists(
931  located_binary_modulespec.GetFileSpec())) {
932  std::string uuid_str;
933  if (uuid_ptr && uuid_ptr->IsValid())
934  uuid_str = uuid_ptr->GetAsString();
935 
936  if (arch.IsValid()) {
937  if (!uuid_str.empty())
938  error.SetErrorStringWithFormat(
939  "'%s' does not contain the %s architecture and UUID %s", path,
940  arch.GetArchitectureName(), uuid_str.c_str());
941  else
942  error.SetErrorStringWithFormat(
943  "'%s' does not contain the %s architecture.", path,
944  arch.GetArchitectureName());
945  }
946  } else {
947  error.SetErrorStringWithFormat("'%s' does not exist", path);
948  }
949  if (error.Fail())
950  module_sp.reset();
951  return error;
952  }
953 
954  // Make sure no one else can try and get or create a module while this
955  // function is actively working on it by doing an extra lock on the global
956  // mutex list.
957  ModuleSpec platform_module_spec(module_spec);
958  platform_module_spec.GetFileSpec() =
959  located_binary_modulespec.GetFileSpec();
960  platform_module_spec.GetPlatformFileSpec() =
961  located_binary_modulespec.GetFileSpec();
962  platform_module_spec.GetSymbolFileSpec() =
963  located_binary_modulespec.GetSymbolFileSpec();
964  ModuleList matching_module_list;
965  shared_module_list.FindModules(platform_module_spec, matching_module_list);
966  if (!matching_module_list.IsEmpty()) {
967  module_sp = matching_module_list.GetModuleAtIndex(0);
968 
969  // If we didn't have a UUID in mind when looking for the object file,
970  // then we should make sure the modification time hasn't changed!
971  if (platform_module_spec.GetUUIDPtr() == nullptr) {
972  auto file_spec_mod_time = FileSystem::Instance().GetModificationTime(
973  located_binary_modulespec.GetFileSpec());
974  if (file_spec_mod_time != llvm::sys::TimePoint<>()) {
975  if (file_spec_mod_time != module_sp->GetModificationTime()) {
976  if (old_modules)
977  old_modules->push_back(module_sp);
978  shared_module_list.Remove(module_sp);
979  module_sp.reset();
980  }
981  }
982  }
983  }
984 
985  if (!module_sp) {
986  module_sp = std::make_shared<Module>(platform_module_spec);
987  // Make sure there are a module and an object file since we can specify a
988  // valid file path with an architecture that might not be in that file.
989  // By getting the object file we can guarantee that the architecture
990  // matches
991  if (module_sp && module_sp->GetObjectFile()) {
992  if (module_sp->GetObjectFile()->GetType() ==
994  module_sp.reset();
995  } else {
996  if (did_create_ptr)
997  *did_create_ptr = true;
998 
999  shared_module_list.ReplaceEquivalent(module_sp, old_modules);
1000  }
1001  } else {
1002  located_binary_modulespec.GetFileSpec().GetPath(path, sizeof(path));
1003 
1004  if (located_binary_modulespec.GetFileSpec()) {
1005  if (arch.IsValid())
1006  error.SetErrorStringWithFormat(
1007  "unable to open %s architecture in '%s'",
1008  arch.GetArchitectureName(), path);
1009  else
1010  error.SetErrorStringWithFormat("unable to open '%s'", path);
1011  } else {
1012  std::string uuid_str;
1013  if (uuid_ptr && uuid_ptr->IsValid())
1014  uuid_str = uuid_ptr->GetAsString();
1015 
1016  if (!uuid_str.empty())
1017  error.SetErrorStringWithFormat(
1018  "cannot locate a module for UUID '%s'", uuid_str.c_str());
1019  else
1020  error.SetErrorString("cannot locate a module");
1021  }
1022  }
1023  }
1024  }
1025 
1026  return error;
1027 }
1028 
1029 bool ModuleList::RemoveSharedModule(lldb::ModuleSP &module_sp) {
1030  return GetSharedModuleList().Remove(module_sp);
1031 }
1032 
1034  return GetSharedModuleList().RemoveIfOrphaned(module_ptr);
1035 }
1036 
1038  std::list<Status> &errors,
1039  Stream *feedback_stream,
1040  bool continue_on_error) {
1041  if (!target)
1042  return false;
1043  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
1044  for (auto module : m_modules) {
1045  Status error;
1046  if (module) {
1047  if (!module->LoadScriptingResourceInTarget(target, error,
1048  feedback_stream)) {
1049  if (error.Fail() && error.AsCString()) {
1050  error.SetErrorStringWithFormat("unable to load scripting data for "
1051  "module %s - error reported was %s",
1052  module->GetFileSpec()
1053  .GetFileNameStrippingExtension()
1054  .GetCString(),
1055  error.AsCString());
1056  errors.push_back(error);
1057 
1058  if (!continue_on_error)
1059  return false;
1060  }
1061  }
1062  }
1063  }
1064  return errors.empty();
1065 }
1066 
1068  std::function<bool(const ModuleSP &module_sp)> const &callback) const {
1069  std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
1070  for (const auto &module : m_modules) {
1071  // If the callback returns false, then stop iterating and break out
1072  if (!callback(module))
1073  break;
1074  }
1075 }
list
MATCHES FreeBSD list(APPEND FBSDKERNEL_LIBS kvm) endif() if(NOT FBSDKERNEL_LIBS) message(STATUS "Skipping FreeBSDKernel plugin due to missing libfbsdvmcore") return() endif() add_lldb_library(lldbPluginProcessFreeBSDKernel PLUGIN ProcessFreeBSDKernel.cpp RegisterContextFreeBSDKernel_arm64.cpp RegisterContextFreeBSDKernel_i386.cpp RegisterContextFreeBSDKernel_x86_64.cpp ThreadFreeBSDKernel.cpp LINK_LIBS lldbCore lldbTarget $
Definition: Plugins/Process/FreeBSDKernel/CMakeLists.txt:6
lldb_private::ModuleList::LoadScriptingResourcesInTarget
bool LoadScriptingResourcesInTarget(Target *target, std::list< Status > &errors, Stream *feedback_stream=nullptr, bool continue_on_error=true)
Definition: ModuleList.cpp:1037
lldb_private::UUID
Definition: UUID.h:23
lldb_private::SymbolFile
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:46
lldb_private::ModuleList::GetGlobalModuleListProperties
static ModuleListProperties & GetGlobalModuleListProperties()
Definition: ModuleList.cpp:760
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb_private::RegularExpression
Definition: RegularExpression.h:18
lldb_private::ModuleSpec::GetPlatformFileSpec
FileSpec & GetPlatformFileSpec()
Definition: ModuleSpec.h:65
FileSystem.h
lldb_private::ModuleSpec::GetUUIDPtr
UUID * GetUUIDPtr()
Definition: ModuleSpec.h:93
lldb_private::ModuleList::RemoveOrphans
size_t RemoveOrphans(bool mandatory)
Definition: ModuleList.cpp:347
ModuleSpec.h
lldb_private::ModuleList::FindSharedModule
static lldb::ModuleSP FindSharedModule(const UUID &uuid)
Definition: ModuleList.cpp:777
UUID.h
lldb-defines.h
lldb_private::ModuleList::m_notifier
Notifier * m_notifier
Definition: ModuleList.h:488
lldb_private::ModuleList::GetIndexForModule
size_t GetIndexForModule(const Module *module) const
Definition: ModuleList.cpp:722
lldb_private::ModuleList::GetModuleAtIndexUnlocked
lldb::ModuleSP GetModuleAtIndexUnlocked(size_t idx) const
Get the module shared pointer for the module at index idx without acquiring the ModuleList mutex.
Definition: ModuleList.cpp:416
lldb_private::UUID::IsValid
bool IsValid() const
Definition: UUID.h:69
lldb_private::ModuleList::GetModulePointerAtIndex
Module * GetModulePointerAtIndex(size_t idx) const
Get the module pointer for the module at index idx.
Definition: ModuleList.cpp:404
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:344
Module.h
lldb_private::ModuleList::FindSharedModules
static void FindSharedModules(const ModuleSpec &module_spec, ModuleList &matching_module_list)
Definition: ModuleList.cpp:772
lldb_private::SymbolContextList
Definition: SymbolContext.h:379
lldb_private::Module
Definition: Module.h:85
lldb_private::FileSpec::GetFilename
const ConstString & GetFilename() const
Filename string const get accessor.
Definition: FileSpec.h:239
LocateSymbolFile.h
lldb_private::ModuleList::ResolveSymbolContextsForFileSpec
uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) const
Resolve items in the symbol context for a given file and line. (const FileSpec
Definition: ModuleList.cpp:710
lldb_private::Stream
Definition: Stream.h:28
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:469
lldb_private::LLDBLog::Modules
@ Modules
lldb_private::ModuleList::Clear
void Clear()
Clear the object's state.
Definition: ModuleList.cpp:393
lldb_private::UUID::GetAsString
std::string GetAsString(llvm::StringRef separator="-") const
Definition: UUID.cpp:49
lldb_private::VariableList
Definition: VariableList.h:18
lldb_private::ModuleList::FindGlobalVariables
void FindGlobalVariables(ConstString name, size_t max_matches, VariableList &variable_list) const
Find global and static variables by name.
Definition: ModuleList.cpp:492
lldb_private::ModuleSpec::GetSymbolFileSpec
FileSpec & GetSymbolFileSpec()
Definition: ModuleSpec.h:77
lldb_private::ModuleList::RemoveSharedModuleIfOrphaned
static bool RemoveSharedModuleIfOrphaned(const Module *module_ptr)
Definition: ModuleList.cpp:1033
lldb_private::ModuleList::FindSymbolsWithNameAndType
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
Definition: ModuleList.cpp:509
lldb_private::ModuleList::~ModuleList
~ModuleList()
Destructor.
lldb_private::Symbols::LocateExecutableObjectFile
static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec)
Definition: LocateSymbolFile.cpp:237
lldb_private::Module::GetFileSpec
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition: Module.h:496
lldb_private::Module::LookupInfo
Definition: Module.h:931
lldb_private::FileSpec
Definition: FileSpec.h:55
lldb_private::ModuleList::FindSymbolsMatchingRegExAndType
void FindSymbolsMatchingRegExAndType(const RegularExpression &regex, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
Definition: ModuleList.cpp:517
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::Status::Success
bool Success() const
Test for success condition.
Definition: Status.cpp:287
lldb_private::ModuleListProperties
Definition: ModuleList.h:50
lldb_private::ModuleList::GetSize
size_t GetSize() const
Gets the size of the module list.
Definition: ModuleList.cpp:635
lldb_private::Function
Definition: Function.h:409
ModuleList.h
lldb_private::ModuleList::Remove
bool Remove(const lldb::ModuleSP &module_sp, bool notify=true)
Remove a module from the module list.
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:201
lldb_private::ModuleList
Definition: ModuleList.h:82
lldb_private::ModuleList::operator=
const ModuleList & operator=(const ModuleList &rhs)
Assignment operator.
Definition: ModuleList.cpp:206
Log.h
lldb_private::ModuleList::ResolveSymbolContextForFilePath
uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) const
Resolve items in the symbol context for a given file and line. (const char
Definition: ModuleList.cpp:702
lldb_private::ModuleList::ModuleIsInCache
static bool ModuleIsInCache(const Module *module_ptr)
Definition: ModuleList.cpp:764
lldb_private::TypeList::GetSize
uint32_t GetSize() const
Definition: TypeList.cpp:60
lldb_private::SymbolContextList::GetSize
uint32_t GetSize() const
Get accessor for a symbol context list size.
Definition: SymbolContext.cpp:1274
Property.h
FileSpecList.h
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::ModuleList::FindFirstModule
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Definition: ModuleList.cpp:623
lldb_private::ModuleList::RemoveOrphanSharedModules
static size_t RemoveOrphanSharedModules(bool mandatory)
Definition: ModuleList.cpp:781
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:96
lldb_private::ModuleList::ReplaceModule
bool ReplaceModule(const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp)
Definition: ModuleList.cpp:320
lldb_private::ModuleList::ForEach
void ForEach(std::function< bool(const lldb::ModuleSP &module_sp)> const &callback) const
Definition: ModuleList.cpp:1067
lldb_private::ModuleList::ResolveFileAddress
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr) const
Definition: ModuleList.cpp:667
lldb_private::ModuleList::RemoveImpl
bool RemoveImpl(const lldb::ModuleSP &module_sp, bool use_notifier=true)
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::FileSystem::Resolve
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
Definition: common/FileSystem.cpp:235
lldb_private::ArchSpec::IsValid
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:352
lldb_private::ModuleList::ResolveSymbolContextForAddress
uint32_t ResolveSymbolContextForAddress(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc) const
Resolve the symbol context for the given address. (const Address
Definition: ModuleList.cpp:679
lldb::SymbolType
SymbolType
Symbol types.
Definition: lldb-enumerations.h:618
VariableList.h
lldb_private::ModuleList::RemoveIfOrphaned
bool RemoveIfOrphaned(const Module *module_ptr)
Definition: ModuleList.cpp:330
lldb_private::CompilerDeclContext
Represents a generic declaration context in a program.
Definition: CompilerDeclContext.h:30
OptionValueProperties.h
ObjectFile.h
lldb_private::ModuleFunctionSearchOptions
Options used by Module::FindFunctions.
Definition: Module.h:63
lldb_private::ModuleList::m_modules_mutex
std::recursive_mutex m_modules_mutex
Definition: ModuleList.h:486
lldb_private::ModuleList::ModuleList
ModuleList()
Default constructor.
Definition: ModuleList.cpp:195
lldb_private::ModuleList::RemoveSharedModule
static bool RemoveSharedModule(lldb::ModuleSP &module_sp)
Definition: ModuleList.cpp:1029
TypeList.h
lldb_private::ModuleList::FindModule
lldb::ModuleSP FindModule(const Module *module_ptr) const
Definition: ModuleList.cpp:534
lldb_private::ModuleList::FindCompileUnits
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list) const
Find compile units by partial or full path.
Definition: ModuleList.cpp:485
lldbassert
#define lldbassert(x)
Definition: LLDBAssert.h:15
lldb_private::ModuleList::Notifier::NotifyModuleAdded
virtual void NotifyModuleAdded(const ModuleList &module_list, const lldb::ModuleSP &module_sp)=0
lldb_private::ModuleSpec::GetFileSpec
FileSpec & GetFileSpec()
Definition: ModuleSpec.h:53
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
PosixApi.h
lldb_private::Status
Definition: Status.h:44
lldb_private::Module::LookupInfo::GetLookupName
ConstString GetLookupName() const
Definition: Module.h:942
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:535
lldb_private::ModuleList::m_modules
collection m_modules
The collection of modules.
Definition: ModuleList.h:485
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
uint32_t
lldb_private::PathMappingList
Definition: PathMappingList.h:20
lldb_private::Address
Definition: Address.h:59
lldb_private::Module::LookupInfo::GetNameTypeMask
lldb::FunctionNameType GetNameTypeMask() const
Definition: Module.h:946
lldb_private::ObjectFile::eTypeStubLibrary
@ eTypeStubLibrary
A library that can be linked against but not used for execution.
Definition: ObjectFile.h:81
lldb_private::ModuleList::AppendIfNeeded
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
lldb_private::ModuleList::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: ModuleList.cpp:611
ArchSpec.h
lldb_private::ModuleList::AppendImpl
void AppendImpl(const lldb::ModuleSP &module_sp, bool use_notifier=true)
Definition: ModuleList.cpp:220
lldb_private::ModuleSpec::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:89
lldb_private::ModuleList::LogUUIDAndPaths
void LogUUIDAndPaths(Log *log, const char *prefix_cstr)
Definition: ModuleList.cpp:650
lldb_private::ModuleList::FindFunctions
void FindFunctions(ConstString name, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list) const
lldb_private::FileSystem::Instance
static FileSystem & Instance()
Definition: common/FileSystem.cpp:46
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:987
SymbolContext.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::ModuleList::Destroy
void Destroy()
Clear the object's state.
Definition: ModuleList.cpp:395
lldb_private::ModuleList::Notifier::NotifyModuleRemoved
virtual void NotifyModuleRemoved(const ModuleList &module_list, const lldb::ModuleSP &module_sp)=0
lldb_private::ModuleList::Dump
void Dump(Stream *s) const
Dump the description of each module contained in this list.
Definition: ModuleList.cpp:644
lldb_private::TypeList
Definition: TypeList.h:20
lldb_private::ModuleList::GetModuleAtIndex
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
Definition: ModuleList.cpp:411
lldb_private::ModuleList::FindModules
void FindModules(const ModuleSpec &module_spec, ModuleList &matching_module_list) const
Finds the first module whose file specification matches file_spec.
Definition: ModuleList.cpp:525
ConstString.h
GetSharedModuleList
static ModuleList & GetSharedModuleList()
Definition: ModuleList.cpp:756
OptionValueFileSpecList.h
lldb_private::ModuleList::FindFunctionSymbols
void FindFunctionSymbols(ConstString name, lldb::FunctionNameType name_type_mask, SymbolContextList &sc_list)
Definition: ModuleList.cpp:451
LLDB_INVALID_INDEX32
#define LLDB_INVALID_INDEX32
Definition: lldb-defines.h:75
lldb_private::Address::GetModule
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
Definition: Address.cpp:283
lldb_private::Module::LookupInfo::Prune
void Prune(SymbolContextList &sc_list, size_t start_idx) const
Definition: Module.cpp:766
lldb_private::Log
Definition: Log.h:115
lldb_private::ModuleList::FindTypes
void FindTypes(Module *search_first, ConstString name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet< SymbolFile * > &searched_symbol_files, TypeList &types) const
Find types by name.
Definition: ModuleList.cpp:569
lldb_private::ModuleList::Notifier::NotifyWillClearList
virtual void NotifyWillClearList(const ModuleList &module_list)=0
lldb_private::Module::GetArchitecture
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
Definition: Module.cpp:1079
lldb_private::Module::GetUUID
const lldb_private::UUID & GetUUID()
Get a reference to the UUID value contained in this object.
Definition: Module.cpp:342
llvm::SmallVectorImpl
Definition: Disassembler.h:42
PATH_MAX
#define PATH_MAX
Definition: windows/PosixApi.h:25
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb_private::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:364
lldb_private::ModuleList::ReplaceEquivalent
void ReplaceEquivalent(const lldb::ModuleSP &module_sp, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules=nullptr)
Append a module to the module list and remove any equivalent modules.
Definition: ModuleList.cpp:233
lldb_private::ModuleList::Notifier::NotifyModuleUpdated
virtual void NotifyModuleUpdated(const ModuleList &module_list, const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp)=0
OptionValueFileSpec.h
lldb_private::ModuleList::ClearImpl
void ClearImpl(bool use_notifier=true)
Definition: ModuleList.cpp:397
lldb
Definition: SBAddress.h:15
lldb_private::ModuleList::GetSharedModule
static Status GetSharedModule(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr, bool always_create=false)
Definition: ModuleList.cpp:786
lldb_private::ModuleList::IsEmpty
bool IsEmpty() const
Definition: ModuleList.h:440
LLDBLog.h
GetSharedModuleListInfo
static SharedModuleListInfo & GetSharedModuleListInfo()
Definition: ModuleList.cpp:742
lldb_private::ModuleList::Append
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
lldb_private::ModuleList::Notifier
Definition: ModuleList.h:84
lldb_private::ModuleList::Notifier::NotifyModulesRemoved
virtual void NotifyModulesRemoved(lldb_private::ModuleList &module_list)=0
lldb_private::ModuleList::FindSourceFile
bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const
Definition: ModuleList.cpp:601