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
10#include "lldb/Core/Debugger.h"
11#include "lldb/Core/Module.h"
24#include "lldb/Target/Target.h"
29#include "lldb/Utility/Log.h"
30#include "lldb/Utility/UUID.h"
31#include "lldb/lldb-defines.h"
32#include "llvm/Support/ThreadPool.h"
33
34#if defined(_WIN32)
36#endif
37
38#include "llvm/ADT/StringRef.h"
39#include "llvm/Support/FileSystem.h"
40#include "llvm/Support/Threading.h"
41#include "llvm/Support/raw_ostream.h"
42
43#include <chrono>
44#include <memory>
45#include <mutex>
46#include <string>
47#include <utility>
48
49namespace lldb_private {
50class Function;
51}
52namespace lldb_private {
54}
55namespace lldb_private {
56class Stream;
57}
58namespace lldb_private {
59class SymbolFile;
60}
61namespace lldb_private {
62class Target;
63}
64
65using namespace lldb;
66using namespace lldb_private;
67
68namespace {
69
70#define LLDB_PROPERTIES_modulelist
71#include "CoreProperties.inc"
72
73enum {
74#define LLDB_PROPERTIES_modulelist
75#include "CorePropertiesEnum.inc"
76};
77
78#define LLDB_PROPERTIES_modulelist_index_cache
79#include "CoreProperties.inc"
80
81enum {
82#define LLDB_PROPERTIES_modulelist_index_cache
83#include "CorePropertiesEnum.inc"
84};
85
86#define LLDB_PROPERTIES_modulelist_index_cache_type
87#include "CoreProperties.inc"
88
89enum {
90#define LLDB_PROPERTIES_modulelist_index_cache_type
91#include "CorePropertiesEnum.inc"
92};
93
94#define LLDB_PROPERTIES_modulelist_experimental
95#include "CoreProperties.inc"
96
97enum {
98#define LLDB_PROPERTIES_modulelist_experimental
99#include "CorePropertiesEnum.inc"
100};
101
102/// Set the settings at \a replacement_idxs in \a replacements to the value of
103/// the deprecated setting at \a deprecated_idx in \a deprecated. If the
104/// deprecated setting was cleared, clear its replacements too.
105template <typename T>
106void ForwardDeprecatedSetting(const OptionValueProperties &deprecated,
107 uint32_t deprecated_idx,
108 const OptionValueProperties &replacements,
109 llvm::ArrayRef<uint32_t> replacement_idxs) {
110 OptionValueSP deprecated_sp =
111 deprecated.GetPropertyValueAtIndex(deprecated_idx, nullptr);
112 if (!deprecated_sp)
113 return;
114 std::optional<T> value;
115 if (deprecated_sp->OptionWasSet())
116 value = deprecated_sp->GetValueAs<T>();
117 for (uint32_t idx : replacement_idxs) {
118 OptionValueSP replacement_sp =
119 replacements.GetPropertyValueAtIndex(idx, nullptr);
120 if (!replacement_sp)
121 continue;
122 if (value) {
123 replacement_sp->SetValueAs(*value);
124 replacement_sp->SetOptionWasSet();
125 } else {
126 replacement_sp->Clear();
127 }
128 }
129}
130
131} // namespace
132
134 m_collection_sp = std::make_shared<OptionValueProperties>("symbols");
135 m_collection_sp->Initialize(g_modulelist_properties_def);
136 m_collection_sp->SetValueChangedCallback(ePropertySymLinkPaths,
137 [this] { UpdateSymlinkMappings(); });
138
140 std::make_shared<OptionValueProperties>("lldb-index-cache");
141 m_index_cache_sp->Initialize(g_modulelist_index_cache_properties_def);
142 m_collection_sp->AppendProperty(
143 "lldb-index-cache",
144 "Settings for caching data from modules on disk, for improved "
145 "performance in subsequent debug sessions.",
146 /*is_global=*/true, m_index_cache_sp);
147
148 m_index_cache_type_sp = std::make_shared<OptionValueProperties>("type");
149 m_index_cache_type_sp->Initialize(
150 g_modulelist_index_cache_type_properties_def);
151 m_index_cache_sp->AppendProperty("type",
152 "Settings for which kinds of data from "
153 "modules are cached on disk.",
154 /*is_global=*/true, m_index_cache_type_sp);
155
157
158 m_experimental_properties_sp = std::make_shared<OptionValueProperties>(
161 g_modulelist_experimental_properties_def);
162 m_collection_sp->AppendProperty(
164 "Experimental settings - setting these won't produce "
165 "errors if the setting is not present.",
167
168 // Make the platform's cache directory the default, so that clearing the
169 // setting goes back to it.
170 llvm::SmallString<128> path;
171 if (llvm::sys::path::cache_directory(path)) {
172 llvm::sys::path::append(path, "lldb");
173 llvm::sys::path::append(path, "IndexCache");
174 OptionValueFileSpec *path_value =
175 m_index_cache_sp->GetPropertyAtIndexAsOptionValueFileSpec(
176 ePropertyIndexCachePath);
177 lldbassert(path_value);
178 if (path_value) {
179 path_value->SetDefaultValue(FileSpec(path));
180 path_value->SetCurrentValue(FileSpec(path), /*set_value_was_set=*/false);
181 }
182 }
183}
184
186 m_collection_sp->SetValueChangedCallback(
187 ePropertyEnableLLDBIndexCache, [this] {
188 ForwardDeprecatedSetting<bool>(
189 *m_collection_sp, ePropertyEnableLLDBIndexCache,
191 {ePropertyIndexCacheTypeSymtab, ePropertyIndexCacheTypeDwarfIndex});
192 });
193 m_collection_sp->SetValueChangedCallback(
194 ePropertyEnableLLDBIndexCacheMemoryModules, [this] {
195 ForwardDeprecatedSetting<bool>(
196 *m_collection_sp, ePropertyEnableLLDBIndexCacheMemoryModules,
198 {ePropertyIndexCacheTypeMemoryModuleSymtab});
199 });
200 m_collection_sp->SetValueChangedCallback(ePropertyLLDBIndexCachePath, [this] {
201 ForwardDeprecatedSetting<FileSpec>(
202 *m_collection_sp, ePropertyLLDBIndexCachePath, *m_index_cache_sp,
203 {ePropertyIndexCachePath});
204 });
205 m_collection_sp->SetValueChangedCallback(
206 ePropertyLLDBIndexCacheMaxByteSize, [this] {
207 ForwardDeprecatedSetting<uint64_t>(
208 *m_collection_sp, ePropertyLLDBIndexCacheMaxByteSize,
209 *m_index_cache_sp, {ePropertyIndexCacheMaxByteSize});
210 });
211 m_collection_sp->SetValueChangedCallback(
212 ePropertyLLDBIndexCacheMaxPercent, [this] {
213 ForwardDeprecatedSetting<uint64_t>(
214 *m_collection_sp, ePropertyLLDBIndexCacheMaxPercent,
215 *m_index_cache_sp, {ePropertyIndexCacheMaxPercent});
216 });
217 m_collection_sp->SetValueChangedCallback(
218 ePropertyLLDBIndexCacheExpirationDays, [this] {
219 ForwardDeprecatedSetting<uint64_t>(
220 *m_collection_sp, ePropertyLLDBIndexCacheExpirationDays,
221 *m_index_cache_sp, {ePropertyIndexCacheExpirationDays});
222 });
223}
224
226 const uint32_t idx = ePropertyEnableExternalLookup;
228 idx, g_modulelist_properties[idx].default_uint_value != 0);
229}
230
232 return SetPropertyAtIndex(ePropertyEnableExternalLookup, new_value);
233}
234
236 const uint32_t idx = ePropertyEnableTypeSystemClike;
237 return m_experimental_properties_sp->GetPropertyAtIndexAs<bool>(idx).value_or(
238 g_modulelist_experimental_properties[idx].default_uint_value != 0);
239}
240
242 return m_experimental_properties_sp->SetPropertyAtIndex(
243 ePropertyEnableTypeSystemClike, new_value);
244}
245
247 // Backward compatibility alias.
248 if (GetPropertyAtIndexAs<bool>(ePropertyEnableBackgroundLookup, false))
250
251 const uint32_t idx = ePropertyAutoDownload;
253 idx, static_cast<lldb::SymbolDownload>(
254 g_modulelist_properties[idx].default_uint_value));
255}
256
258 const uint32_t idx = ePropertySharedCacheBinaryLoading;
260 idx, static_cast<lldb::SymbolSharedCacheUse>(
261 g_modulelist_properties[idx].default_uint_value));
262}
263
265 const uint32_t idx = ePropertyClangModulesCachePath;
266 return GetPropertyAtIndexAs<FileSpec>(idx, {});
267}
268
270 const uint32_t idx = ePropertyClangModulesCachePath;
271 return SetPropertyAtIndex(idx, path);
272}
273
275 return m_index_cache_sp
276 ->GetPropertyAtIndexAs<FileSpec>(ePropertyIndexCachePath)
277 .value_or(FileSpec());
278}
279
281 const uint32_t idx = ePropertyIndexCacheForceDisable;
282 return m_index_cache_sp->GetPropertyAtIndexAs<bool>(idx).value_or(
283 g_modulelist_index_cache_properties[idx].default_uint_value != 0);
284}
285
287 const uint32_t idx = ePropertyIndexCacheTypeSymtab;
288 return m_index_cache_type_sp->GetPropertyAtIndexAs<bool>(idx).value_or(
289 g_modulelist_index_cache_type_properties[idx].default_uint_value != 0);
290}
291
293 const uint32_t idx = ePropertyIndexCacheTypeDwarfIndex;
294 return m_index_cache_type_sp->GetPropertyAtIndexAs<bool>(idx).value_or(
295 g_modulelist_index_cache_type_properties[idx].default_uint_value != 0);
296}
297
299 const uint32_t idx = ePropertyIndexCacheTypeMemoryModuleSymtab;
300 return m_index_cache_type_sp->GetPropertyAtIndexAs<bool>(idx).value_or(
301 g_modulelist_index_cache_type_properties[idx].default_uint_value != 0);
302}
303
305 const {
306 const uint32_t idx = ePropertyIndexCacheTypeMemoryModuleHeaderBytes;
307 return m_index_cache_type_sp->GetPropertyAtIndexAs<bool>(idx).value_or(
308 g_modulelist_index_cache_type_properties[idx].default_uint_value != 0);
309}
310
312 const uint32_t idx = ePropertyIndexCacheMaxByteSize;
313 return m_index_cache_sp->GetPropertyAtIndexAs<uint64_t>(idx).value_or(
314 g_modulelist_index_cache_properties[idx].default_uint_value);
315}
316
318 const uint32_t idx = ePropertyIndexCacheMaxPercent;
319 return m_index_cache_sp->GetPropertyAtIndexAs<uint64_t>(idx).value_or(
320 g_modulelist_index_cache_properties[idx].default_uint_value);
321}
322
324 const uint32_t idx = ePropertyIndexCacheExpirationDays;
325 return m_index_cache_sp->GetPropertyAtIndexAs<uint64_t>(idx).value_or(
326 g_modulelist_index_cache_properties[idx].default_uint_value);
327}
328
330 FileSpecList list =
331 GetPropertyAtIndexAs<FileSpecList>(ePropertySymLinkPaths, {});
332 llvm::sys::ScopedWriter lock(m_symlink_paths_mutex);
333 const bool notify = false;
334 m_symlink_paths.Clear(notify);
335 for (auto symlink : list) {
336 FileSpec resolved;
337 Status status = FileSystem::Instance().Readlink(symlink, resolved);
338 if (status.Success())
339 m_symlink_paths.Append(symlink.GetPath(), resolved.GetPath(), notify);
340 }
341}
342
344 llvm::sys::ScopedReader lock(m_symlink_paths_mutex);
345 return m_symlink_paths;
346}
347
349 const uint32_t idx = ePropertyLoadSymbolOnDemand;
351 idx, g_modulelist_properties[idx].default_uint_value != 0);
352}
353
355 const uint32_t idx = ePropertyDemangledNameInfoCacheSize;
357 idx, g_modulelist_properties[idx].default_uint_value);
358}
359
361
363 std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex);
364 std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex);
365 m_modules = rhs.m_modules;
366}
367
370
372 if (this != &rhs) {
373 std::lock(m_modules_mutex, rhs.m_modules_mutex);
374 std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex,
375 std::adopt_lock);
376 std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex,
377 std::adopt_lock);
378 m_modules = rhs.m_modules;
379 }
380 return *this;
381}
382
383ModuleList::~ModuleList() = default;
384
385void ModuleList::AppendImpl(const ModuleSP &module_sp, bool use_notifier) {
386 if (!module_sp)
387 return;
388 {
389 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
390 // We are required to keep the first element of the Module List as the
391 // executable module. So check here and if the first module is NOT an
392 // but the new one is, we insert this module at the beginning, rather than
393 // at the end.
394 // We don't need to do any of this if the list is empty:
395 if (m_modules.empty()) {
396 m_modules.push_back(module_sp);
397 } else {
398 // Since producing the ObjectFile may take some work, first check the
399 // 0th element, and only if that's NOT an executable look at the
400 // incoming ObjectFile. That way in the normal case we only look at the
401 // element 0 ObjectFile.
402 lldb_private::ObjectFile *elem_zero_obj = m_modules[0]->GetObjectFile();
403 const bool elem_zero_is_executable =
404 elem_zero_obj &&
405 elem_zero_obj->GetType() == ObjectFile::Type::eTypeExecutable;
406 lldb_private::ObjectFile *obj = module_sp->GetObjectFile();
407 if (!elem_zero_is_executable && obj &&
409 m_modules.insert(m_modules.begin(), module_sp);
410 } else {
411 m_modules.push_back(module_sp);
412 }
413 }
414 }
415 // Release the mutex before calling the notifier to avoid deadlock
416 // NotifyModuleAdded should be thread-safe
417 if (use_notifier && m_notifier)
418 m_notifier->NotifyModuleAdded(*this, module_sp);
419}
420
421void ModuleList::Append(const ModuleSP &module_sp, bool notify) {
422 AppendImpl(module_sp, notify);
423}
424
426 const ModuleSP &module_sp,
428 if (module_sp) {
429 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
430
431 // First remove any equivalent modules. Equivalent modules are modules
432 // whose path, platform path and architecture match.
433 ModuleSpec equivalent_module_spec(module_sp->GetFileSpec(),
434 module_sp->GetArchitecture());
435 equivalent_module_spec.GetPlatformFileSpec() =
436 module_sp->GetPlatformFileSpec();
437
438 size_t idx = 0;
439 while (idx < m_modules.size()) {
440 ModuleSP test_module_sp(m_modules[idx]);
441 if (test_module_sp->MatchesModuleSpec(equivalent_module_spec)) {
442 if (old_modules)
443 old_modules->push_back(test_module_sp);
444 RemoveImpl(m_modules.begin() + idx);
445 } else {
446 ++idx;
447 }
448 }
449 // Now add the new module to the list
450 Append(module_sp);
451 }
452}
453
454bool ModuleList::AppendIfNeeded(const ModuleSP &new_module, bool notify) {
455 if (new_module) {
456 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
457 for (const ModuleSP &module_sp : m_modules) {
458 if (module_sp.get() == new_module.get())
459 return false; // Already in the list
460 }
461 // Only push module_sp on the list if it wasn't already in there.
462 Append(new_module, notify);
463 return true;
464 }
465 return false;
466}
467
468void ModuleList::Append(const ModuleList &module_list) {
469 for (auto pos : module_list.m_modules)
470 Append(pos);
471}
472
473bool ModuleList::AppendIfNeeded(const ModuleList &module_list) {
474 bool any_in = false;
475 for (auto pos : module_list.m_modules) {
476 if (AppendIfNeeded(pos))
477 any_in = true;
478 }
479 return any_in;
480}
481
482bool ModuleList::RemoveImpl(const ModuleSP &module_sp, bool use_notifier) {
483 if (module_sp) {
484 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
485 collection::iterator pos, end = m_modules.end();
486 for (pos = m_modules.begin(); pos != end; ++pos) {
487 if (pos->get() == module_sp.get()) {
488 m_modules.erase(pos);
489 if (use_notifier && m_notifier)
490 m_notifier->NotifyModuleRemoved(*this, module_sp);
491 return true;
492 }
493 }
494 }
495 return false;
496}
497
498ModuleList::collection::iterator
499ModuleList::RemoveImpl(ModuleList::collection::iterator pos,
500 bool use_notifier) {
501 ModuleSP module_sp(*pos);
502 collection::iterator retval = m_modules.erase(pos);
503 if (use_notifier && m_notifier)
504 m_notifier->NotifyModuleRemoved(*this, module_sp);
505 return retval;
506}
507
508bool ModuleList::Remove(const ModuleSP &module_sp, bool notify) {
509 return RemoveImpl(module_sp, notify);
510}
511
513 const lldb::ModuleSP &new_module_sp) {
514 if (!RemoveImpl(old_module_sp, false))
515 return false;
516 AppendImpl(new_module_sp, false);
517 if (m_notifier)
518 m_notifier->NotifyModuleUpdated(*this, old_module_sp, new_module_sp);
519 return true;
520}
521
523 if (auto module_sp = module_wp.lock()) {
524 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
525 collection::iterator pos, end = m_modules.end();
526 for (pos = m_modules.begin(); pos != end; ++pos) {
527 if (pos->get() == module_sp.get()) {
528 // Since module_sp increases the refcount by 1, the use count should be
529 // the regular use count + 1.
530 constexpr long kUseCountOrphaned = kUseCountModuleListOrphaned + 1;
531 if (pos->use_count() == kUseCountOrphaned) {
532 pos = RemoveImpl(pos);
533 return true;
534 }
535 return false;
536 }
537 }
538 }
539 return false;
540}
541
542size_t ModuleList::RemoveOrphans(bool mandatory) {
543 std::unique_lock<std::recursive_mutex> lock(m_modules_mutex, std::defer_lock);
544
545 if (mandatory) {
546 lock.lock();
547 } else {
548 // Not mandatory, remove orphans if we can get the mutex
549 if (!lock.try_lock())
550 return 0;
551 }
552 size_t remove_count = 0;
553 // Modules might hold shared pointers to other modules, so removing one
554 // module might make other modules orphans. Keep removing modules until
555 // there are no further modules that can be removed.
556 bool made_progress = true;
557 while (made_progress) {
558 // Keep track if we make progress this iteration.
559 made_progress = false;
560 collection::iterator pos = m_modules.begin();
561 while (pos != m_modules.end()) {
562 if (pos->use_count() == kUseCountModuleListOrphaned) {
563 pos = RemoveImpl(pos);
564 ++remove_count;
565 // We did make progress.
566 made_progress = true;
567 } else {
568 ++pos;
569 }
570 }
571 }
572 return remove_count;
573}
574
575size_t ModuleList::Remove(ModuleList &module_list) {
576 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
577 size_t num_removed = 0;
578 collection::iterator pos, end = module_list.m_modules.end();
579 for (pos = module_list.m_modules.begin(); pos != end; ++pos) {
580 if (Remove(*pos, false /* notify */))
581 ++num_removed;
582 }
583 if (m_notifier)
584 m_notifier->NotifyModulesRemoved(module_list);
585 return num_removed;
586}
587
589
591
592void ModuleList::ClearImpl(bool use_notifier) {
593 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
594 if (use_notifier && m_notifier)
595 m_notifier->NotifyWillClearList(*this);
596 m_modules.clear();
597}
598
600 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
601 if (idx < m_modules.size())
602 return m_modules[idx].get();
603 return nullptr;
604}
605
607 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
608 return GetModuleAtIndexUnlocked(idx);
609}
610
612 ModuleSP module_sp;
613 if (idx < m_modules.size())
614 module_sp = m_modules[idx];
615 return module_sp;
616}
617
618void ModuleList::FindFunctions(llvm::StringRef name,
619 FunctionNameType name_type_mask,
620 const ModuleFunctionSearchOptions &options,
621 SymbolContextList &sc_list) const {
622 if (name_type_mask & eFunctionNameTypeAuto) {
623 std::vector<Module::LookupInfo> lookup_infos =
626 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
627 for (const auto &lookup_info : lookup_infos) {
628 const size_t old_size = sc_list.GetSize();
629 for (const ModuleSP &module_sp : m_modules) {
630 module_sp->FindFunctions(lookup_info, CompilerDeclContext(), options,
631 sc_list);
632 }
633
634 const size_t new_size = sc_list.GetSize();
635 if (old_size < new_size)
636 lookup_info.Prune(sc_list, old_size);
637 }
638 } else {
639 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
640 for (const ModuleSP &module_sp : m_modules) {
641 module_sp->FindFunctions(ConstString(name), CompilerDeclContext(),
642 name_type_mask, options, sc_list);
643 }
644 }
645}
646
647void ModuleList::FindFunctionSymbols(llvm::StringRef name,
648 lldb::FunctionNameType name_type_mask,
649 SymbolContextList &sc_list) {
650 if (name_type_mask & eFunctionNameTypeAuto) {
651 std::vector<Module::LookupInfo> lookup_infos =
654
655 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
656 for (const auto &lookup_info : lookup_infos) {
657 const size_t old_size = sc_list.GetSize();
658 for (const ModuleSP &module_sp : m_modules) {
659 module_sp->FindFunctionSymbols(lookup_info.GetLookupName(),
660 lookup_info.GetNameTypeMask(), sc_list);
661 }
662
663 const size_t new_size = sc_list.GetSize();
664
665 if (old_size < new_size)
666 lookup_info.Prune(sc_list, old_size);
667 }
668 } else {
669 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
670 for (const ModuleSP &module_sp : m_modules) {
671 module_sp->FindFunctionSymbols(ConstString(name), name_type_mask,
672 sc_list);
673 }
674 }
675}
676
678 const ModuleFunctionSearchOptions &options,
679 SymbolContextList &sc_list) {
680 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
681 for (const ModuleSP &module_sp : m_modules)
682 module_sp->FindFunctions(name, options, sc_list);
683}
684
686 SymbolContextList &sc_list) const {
687 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
688 for (const ModuleSP &module_sp : m_modules)
689 module_sp->FindCompileUnits(path, sc_list);
690}
691
692void ModuleList::FindGlobalVariables(llvm::StringRef name, size_t max_matches,
693 VariableList &variable_list) const {
694 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
695 for (const ModuleSP &module_sp : m_modules) {
696 module_sp->FindGlobalVariables(ConstString(name), CompilerDeclContext(),
697 max_matches, variable_list);
698 }
699}
700
702 size_t max_matches,
703 VariableList &variable_list) const {
704 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
705 for (const ModuleSP &module_sp : m_modules)
706 module_sp->FindGlobalVariables(regex, max_matches, variable_list);
707}
708
710 SymbolType symbol_type,
711 SymbolContextList &sc_list) const {
712 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
713 for (const ModuleSP &module_sp : m_modules)
714 module_sp->FindSymbolsWithNameAndType(ConstString(name), symbol_type,
715 sc_list);
716}
717
719 const RegularExpression &regex, lldb::SymbolType symbol_type,
720 SymbolContextList &sc_list) const {
721 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
722 for (const ModuleSP &module_sp : m_modules)
723 module_sp->FindSymbolsMatchingRegExAndType(regex, symbol_type, sc_list);
724}
725
726void ModuleList::FindModules(const ModuleSpec &module_spec,
727 ModuleList &matching_module_list) const {
728 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
729 for (const ModuleSP &module_sp : m_modules) {
730 if (module_sp->MatchesModuleSpec(module_spec))
731 matching_module_list.Append(module_sp);
732 }
733}
734
735ModuleSP ModuleList::FindModule(const Module *module_ptr) const {
736 ModuleSP module_sp;
737
738 // Scope for "locker"
739 {
740 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
741 collection::const_iterator pos, end = m_modules.end();
742
743 for (pos = m_modules.begin(); pos != end; ++pos) {
744 if ((*pos).get() == module_ptr) {
745 module_sp = (*pos);
746 break;
747 }
748 }
749 }
750 return module_sp;
751}
752
754 ModuleSP module_sp;
755
756 if (uuid.IsValid()) {
757 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
758 collection::const_iterator pos, end = m_modules.end();
759
760 for (pos = m_modules.begin(); pos != end; ++pos) {
761 if ((*pos)->GetUUID() == uuid) {
762 module_sp = (*pos);
763 break;
764 }
765 }
766 }
767 return module_sp;
768}
769
771 ModuleSP module_sp;
772 ForEach([&](const ModuleSP &m) {
773 if (m->GetID() == uid) {
774 module_sp = m;
776 }
777
779 });
780
781 return module_sp;
782}
783
784void ModuleList::FindTypes(Module *search_first, const TypeQuery &query,
785 TypeResults &results) const {
786 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
787 if (search_first) {
788 search_first->FindTypes(query, results);
789 if (results.Done(query))
790 return;
791 }
792 for (const auto &module_sp : m_modules) {
793 if (search_first != module_sp.get()) {
794 module_sp->FindTypes(query, results);
795 if (results.Done(query))
796 return;
797 }
798 }
799}
800
802 FileSpec &new_spec) const {
803 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
804 for (const ModuleSP &module_sp : m_modules) {
805 if (module_sp->FindSourceFile(orig_spec, new_spec))
806 return true;
807 }
808 return false;
809}
810
812 const FileSpec &file, uint32_t line,
813 Function *function,
814 std::vector<Address> &output_local,
815 std::vector<Address> &output_extern) {
816 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
817 for (const ModuleSP &module_sp : m_modules) {
818 module_sp->FindAddressesForLine(target_sp, file, line, function,
819 output_local, output_extern);
820 }
821}
822
824 ModuleSP module_sp;
825 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
826 collection::const_iterator pos, end = m_modules.end();
827 for (pos = m_modules.begin(); pos != end; ++pos) {
828 ModuleSP module_sp(*pos);
829 if (module_sp->MatchesModuleSpec(module_spec))
830 return module_sp;
831 }
832 return module_sp;
833}
834
835size_t ModuleList::GetSize() const {
836 size_t size = 0;
837 {
838 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
839 size = m_modules.size();
840 }
841 return size;
842}
843
844void ModuleList::Dump(Stream *s) const {
845 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
846 for (const ModuleSP &module_sp : m_modules)
847 module_sp->Dump(s);
848}
849
850void ModuleList::LogUUIDAndPaths(Log *log, const char *prefix_cstr) {
851 if (log != nullptr) {
852 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
853 collection::const_iterator pos, begin = m_modules.begin(),
854 end = m_modules.end();
855 for (pos = begin; pos != end; ++pos) {
856 Module *module = pos->get();
857 const FileSpec &module_file_spec = module->GetFileSpec();
858 LLDB_LOGF(log, "%s[%u] %s (%s) \"%s\"", prefix_cstr ? prefix_cstr : "",
859 (uint32_t)std::distance(begin, pos),
860 module->GetUUID().GetAsString().c_str(),
862 module_file_spec.GetPath().c_str());
863 }
864 }
865}
866
868 Address &so_addr) const {
869 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
870 for (const ModuleSP &module_sp : m_modules) {
871 if (module_sp->ResolveFileAddress(vm_addr, so_addr))
872 return true;
873 }
874
875 return false;
876}
877
878uint32_t
880 SymbolContextItem resolve_scope,
881 SymbolContext &sc) const {
882 // The address is already section offset so it has a module
883 uint32_t resolved_flags = 0;
884 ModuleSP module_sp(so_addr.GetModule());
885 if (module_sp) {
886 resolved_flags =
887 module_sp->ResolveSymbolContextForAddress(so_addr, resolve_scope, sc);
888 } else {
889 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
890 collection::const_iterator pos, end = m_modules.end();
891 for (pos = m_modules.begin(); pos != end; ++pos) {
892 resolved_flags =
893 (*pos)->ResolveSymbolContextForAddress(so_addr, resolve_scope, sc);
894 if (resolved_flags != 0)
895 break;
896 }
897 }
898
899 return resolved_flags;
900}
901
903 const char *file_path, uint32_t line, bool check_inlines,
904 SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
905 FileSpec file_spec(file_path);
906 return ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
907 resolve_scope, sc_list);
908}
909
911 const FileSpec &file_spec, uint32_t line, bool check_inlines,
912 SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
913 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
914 for (const ModuleSP &module_sp : m_modules) {
915 module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
916 resolve_scope, sc_list);
917 }
918
919 return sc_list.GetSize();
920}
921
922size_t ModuleList::GetIndexForModule(const Module *module) const {
923 if (module) {
924 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
925 collection::const_iterator pos;
926 collection::const_iterator begin = m_modules.begin();
927 collection::const_iterator end = m_modules.end();
928 for (pos = begin; pos != end; ++pos) {
929 if ((*pos).get() == module)
930 return std::distance(begin, pos);
931 }
932 }
934}
935
936namespace {
937/// A wrapper around ModuleList for shared modules. Provides fast lookups for
938/// file-based ModuleSpec queries.
939class SharedModuleList {
940public:
941 /// Finds all the modules matching the module_spec, and adds them to \p
942 /// matching_module_list.
943 void FindModules(const ModuleSpec &module_spec,
944 ModuleList &matching_module_list) const {
945 std::lock_guard<std::recursive_mutex> guard(GetMutex());
946 // Try map first for performance - if found, skip expensive full list
947 // search.
948 FindModulesInMap(module_spec, matching_module_list);
949 if (!matching_module_list.IsEmpty())
950 return;
951 m_list.FindModules(module_spec, matching_module_list);
952 // Assert that modules were found in the list but not the map, it's
953 // because the module_spec has no filename or the found module has a
954 // different filename. For example, when searching by UUID and finding a
955 // module with an alias.
956 assert((matching_module_list.IsEmpty() ||
957 module_spec.GetFileSpec().GetFilename().empty() ||
958 module_spec.GetFileSpec().GetFilename() !=
959 matching_module_list.GetModuleAtIndex(0)
960 ->GetFileSpec()
961 .GetFilename()) &&
962 "Search by name not found in SharedModuleList's map");
963 }
964
965 ModuleSP FindModule(const Module &module) {
966
967 std::lock_guard<std::recursive_mutex> guard(GetMutex());
968 if (ModuleSP result = FindModuleInMap(module))
969 return result;
970 return m_list.FindModule(&module);
971 }
972
973 // UUID searches bypass map since UUIDs aren't indexed by filename.
974 ModuleSP FindModule(const UUID &uuid) const {
975 return m_list.FindModule(uuid);
976 }
977
978 void Append(const ModuleSP &module_sp, bool use_notifier) {
979 if (!module_sp)
980 return;
981 std::lock_guard<std::recursive_mutex> guard(GetMutex());
982 m_list.Append(module_sp, use_notifier);
983 AddToMap(module_sp);
984 }
985
986 size_t RemoveOrphans(bool mandatory) {
987 std::unique_lock<std::recursive_mutex> lock(GetMutex(), std::defer_lock);
988 if (mandatory) {
989 lock.lock();
990 } else {
991 if (!lock.try_lock())
992 return 0;
993 }
994 size_t total_count = 0;
995 size_t run_count;
996 do {
997 // Remove indexed orphans first, then remove non-indexed orphans. This
998 // order is important because the shared count will be different if a
999 // module is indexed or not.
1000 run_count = RemoveOrphansFromMapAndList();
1001 run_count += m_list.RemoveOrphans(mandatory);
1002 total_count += run_count;
1003 // Because removing orphans might make new orphans, remove from both
1004 // containers until a fixed-point is reached.
1005 } while (run_count != 0);
1006
1007 return total_count;
1008 }
1009
1010 bool Remove(const ModuleSP &module_sp, bool use_notifier = true) {
1011 if (!module_sp)
1012 return false;
1013 std::lock_guard<std::recursive_mutex> guard(GetMutex());
1014 RemoveFromMap(module_sp);
1015 return m_list.Remove(module_sp, use_notifier);
1016 }
1017
1018 void ReplaceEquivalent(const ModuleSP &module_sp,
1019 llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules) {
1020 std::lock_guard<std::recursive_mutex> guard(GetMutex());
1021 m_list.ReplaceEquivalent(module_sp, old_modules);
1022 ReplaceEquivalentInMap(module_sp);
1023 }
1024
1025 bool RemoveIfOrphaned(const ModuleWP module_wp) {
1026 std::lock_guard<std::recursive_mutex> guard(GetMutex());
1027 RemoveFromMap(module_wp, /*if_orphaned=*/true);
1028 return m_list.RemoveIfOrphaned(module_wp);
1029 }
1030
1031 std::recursive_mutex &GetMutex() const { return m_list.GetMutex(); }
1032
1033private:
1034 ModuleSP FindModuleInMap(const Module &module) const {
1035 if (module.GetFileSpec().GetFilename().empty())
1036 return ModuleSP();
1037 llvm::StringRef name = module.GetFileSpec().GetFilename();
1038 auto it = m_name_to_modules.find(name);
1039 if (it == m_name_to_modules.end())
1040 return ModuleSP();
1041 const llvm::SmallVectorImpl<ModuleSP> &vector = it->second;
1042 for (const ModuleSP &module_sp : vector) {
1043 if (module_sp.get() == &module)
1044 return module_sp;
1045 }
1046 return ModuleSP();
1047 }
1048
1049 void FindModulesInMap(const ModuleSpec &module_spec,
1050 ModuleList &matching_module_list) const {
1051 auto it = m_name_to_modules.find(module_spec.GetFileSpec().GetFilename());
1052 if (it == m_name_to_modules.end())
1053 return;
1054 const llvm::SmallVectorImpl<ModuleSP> &vector = it->second;
1055 for (const ModuleSP &module_sp : vector) {
1056 if (module_sp->MatchesModuleSpec(module_spec))
1057 matching_module_list.Append(module_sp);
1058 }
1059 }
1060
1061 void AddToMap(const ModuleSP &module_sp) {
1062 llvm::StringRef name = module_sp->GetFileSpec().GetFilename();
1063 if (name.empty())
1064 return;
1065 m_name_to_modules[name].push_back(module_sp);
1066 }
1067
1068 void RemoveFromMap(const ModuleWP module_wp, bool if_orphaned = false) {
1069 if (auto module_sp = module_wp.lock()) {
1070 llvm::StringRef name = module_sp->GetFileSpec().GetFilename();
1071 if (!m_name_to_modules.contains(name))
1072 return;
1073 llvm::SmallVectorImpl<ModuleSP> &vec = m_name_to_modules[name];
1074 for (auto *it = vec.begin(); it != vec.end(); ++it) {
1075 if (it->get() == module_sp.get()) {
1076 // Since module_sp increases the refcount by 1, the use count should
1077 // be the regular use count + 1.
1078 constexpr long kUseCountOrphaned =
1079 kUseCountSharedModuleListOrphaned + 1;
1080 if (!if_orphaned || it->use_count() == kUseCountOrphaned) {
1081 vec.erase(it);
1082 break;
1083 }
1084 }
1085 }
1086 }
1087 }
1088
1089 void ReplaceEquivalentInMap(const ModuleSP &module_sp) {
1090 RemoveEquivalentModulesFromMap(module_sp);
1091 AddToMap(module_sp);
1092 }
1093
1094 void RemoveEquivalentModulesFromMap(const ModuleSP &module_sp) {
1095 llvm::StringRef name = module_sp->GetFileSpec().GetFilename();
1096 if (name.empty())
1097 return;
1098
1099 auto it = m_name_to_modules.find(name);
1100 if (it == m_name_to_modules.end())
1101 return;
1102
1103 // First remove any equivalent modules. Equivalent modules are modules
1104 // whose path, platform path and architecture match.
1105 ModuleSpec equivalent_module_spec(module_sp->GetFileSpec(),
1106 module_sp->GetArchitecture());
1107 equivalent_module_spec.GetPlatformFileSpec() =
1108 module_sp->GetPlatformFileSpec();
1109
1110 llvm::SmallVectorImpl<ModuleSP> &vec = it->second;
1111 llvm::erase_if(vec, [&equivalent_module_spec](ModuleSP &element) {
1112 return element->MatchesModuleSpec(equivalent_module_spec);
1113 });
1114 }
1115
1116 /// Remove orphans from the vector and return the removed modules.
1117 ModuleList RemoveOrphansFromVector(llvm::SmallVectorImpl<ModuleSP> &vec) {
1118 // remove_if moves the elements that match the condition to the end of the
1119 // container, and returns an iterator to the first element that was moved.
1120 auto *to_remove_start = llvm::remove_if(vec, [](const ModuleSP &module) {
1121 return module.use_count() == kUseCountSharedModuleListOrphaned;
1122 });
1123
1124 ModuleList to_remove;
1125 for (ModuleSP *it = to_remove_start; it != vec.end(); ++it)
1126 to_remove.Append(*it);
1127
1128 vec.erase(to_remove_start, vec.end());
1129 return to_remove;
1130 }
1131
1132 /// Remove orphans that exist in both the map and list. This does not remove
1133 /// any orphans that exist exclusively on the list.
1134 ///
1135 /// The mutex must be locked by the caller.
1136 int RemoveOrphansFromMapAndList() {
1137 // Modules might hold shared pointers to other modules, so removing one
1138 // module might orphan other modules. Keep removing modules until
1139 // there are no further modules that can be removed.
1140 int remove_count = 0;
1141 int previous_remove_count;
1142 do {
1143 previous_remove_count = remove_count;
1144 for (auto &[name, vec] : m_name_to_modules) {
1145 if (vec.empty())
1146 continue;
1147 ModuleList to_remove = RemoveOrphansFromVector(vec);
1148 remove_count += to_remove.GetSize();
1149 m_list.Remove(to_remove);
1150 }
1151 // Break when fixed-point is reached.
1152 } while (previous_remove_count != remove_count);
1153
1154 return remove_count;
1155 }
1156
1157 ModuleList m_list;
1158
1159 /// A hash map from a module's filename to all the modules that share that
1160 /// filename, for fast module lookups by name.
1161 llvm::StringMap<llvm::SmallVector<ModuleSP, 1>> m_name_to_modules;
1162
1163 /// The use count of a module held only by m_list and m_name_to_modules.
1164 static constexpr long kUseCountSharedModuleListOrphaned = 2;
1165};
1166
1167struct SharedModuleListInfo {
1168 SharedModuleList module_list;
1169 ModuleListProperties module_list_properties;
1170};
1171} // namespace
1172static SharedModuleListInfo &GetSharedModuleListInfo() {
1173 static SharedModuleListInfo *g_shared_module_list_info = nullptr;
1174 static llvm::once_flag g_once_flag;
1175 llvm::call_once(g_once_flag, []() {
1176 // NOTE: Intentionally leak the module list so a program doesn't have to
1177 // cleanup all modules and object files as it exits. This just wastes time
1178 // doing a bunch of cleanup that isn't required.
1179 if (g_shared_module_list_info == nullptr)
1180 g_shared_module_list_info = new SharedModuleListInfo();
1181 });
1182 return *g_shared_module_list_info;
1183}
1184
1185static SharedModuleList &GetSharedModuleList() {
1186 return GetSharedModuleListInfo().module_list;
1187}
1188
1192
1193bool ModuleList::ModuleIsInCache(const Module *module_ptr) {
1194 if (module_ptr) {
1195 SharedModuleList &shared_module_list = GetSharedModuleList();
1196 return shared_module_list.FindModule(*module_ptr).get() != nullptr;
1197 }
1198 return false;
1199}
1200
1202 ModuleList &matching_module_list) {
1203 GetSharedModuleList().FindModules(module_spec, matching_module_list);
1204}
1205
1207 return GetSharedModuleList().FindModule(uuid);
1208}
1209
1211 return GetSharedModuleList().RemoveOrphans(mandatory);
1212}
1213
1214Status
1215ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
1217 bool *did_create_ptr, bool invoke_locate_callback,
1218 bool invoke_symbol_locators) {
1219 SharedModuleList &shared_module_list = GetSharedModuleList();
1220 std::lock_guard<std::recursive_mutex> guard(shared_module_list.GetMutex());
1221 char path[PATH_MAX];
1222
1223 Status error;
1224
1225 module_sp.reset();
1226
1227 if (did_create_ptr)
1228 *did_create_ptr = false;
1229
1230 const UUID *uuid_ptr = module_spec.GetUUIDPtr();
1231 const FileSpec &module_file_spec = module_spec.GetFileSpec();
1232 const ArchSpec &arch = module_spec.GetArchitecture();
1233
1234 // Make sure no one else can try and get or create a module while this
1235 // function is actively working on it by doing an extra lock on the global
1236 // mutex list.
1237 {
1238 ModuleList matching_module_list;
1239 shared_module_list.FindModules(module_spec, matching_module_list);
1240 const size_t num_matching_modules = matching_module_list.GetSize();
1241
1242 if (num_matching_modules > 0) {
1243 for (size_t module_idx = 0; module_idx < num_matching_modules;
1244 ++module_idx) {
1245 module_sp = matching_module_list.GetModuleAtIndex(module_idx);
1246
1247 // Make sure the file for the module hasn't been modified
1248 if (module_sp->FileHasChanged()) {
1249 if (old_modules)
1250 old_modules->push_back(module_sp);
1251
1252 Log *log = GetLog(LLDBLog::Modules);
1253 LLDB_LOG(
1254 log,
1255 "{0:x} '{1}' module changed: removing from global module list",
1256 static_cast<void *>(module_sp.get()),
1257 module_sp->GetFileSpec().GetFilename());
1258
1259 shared_module_list.Remove(module_sp);
1260 module_sp.reset();
1261 } else {
1262 // The module matches and the module was not modified from when it
1263 // was last loaded.
1264 return error;
1265 }
1266 }
1267 }
1268 }
1269
1270 if (module_sp)
1271 return error;
1272
1273 // Try platform's locate module callback before second attempt.
1274 // The platform can come from either the Target (if available) or directly
1275 // from the ModuleSpec (useful when Target is not yet created, e.g., during
1276 // target creation for launch mode).
1277 if (invoke_locate_callback) {
1278 PlatformSP platform_sp;
1279 if (TargetSP target_sp = module_spec.GetTargetSP()) {
1280 if (target_sp->IsValid())
1281 platform_sp = target_sp->GetPlatform();
1282 }
1283 if (!platform_sp)
1284 platform_sp = module_spec.GetPlatformSP();
1285
1286 if (platform_sp) {
1287 FileSpec symbol_file_spec;
1288 platform_sp->CallLocateModuleCallbackIfSet(
1289 module_spec, module_sp, symbol_file_spec, did_create_ptr);
1290 if (module_sp) {
1291 // The callback found a module.
1292 return error;
1293 }
1294 }
1295 }
1296
1297 module_sp = std::make_shared<Module>(module_spec);
1298 // Make sure there are a module and an object file since we can specify a
1299 // valid file path with an architecture that might not be in that file. By
1300 // getting the object file we can guarantee that the architecture matches
1301 if (module_sp->GetObjectFile()) {
1302 // If we get in here we got the correct arch, now we just need to verify
1303 // the UUID if one was given
1304 if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) {
1305 module_sp.reset();
1306 } else {
1307 if (module_sp->GetObjectFile() && module_sp->GetObjectFile()->GetType() ==
1309 module_sp.reset();
1310 } else {
1311 if (did_create_ptr) {
1312 *did_create_ptr = true;
1313 }
1314
1315 shared_module_list.ReplaceEquivalent(module_sp, old_modules);
1316 return error;
1317 }
1318 }
1319 } else {
1320 module_sp.reset();
1321 }
1322
1323 // Get module search paths from the target if available.
1324 lldb::TargetSP target_sp = module_spec.GetTargetSP();
1325 FileSpecList module_search_paths;
1326 if (target_sp)
1327 module_search_paths = target_sp->GetExecutableSearchPaths();
1328
1329 if (!module_search_paths.IsEmpty()) {
1330 const auto num_directories = module_search_paths.GetSize();
1331 for (size_t idx = 0; idx < num_directories; ++idx) {
1332 auto search_path_spec = module_search_paths.GetFileSpecAtIndex(idx);
1333 FileSystem::Instance().Resolve(search_path_spec);
1334 namespace fs = llvm::sys::fs;
1335 if (!FileSystem::Instance().IsDirectory(search_path_spec))
1336 continue;
1337 search_path_spec.AppendPathComponent(
1338 module_spec.GetFileSpec().GetFilename());
1339 if (!FileSystem::Instance().Exists(search_path_spec))
1340 continue;
1341
1342 auto resolved_module_spec(module_spec);
1343 resolved_module_spec.GetFileSpec() = search_path_spec;
1344 module_sp = std::make_shared<Module>(resolved_module_spec);
1345 if (module_sp->GetObjectFile()) {
1346 // If we get in here we got the correct arch, now we just need to
1347 // verify the UUID if one was given
1348 if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) {
1349 module_sp.reset();
1350 } else {
1351 if (module_sp->GetObjectFile()->GetType() ==
1353 module_sp.reset();
1354 } else {
1355 if (did_create_ptr)
1356 *did_create_ptr = true;
1357
1358 shared_module_list.ReplaceEquivalent(module_sp, old_modules);
1359 return Status();
1360 }
1361 }
1362 } else {
1363 module_sp.reset();
1364 }
1365 }
1366 }
1367
1368 // Either the file didn't exist where at the path, or no path was given, so we
1369 // now either have to use more extreme measures to try and find the
1370 // appropriate module or end our search here.
1371 if (!invoke_symbol_locators) {
1372 std::string uuid_str;
1373 if (uuid_ptr && uuid_ptr->IsValid())
1374 uuid_str = uuid_ptr->GetAsString();
1375 if (!uuid_str.empty())
1377 "cannot locate module for UUID '{}'", uuid_str);
1378 return Status::FromErrorString("cannot locate module");
1379 }
1380
1381 // Fixup the incoming path in case the path points to a valid file, yet the
1382 // arch or UUID (if one was passed in) don't match.
1383 ModuleSpec located_binary_modulespec;
1384 StatisticsMap symbol_locator_map;
1385 located_binary_modulespec = PluginManager::LocateExecutableObjectFile(
1386 module_spec, symbol_locator_map);
1387 // Don't look for the file if it appears to be the same one we already
1388 // checked for above...
1389 if (located_binary_modulespec.GetFileSpec() != module_file_spec) {
1390 if (!FileSystem::Instance().Exists(
1391 located_binary_modulespec.GetFileSpec())) {
1392 located_binary_modulespec.GetFileSpec().GetPath(path, sizeof(path));
1393 if (path[0] == '\0')
1394 module_file_spec.GetPath(path, sizeof(path));
1395 // How can this check ever be true? This branch it is false, and we
1396 // haven't modified file_spec.
1397 if (FileSystem::Instance().Exists(
1398 located_binary_modulespec.GetFileSpec())) {
1399 std::string uuid_str;
1400 if (uuid_ptr && uuid_ptr->IsValid())
1401 uuid_str = uuid_ptr->GetAsString();
1402
1403 if (arch.IsValid()) {
1404 if (!uuid_str.empty())
1406 "'%s' does not contain the %s architecture and UUID %s", path,
1407 arch.GetArchitectureName(), uuid_str.c_str());
1408 else
1410 "'%s' does not contain the %s architecture.", path,
1411 arch.GetArchitectureName());
1412 }
1413 } else {
1414 error = Status::FromErrorStringWithFormat("'%s' does not exist", path);
1415 }
1416 if (error.Fail())
1417 module_sp.reset();
1418 return error;
1419 }
1420
1421 // Make sure no one else can try and get or create a module while this
1422 // function is actively working on it by doing an extra lock on the global
1423 // mutex list.
1424 ModuleSpec platform_module_spec(module_spec);
1425 platform_module_spec.GetFileSpec() =
1426 located_binary_modulespec.GetFileSpec();
1427 platform_module_spec.GetPlatformFileSpec() =
1428 located_binary_modulespec.GetFileSpec();
1429 platform_module_spec.GetSymbolFileSpec() =
1430 located_binary_modulespec.GetSymbolFileSpec();
1431 ModuleList matching_module_list;
1432 shared_module_list.FindModules(platform_module_spec, matching_module_list);
1433 if (!matching_module_list.IsEmpty()) {
1434 module_sp = matching_module_list.GetModuleAtIndex(0);
1435
1436 // If we didn't have a UUID in mind when looking for the object file,
1437 // then we should make sure the modification time hasn't changed!
1438 if (platform_module_spec.GetUUIDPtr() == nullptr) {
1439 auto file_spec_mod_time = FileSystem::Instance().GetModificationTime(
1440 located_binary_modulespec.GetFileSpec());
1441 if (file_spec_mod_time != llvm::sys::TimePoint<>()) {
1442 if (file_spec_mod_time != module_sp->GetModificationTime()) {
1443 if (old_modules)
1444 old_modules->push_back(module_sp);
1445 shared_module_list.Remove(module_sp);
1446 module_sp.reset();
1447 }
1448 }
1449 }
1450 }
1451
1452 if (!module_sp) {
1453 module_sp = std::make_shared<Module>(platform_module_spec);
1454 // Make sure there are a module and an object file since we can specify a
1455 // valid file path with an architecture that might not be in that file.
1456 // By getting the object file we can guarantee that the architecture
1457 // matches
1458 if (module_sp && module_sp->GetObjectFile()) {
1459 module_sp->GetSymbolLocatorStatistics().merge(symbol_locator_map);
1460 if (module_sp->GetObjectFile()->GetType() ==
1462 module_sp.reset();
1463 } else {
1464 if (did_create_ptr)
1465 *did_create_ptr = true;
1466
1467 shared_module_list.ReplaceEquivalent(module_sp, old_modules);
1468 }
1469 } else {
1470 located_binary_modulespec.GetFileSpec().GetPath(path, sizeof(path));
1471
1472 if (located_binary_modulespec.GetFileSpec()) {
1473 if (arch.IsValid())
1475 "unable to open %s architecture in '%s'",
1476 arch.GetArchitectureName(), path);
1477 else
1478 error =
1479 Status::FromErrorStringWithFormat("unable to open '%s'", path);
1480 } else {
1481 std::string uuid_str;
1482 if (uuid_ptr && uuid_ptr->IsValid())
1483 uuid_str = uuid_ptr->GetAsString();
1484
1485 if (!uuid_str.empty())
1487 "cannot locate a module for UUID '%s'", uuid_str.c_str());
1488 else
1489 error = Status::FromErrorString("cannot locate a module");
1490 }
1491 }
1492 }
1493 }
1494
1495 return error;
1496}
1497
1499 return GetSharedModuleList().Remove(module_sp);
1500}
1501
1503 return GetSharedModuleList().RemoveIfOrphaned(module_wp);
1504}
1505
1506static bool LoadScriptingModule(const FileSpec &scripting_fspec,
1507 ScriptInterpreter &script_interpreter,
1508 Target &target, Status &error) {
1509 assert(scripting_fspec);
1510
1511 StreamString scripting_stream;
1512 scripting_fspec.Dump(scripting_stream.AsRawOstream());
1513 LoadScriptOptions options;
1514 return script_interpreter.LoadScriptingModule(
1515 scripting_stream.GetData(), options, error,
1516 /*module_sp*/ nullptr, /*extra_path*/ {}, target.shared_from_this());
1517}
1518
1520 Target &target,
1521 Status &error) {
1522 Log *log = GetLog(LLDBLog::Modules);
1523
1524 Debugger &debugger = target.GetDebugger();
1525 const ScriptLanguage script_language = debugger.GetScriptLanguage();
1526 if (script_language == eScriptLanguageNone)
1527 return true;
1528
1529 ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
1530 if (!script_interpreter) {
1531 error = Status::FromErrorString("invalid ScriptInterpreter");
1532 return false;
1533 }
1534
1535 PlatformSP platform_sp = target.GetPlatform();
1536 if (!platform_sp) {
1537 error = Status::FromErrorString("invalid Platform");
1538 return false;
1539 }
1540
1541 StreamString feedback_stream;
1542 llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile> file_specs =
1543 platform_sp->LocateExecutableScriptingResources(&target, module,
1544 feedback_stream);
1545
1546 if (!feedback_stream.Empty())
1547 debugger.ReportWarning(feedback_stream.GetString().str(), debugger.GetID());
1548
1549 const bool trusted = platform_sp->IsSymbolFileTrusted(module);
1550
1551 llvm::SmallVector<const FileSpec *> scripts_to_load;
1552 for (const auto &[scripting_fspec, load_style] : file_specs) {
1553 if (load_style == eLoadScriptFromSymFileFalse)
1554 continue;
1555
1556 if (!FileSystem::Instance().Exists(scripting_fspec))
1557 continue;
1558
1559 switch (load_style) {
1561 llvm_unreachable("case already handled");
1563 break;
1565 if (trusted)
1566 break;
1567 LLVM_FALLTHROUGH;
1569 debugger.ReportWarning(
1570 llvm::formatv(
1571 // clang-format off
1572R"('{0}' contains {1} debug script. To run this script in this debug session:
1573
1574 command script import "{2}"
1575
1576To run all discovered debug scripts in this session:
1577
1578 settings set target.load-script-from-symbol-file true
1579)",
1580 // clang-format on
1582 trusted ? "a trusted" : "an untrusted",
1583 scripting_fspec.GetPath()),
1584 debugger.GetID());
1585
1586 continue;
1587 }
1588
1589 scripts_to_load.push_back(&scripting_fspec);
1590 }
1591
1592 // Only load each module's scripts once per target. We record the module for
1593 // all of its scripts at once, so that loading the first one doesn't skip the
1594 // others.
1595 if (scripts_to_load.empty() || !target.RecordScriptingResources(module))
1596 return true;
1597
1598 bool loaded = true;
1599 for (const FileSpec *scripting_fspec : scripts_to_load) {
1600 LLDB_LOG(log, "Auto-loading {0}", scripting_fspec->GetPath());
1601
1602 if (!LoadScriptingModule(*scripting_fspec, *script_interpreter, target,
1603 error)) {
1604 LLDB_LOG(log, "Failed to load '{0}'. Remaining scripts won't be loaded.",
1605 scripting_fspec->GetPath());
1606 loaded = false;
1607 break;
1608 }
1609 }
1610
1611 // Run the stop hooks that __lldb_module_added_to_target added with
1612 // --at-initial-stop, if the process is already stopped. When another
1613 // module's __lldb_module_added_to_target loaded this module, that function
1614 // hasn't returned yet, so the load that called it runs them.
1615 if (!target.IsCollectingHooks())
1617 return loaded;
1618}
1619
1621 std::list<Status> &errors,
1622 bool continue_on_error) {
1623 if (!target)
1624 return false;
1625 m_modules_mutex.lock();
1626 // Don't hold the module list mutex while loading the scripting resources,
1627 // The initializer might do any amount of work, and having that happen while
1628 // the module list is held is asking for A/B locking problems.
1629 const ModuleList tmp_module_list(*this);
1630 m_modules_mutex.unlock();
1631
1632 for (auto module : tmp_module_list.ModulesNoLocking()) {
1633 if (module) {
1634 Status error;
1635 if (!LoadScriptingResourceInTargetForModule(*module, *target, error)) {
1636 if (error.Fail() && error.AsCString()) {
1638 "unable to load scripting data for "
1639 "module {0} - error reported was {1}",
1641 error.AsCString());
1642 errors.push_back(std::move(error));
1643 if (!continue_on_error)
1644 return false;
1646 }
1647 }
1648 }
1649 return errors.empty();
1650}
1651
1653 std::function<IterationAction(const ModuleSP &module_sp)> const &callback)
1654 const {
1655 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
1656 for (const auto &module_sp : m_modules) {
1657 assert(module_sp != nullptr);
1658 if (callback(module_sp) == IterationAction::Stop)
1659 break;
1660 }
1661}
1662
1664 std::function<bool(lldb_private::Module &module_sp)> const &callback)
1665 const {
1666 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
1667 for (const auto &module_sp : m_modules) {
1668 assert(module_sp != nullptr);
1669 if (callback(*module_sp))
1670 return true;
1671 }
1672
1673 return false;
1674}
1675
1677 // scoped_lock locks both mutexes at once.
1678 std::scoped_lock<std::recursive_mutex, std::recursive_mutex> lock(
1680 m_modules.swap(other.m_modules);
1681}
1682
1683void ModuleList::PreloadSymbols(bool parallelize) const {
1684 std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
1685
1686 if (!parallelize) {
1687 for (const ModuleSP &module_sp : m_modules)
1688 module_sp->PreloadSymbols();
1689 return;
1690 }
1691
1692 llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
1693 for (const ModuleSP &module_sp : m_modules)
1694 task_group.async([module_sp] {
1695 if (module_sp)
1696 module_sp->PreloadSymbols();
1697 });
1698 task_group.wait();
1699}
static llvm::raw_ostream & error(Stream &strm)
#define lldbassert(x)
Definition LLDBAssert.h:16
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:375
#define LLDB_LOGF(log,...)
Definition Log.h:389
static SharedModuleListInfo & GetSharedModuleListInfo()
static bool LoadScriptingModule(const FileSpec &scripting_fspec, ScriptInterpreter &script_interpreter, Target &target, Status &error)
static SharedModuleList & GetSharedModuleList()
A section + offset based address class.
Definition Address.h:62
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
Definition Address.cpp:275
An architecture specification class.
Definition ArchSpec.h:32
bool IsValid() const
Tests if this ArchSpec is valid.
Definition ArchSpec.h:375
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition ArchSpec.cpp:568
Represents a generic declaration context in a program.
A uniqued constant string class.
Definition ConstString.h:40
A class to manage flag bits.
Definition Debugger.h:106
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
static llvm::ThreadPoolInterface & GetThreadPool()
Shared thread pool. Use only with ThreadPoolTaskGroup.
lldb::ScriptLanguage GetScriptLanguage() const
Definition Debugger.cpp:459
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
A file collection class.
const FileSpec & GetFileSpecAtIndex(size_t idx) const
Get file at index.
size_t GetSize() const
Get the number of files in the file list.
A file utility class.
Definition FileSpec.h:56
llvm::StringRef GetFileNameStrippingExtension() const
Return the filename without the extension part.
Definition FileSpec.cpp:414
llvm::StringRef GetFilename() const
Filename string const get accessor.
Definition FileSpec.h:248
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:380
void Dump(llvm::raw_ostream &s) const
Dump this object to a Stream.
Definition FileSpec.cpp:341
llvm::sys::TimePoint GetModificationTime(const FileSpec &file_spec) const
Returns the modification time of the given file.
Status Readlink(const FileSpec &src, FileSpec &dst)
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
A class that describes a function.
Definition Function.h:386
bool SetClangModulesCachePath(const FileSpec &path)
lldb::SymbolDownload GetSymbolAutoDownload() const
bool GetLLDBIndexCacheTypeMemoryModuleHeaderBytes() const
bool SetEnableExternalLookup(bool new_value)
PathMappingList GetSymlinkMappings() const
uint64_t GetDemangledNameInfoCacheSize() const
lldb::SymbolSharedCacheUse GetSharedCacheBinaryLoading() const
lldb::OptionValuePropertiesSP m_experimental_properties_sp
Definition ModuleList.h:101
void ForwardDeprecatedIndexCacheSettings()
Make the deprecated "symbols.*lldb-index-cache*" settings set their replacements in "symbols....
FileSpec GetClangModulesCachePath() const
llvm::sys::RWMutex m_symlink_paths_mutex
Definition ModuleList.h:94
lldb::OptionValuePropertiesSP m_index_cache_type_sp
The "symbols.lldb-index-cache.type" settings.
Definition ModuleList.h:99
bool SetEnableTypeSystemClike(bool new_value)
bool GetLLDBIndexCacheTypeMemoryModuleSymtab() const
lldb::OptionValuePropertiesSP m_index_cache_sp
The "symbols.lldb-index-cache" settings.
Definition ModuleList.h:97
virtual void NotifyModuleRemoved(const ModuleList &module_list, const lldb::ModuleSP &module_sp)=0
A collection class for Module objects.
Definition ModuleList.h:139
bool ReplaceModule(const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp)
collection m_modules
The collection of modules.
Definition ModuleList.h:570
void ClearImpl(bool use_notifier=true)
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&,...
static bool RemoveSharedModule(lldb::ModuleSP &module_sp)
static Status GetSharedModule(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr, bool invoke_locate_callback=true, bool invoke_symbol_locators=true)
bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const
bool AnyOf(std::function< bool(lldb_private::Module &module)> const &callback) const
Returns true if 'callback' returns true for one of the modules in this ModuleList.
void FindGlobalVariables(llvm::StringRef name, size_t max_matches, VariableList &variable_list) const
Find global and static variables by name.
ModuleIterableNoLocking ModulesNoLocking() const
Definition ModuleList.h:592
static constexpr long kUseCountModuleListOrphaned
An orphaned module that lives only in the ModuleList has a count of 1.
Definition ModuleList.h:576
static bool ModuleIsInCache(const Module *module_ptr)
void Swap(ModuleList &other)
Atomically swaps the contents of this module list with other.
size_t GetIndexForModule(const Module *module) const
bool RemoveImpl(const lldb::ModuleSP &module_sp, bool use_notifier=true)
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Finds the first module whose file specification matches module_spec.
void Clear()
Clear the object's state.
ModuleList()
Default constructor.
void Dump(Stream *s) const
Dump the description of each module contained in this list.
void FindTypes(Module *search_first, const TypeQuery &query, lldb_private::TypeResults &results) const
Find types using a type-matching object that contains all search parameters.
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*,uint32_t,...
static bool LoadScriptingResourceInTargetForModule(Module &module, Target &target, Status &error)
lldb::ModuleSP GetModuleAtIndexUnlocked(size_t idx) const
Get the module shared pointer for the module at index idx without acquiring the ModuleList mutex.
static bool RemoveSharedModuleIfOrphaned(const lldb::ModuleWP module_ptr)
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list) const
Find compile units by partial or full path.
void PreloadSymbols(bool parallelize) const
For each module in this ModuleList, preload its symbols.
const ModuleList & operator=(const ModuleList &rhs)
Assignment operator.
std::recursive_mutex m_modules_mutex
Definition ModuleList.h:571
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
Module * GetModulePointerAtIndex(size_t idx) const
Get the module pointer for the module at index idx.
static lldb::ModuleSP FindSharedModule(const UUID &uuid)
lldb::ModuleSP FindModule(const Module *module_ptr) const
static ModuleListProperties & GetGlobalModuleListProperties()
void FindModules(const ModuleSpec &module_spec, ModuleList &matching_module_list) const
Finds modules whose file specification matches module_spec.
void FindFunctionSymbols(llvm::StringRef name, lldb::FunctionNameType name_type_mask, SymbolContextList &sc_list)
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.
uint32_t ResolveSymbolContextForAddress(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc) const
Resolve the symbol context for the given address. (const Address&,uint32_t,SymbolContext&)
bool Remove(const lldb::ModuleSP &module_sp, bool notify=true)
Remove a module from the module list.
size_t RemoveOrphans(bool mandatory)
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
static size_t RemoveOrphanSharedModules(bool mandatory)
void Destroy()
Clear the object's state.
void AppendImpl(const lldb::ModuleSP &module_sp, bool use_notifier=true)
void FindSymbolsWithNameAndType(llvm::StringRef name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
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.
static void FindSharedModules(const ModuleSpec &module_spec, ModuleList &matching_module_list)
bool LoadScriptingResourcesInTarget(Target *target, std::list< Status > &errors, bool continue_on_error=true)
void FindSymbolsMatchingRegExAndType(const RegularExpression &regex, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
void FindFunctions(llvm::StringRef name, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list) const
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr) const
size_t GetSize() const
Gets the size of the module list.
bool RemoveIfOrphaned(const lldb::ModuleWP module_ptr)
void LogUUIDAndPaths(Log *log, const char *prefix_cstr)
void ForEach(std::function< IterationAction(const lldb::ModuleSP &module_sp)> const &callback) const
Applies 'callback' to each module in this ModuleList.
FileSpec & GetPlatformFileSpec()
Definition ModuleSpec.h:69
FileSpec & GetFileSpec()
Definition ModuleSpec.h:57
lldb::PlatformSP GetPlatformSP() const
Definition ModuleSpec.h:152
ArchSpec & GetArchitecture()
Definition ModuleSpec.h:93
FileSpec & GetSymbolFileSpec()
Definition ModuleSpec.h:81
lldb::TargetSP GetTargetSP() const
Definition ModuleSpec.h:142
static std::vector< LookupInfo > MakeLookupInfos(ConstString name, lldb::FunctionNameType name_type_mask, lldb::LanguageType lang_type, ConstString lookup_name_override={})
Creates a vector of lookup infos for function name resolution.
Definition Module.cpp:710
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:92
const lldb_private::UUID & GetUUID()
Get a reference to the UUID value contained in this object.
Definition Module.cpp:364
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
Definition Module.cpp:1070
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition Module.h:448
void FindTypes(const TypeQuery &query, TypeResults &results)
Find types using a type-matching object that contains all search parameters.
Definition Module.cpp:995
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:47
@ eTypeExecutable
A normal executable.
Definition ObjectFile.h:56
@ eTypeStubLibrary
A library that can be linked against but not used for execution.
Definition ObjectFile.h:66
void SetDefaultValue(const FileSpec &value)
void SetCurrentValue(const FileSpec &value, bool set_value_was_set)
virtual lldb::OptionValueSP GetPropertyValueAtIndex(size_t idx, const ExecutionContext *exe_ctx) const
static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec, StatisticsMap &map)
lldb::OptionValuePropertiesSP m_collection_sp
T GetPropertyAtIndexAs(uint32_t idx, T default_value, const ExecutionContext *exe_ctx=nullptr) const
static llvm::StringRef GetExperimentalSettingsName()
bool SetPropertyAtIndex(uint32_t idx, T t, const ExecutionContext *exe_ctx=nullptr) const
virtual bool LoadScriptingModule(const char *filename, const LoadScriptOptions &options, lldb_private::Status &error, StructuredData::ObjectSP *module_sp=nullptr, FileSpec extra_search_dir={}, lldb::TargetSP loaded_into_target_sp={})
A class to count time for plugins.
Definition Statistics.h:94
An error handling class.
Definition Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition Status.h:151
bool Success() const
Test for success condition.
Definition Status.cpp:303
const char * GetData() const
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition Stream.h:28
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition Stream.h:405
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
Defines a symbol context baton that can be handed other debug core functions.
Provides public interface for all SymbolFiles.
Definition SymbolFile.h:51
void RunCollectedInitialStopHooks()
Run the collected stop hooks and hooks that were added with –at-initial-stop if the process is stoppe...
Definition Target.cpp:3318
bool RecordScriptingResources(Module &module)
Record that we're auto-loading module's scripts in this target, so we only load them once.
Definition Target.cpp:1979
Debugger & GetDebugger() const
Definition Target.h:1378
bool IsCollectingHooks() const
Definition Target.h:2024
lldb::PlatformSP GetPlatform()
Definition Target.h:2053
A class that contains all state required for type lookups.
This class tracks the state and results of a TypeQuery.
bool Done(const TypeQuery &query) const
Check if the type matching has found all of the matches that it needs.
Represents UUID's of various sizes.
Definition UUID.h:27
std::string GetAsString(llvm::StringRef separator="-") const
Definition UUID.cpp:54
bool IsValid() const
Definition UUID.h:69
#define LLDB_INVALID_INDEX32
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:338
@ eLoadScriptFromSymFileTrue
Definition Target.h:69
@ eLoadScriptFromSymFileTrusted
Definition Target.h:72
@ eLoadScriptFromSymFileFalse
Definition Target.h:70
@ eLoadScriptFromSymFileWarn
Definition Target.h:71
IterationAction
Useful for callbacks whose return type indicates whether to continue iteration or short-circuit.
ScriptLanguage
Script interpreter types.
@ eScriptLanguageNone
std::weak_ptr< lldb_private::Module > ModuleWP
std::shared_ptr< lldb_private::Platform > PlatformSP
@ eLanguageTypeUnknown
Unknown or invalid language value.
SymbolType
Symbol types.
uint64_t user_id_t
Definition lldb-types.h:83
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
@ eSymbolDownloadBackground
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::OptionValue > OptionValueSP
Options used by Module::FindFunctions.
Definition Module.h:68
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition UserID.h:47
#define PATH_MAX