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