32#include "llvm/Support/ThreadPool.h"
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"
70#define LLDB_PROPERTIES_modulelist
71#include "CoreProperties.inc"
74#define LLDB_PROPERTIES_modulelist
75#include "CorePropertiesEnum.inc"
86 llvm::SmallString<128> path;
87 if (llvm::sys::path::cache_directory(path)) {
88 llvm::sys::path::append(path,
"lldb");
89 llvm::sys::path::append(path,
"IndexCache");
95 const uint32_t idx = ePropertyEnableExternalLookup;
97 idx, g_modulelist_properties[idx].default_uint_value != 0);
109 const uint32_t idx = ePropertyAutoDownload;
112 g_modulelist_properties[idx].default_uint_value));
116 const uint32_t idx = ePropertySharedCacheBinaryLoading;
119 g_modulelist_properties[idx].default_uint_value));
123 const uint32_t idx = ePropertyClangModulesCachePath;
128 const uint32_t idx = ePropertyClangModulesCachePath;
133 const uint32_t idx = ePropertyLLDBIndexCachePath;
138 const uint32_t idx = ePropertyLLDBIndexCachePath;
143 const uint32_t idx = ePropertyEnableLLDBIndexCache;
145 idx, g_modulelist_properties[idx].default_uint_value != 0);
153 const uint32_t idx = ePropertyEnableLLDBIndexCacheMemoryModules;
155 idx, g_modulelist_properties[idx].default_uint_value != 0);
165 const uint32_t idx = ePropertyLLDBIndexCacheMaxByteSize;
167 idx, g_modulelist_properties[idx].default_uint_value);
171 const uint32_t idx = ePropertyLLDBIndexCacheMaxPercent;
173 idx, g_modulelist_properties[idx].default_uint_value);
177 const uint32_t idx = ePropertyLLDBIndexCacheExpirationDays;
179 idx, g_modulelist_properties[idx].default_uint_value);
186 const bool notify =
false;
188 for (
auto symlink : list) {
202 const uint32_t idx = ePropertyLoadSymbolOnDemand;
204 idx, g_modulelist_properties[idx].default_uint_value != 0);
208 const uint32_t idx = ePropertyDemangledNameInfoCacheSize;
210 idx, g_modulelist_properties[idx].default_uint_value);
256 const bool elem_zero_is_executable =
260 if (!elem_zero_is_executable && obj &&
271 m_notifier->NotifyModuleAdded(*
this, module_sp);
286 ModuleSpec equivalent_module_spec(module_sp->GetFileSpec(),
287 module_sp->GetArchitecture());
289 module_sp->GetPlatformFileSpec();
294 if (test_module_sp->MatchesModuleSpec(equivalent_module_spec)) {
296 old_modules->push_back(test_module_sp);
311 if (module_sp.get() == new_module.get())
315 Append(new_module, notify);
338 collection::iterator pos, end =
m_modules.end();
339 for (pos =
m_modules.begin(); pos != end; ++pos) {
340 if (pos->get() == module_sp.get()) {
343 m_notifier->NotifyModuleRemoved(*
this, module_sp);
351ModuleList::collection::iterator
355 collection::iterator retval =
m_modules.erase(pos);
371 m_notifier->NotifyModuleUpdated(*
this, old_module_sp, new_module_sp);
376 if (
auto module_sp = module_wp.lock()) {
378 collection::iterator pos, end =
m_modules.end();
379 for (pos =
m_modules.begin(); pos != end; ++pos) {
380 if (pos->get() == module_sp.get()) {
384 if (pos->use_count() == kUseCountOrphaned) {
396 std::unique_lock<std::recursive_mutex> lock(
m_modules_mutex, std::defer_lock);
402 if (!lock.try_lock())
405 size_t remove_count = 0;
409 bool made_progress =
true;
410 while (made_progress) {
412 made_progress =
false;
413 collection::iterator pos =
m_modules.begin();
419 made_progress =
true;
430 size_t num_removed = 0;
431 collection::iterator pos, end = module_list.
m_modules.end();
432 for (pos = module_list.
m_modules.begin(); pos != end; ++pos) {
437 m_notifier->NotifyModulesRemoved(module_list);
472 FunctionNameType name_type_mask,
475 if (name_type_mask & eFunctionNameTypeAuto) {
476 std::vector<Module::LookupInfo> lookup_infos =
480 for (
const auto &lookup_info : lookup_infos) {
481 const size_t old_size = sc_list.
GetSize();
487 const size_t new_size = sc_list.
GetSize();
488 if (old_size < new_size)
489 lookup_info.Prune(sc_list, old_size);
494 module_sp->FindFunctions(name, CompilerDeclContext(), name_type_mask,
501 lldb::FunctionNameType name_type_mask,
503 if (name_type_mask & eFunctionNameTypeAuto) {
504 std::vector<Module::LookupInfo> lookup_infos =
509 for (
const auto &lookup_info : lookup_infos) {
510 const size_t old_size = sc_list.
GetSize();
512 module_sp->FindFunctionSymbols(lookup_info.GetLookupName(),
513 lookup_info.GetNameTypeMask(), sc_list);
516 const size_t new_size = sc_list.
GetSize();
518 if (old_size < new_size)
519 lookup_info.Prune(sc_list, old_size);
524 module_sp->FindFunctionSymbols(name, name_type_mask, sc_list);
534 module_sp->FindFunctions(name, options, sc_list);
541 module_sp->FindCompileUnits(path, sc_list);
558 module_sp->FindGlobalVariables(regex, max_matches, variable_list);
566 module_sp->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
574 module_sp->FindSymbolsMatchingRegExAndType(regex, symbol_type, sc_list);
581 if (module_sp->MatchesModuleSpec(module_spec))
582 matching_module_list.
Append(module_sp);
592 collection::const_iterator pos, end =
m_modules.end();
594 for (pos =
m_modules.begin(); pos != end; ++pos) {
595 if ((*pos).get() == module_ptr) {
609 collection::const_iterator pos, end =
m_modules.end();
611 for (pos =
m_modules.begin(); pos != end; ++pos) {
612 if ((*pos)->GetUUID() == uuid) {
624 if (m->GetID() == uid) {
640 if (results.
Done(query))
643 for (
const auto &module_sp :
m_modules) {
644 if (search_first != module_sp.get()) {
645 module_sp->FindTypes(query, results);
646 if (results.
Done(query))
656 if (module_sp->FindSourceFile(orig_spec, new_spec))
663 const FileSpec &file, uint32_t line,
665 std::vector<Address> &output_local,
666 std::vector<Address> &output_extern) {
669 module_sp->FindAddressesForLine(target_sp, file, line, function,
670 output_local, output_extern);
677 collection::const_iterator pos, end =
m_modules.end();
678 for (pos =
m_modules.begin(); pos != end; ++pos) {
680 if (module_sp->MatchesModuleSpec(module_spec))
702 if (log !=
nullptr) {
704 collection::const_iterator pos, begin =
m_modules.begin(),
706 for (pos = begin; pos != end; ++pos) {
707 Module *module = pos->get();
708 const FileSpec &module_file_spec =
module->GetFileSpec();
709 LLDB_LOGF(log,
"%s[%u] %s (%s) \"%s\"", prefix_cstr ? prefix_cstr :
"",
710 (uint32_t)std::distance(begin, pos),
713 module_file_spec.
GetPath().c_str());
722 if (module_sp->ResolveFileAddress(vm_addr, so_addr))
731 SymbolContextItem resolve_scope,
734 uint32_t resolved_flags = 0;
738 module_sp->ResolveSymbolContextForAddress(so_addr, resolve_scope, sc);
741 collection::const_iterator pos, end =
m_modules.end();
742 for (pos =
m_modules.begin(); pos != end; ++pos) {
744 (*pos)->ResolveSymbolContextForAddress(so_addr, resolve_scope, sc);
745 if (resolved_flags != 0)
750 return resolved_flags;
754 const char *file_path, uint32_t line,
bool check_inlines,
758 resolve_scope, sc_list);
762 const FileSpec &file_spec, uint32_t line,
bool check_inlines,
766 module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
767 resolve_scope, sc_list);
776 collection::const_iterator pos;
777 collection::const_iterator begin =
m_modules.begin();
778 collection::const_iterator end =
m_modules.end();
779 for (pos = begin; pos != end; ++pos) {
780 if ((*pos).get() == module)
781 return std::distance(begin, pos);
790class SharedModuleList {
794 void FindModules(
const ModuleSpec &module_spec,
796 std::lock_guard<std::recursive_mutex> guard(GetMutex());
799 FindModulesInMap(module_spec, matching_module_list);
800 if (!matching_module_list.
IsEmpty())
802 m_list.FindModules(module_spec, matching_module_list);
807 assert((matching_module_list.
IsEmpty() ||
813 "Search by name not found in SharedModuleList's map");
818 std::lock_guard<std::recursive_mutex> guard(GetMutex());
819 if (
ModuleSP result = FindModuleInMap(module))
821 return m_list.FindModule(&module);
825 ModuleSP FindModule(
const UUID &uuid)
const {
826 return m_list.FindModule(uuid);
829 void Append(
const ModuleSP &module_sp,
bool use_notifier) {
832 std::lock_guard<std::recursive_mutex> guard(GetMutex());
833 m_list.Append(module_sp, use_notifier);
837 size_t RemoveOrphans(
bool mandatory) {
838 std::unique_lock<std::recursive_mutex> lock(GetMutex(), std::defer_lock);
842 if (!lock.try_lock())
845 size_t total_count = 0;
851 run_count = RemoveOrphansFromMapAndList();
852 run_count += m_list.RemoveOrphans(mandatory);
853 total_count += run_count;
856 }
while (run_count != 0);
861 bool Remove(
const ModuleSP &module_sp,
bool use_notifier =
true) {
864 std::lock_guard<std::recursive_mutex> guard(GetMutex());
865 RemoveFromMap(module_sp);
866 return m_list.Remove(module_sp, use_notifier);
869 void ReplaceEquivalent(
const ModuleSP &module_sp,
870 llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules) {
871 std::lock_guard<std::recursive_mutex> guard(GetMutex());
872 m_list.ReplaceEquivalent(module_sp, old_modules);
873 ReplaceEquivalentInMap(module_sp);
876 bool RemoveIfOrphaned(
const ModuleWP module_wp) {
877 std::lock_guard<std::recursive_mutex> guard(GetMutex());
878 RemoveFromMap(module_wp,
true);
879 return m_list.RemoveIfOrphaned(module_wp);
882 std::recursive_mutex &GetMutex()
const {
return m_list.GetMutex(); }
888 llvm::StringRef name =
module.GetFileSpec().GetFilename();
889 auto it = m_name_to_modules.find(ConstString(name));
890 if (it == m_name_to_modules.end())
892 const llvm::SmallVectorImpl<ModuleSP> &vector = it->second;
893 for (
const ModuleSP &module_sp : vector) {
894 if (module_sp.get() == &module)
900 void FindModulesInMap(
const ModuleSpec &module_spec,
901 ModuleList &matching_module_list)
const {
902 auto it = m_name_to_modules.find(
904 if (it == m_name_to_modules.end())
906 const llvm::SmallVectorImpl<ModuleSP> &vector = it->second;
907 for (
const ModuleSP &module_sp : vector) {
908 if (module_sp->MatchesModuleSpec(module_spec))
909 matching_module_list.
Append(module_sp);
913 void AddToMap(
const ModuleSP &module_sp) {
914 llvm::StringRef name = module_sp->GetFileSpec().GetFilename();
917 m_name_to_modules[ConstString(name)].push_back(module_sp);
920 void RemoveFromMap(
const ModuleWP module_wp,
bool if_orphaned =
false) {
921 if (
auto module_sp = module_wp.lock()) {
922 ConstString name = ConstString(module_sp->GetFileSpec().GetFilename());
923 if (!m_name_to_modules.contains(name))
925 llvm::SmallVectorImpl<ModuleSP> &vec = m_name_to_modules[name];
926 for (
auto *it = vec.begin(); it != vec.end(); ++it) {
927 if (it->get() == module_sp.get()) {
930 constexpr long kUseCountOrphaned =
931 kUseCountSharedModuleListOrphaned + 1;
932 if (!if_orphaned || it->use_count() == kUseCountOrphaned) {
941 void ReplaceEquivalentInMap(
const ModuleSP &module_sp) {
942 RemoveEquivalentModulesFromMap(module_sp);
946 void RemoveEquivalentModulesFromMap(
const ModuleSP &module_sp) {
947 llvm::StringRef name = module_sp->GetFileSpec().GetFilename();
951 auto it = m_name_to_modules.find(ConstString(name));
952 if (it == m_name_to_modules.end())
957 ModuleSpec equivalent_module_spec(module_sp->GetFileSpec(),
958 module_sp->GetArchitecture());
959 equivalent_module_spec.GetPlatformFileSpec() =
960 module_sp->GetPlatformFileSpec();
962 llvm::SmallVectorImpl<ModuleSP> &vec = it->second;
963 llvm::erase_if(vec, [&equivalent_module_spec](
ModuleSP &element) {
964 return element->MatchesModuleSpec(equivalent_module_spec);
969 ModuleList RemoveOrphansFromVector(llvm::SmallVectorImpl<ModuleSP> &vec) {
972 auto *to_remove_start = llvm::remove_if(vec, [](
const ModuleSP &module) {
973 return module.use_count() == kUseCountSharedModuleListOrphaned;
976 ModuleList to_remove;
977 for (
ModuleSP *it = to_remove_start; it != vec.end(); ++it)
978 to_remove.Append(*it);
980 vec.erase(to_remove_start, vec.end());
988 int RemoveOrphansFromMapAndList() {
992 int remove_count = 0;
993 int previous_remove_count;
995 previous_remove_count = remove_count;
996 for (
auto &[name, vec] : m_name_to_modules) {
999 ModuleList to_remove = RemoveOrphansFromVector(vec);
1000 remove_count += to_remove.
GetSize();
1001 m_list.Remove(to_remove);
1004 }
while (previous_remove_count != remove_count);
1006 return remove_count;
1013 llvm::DenseMap<ConstString, llvm::SmallVector<ModuleSP, 1>> m_name_to_modules;
1016 static constexpr long kUseCountSharedModuleListOrphaned = 2;
1019struct SharedModuleListInfo {
1020 SharedModuleList module_list;
1021 ModuleListProperties module_list_properties;
1025 static SharedModuleListInfo *g_shared_module_list_info =
nullptr;
1026 static llvm::once_flag g_once_flag;
1027 llvm::call_once(g_once_flag, []() {
1031 if (g_shared_module_list_info ==
nullptr)
1032 g_shared_module_list_info =
new SharedModuleListInfo();
1034 return *g_shared_module_list_info;
1048 return shared_module_list.FindModule(*module_ptr).get() !=
nullptr;
1069 bool *did_create_ptr,
bool invoke_locate_callback,
1070 bool invoke_symbol_locators) {
1072 std::lock_guard<std::recursive_mutex> guard(shared_module_list.GetMutex());
1080 *did_create_ptr =
false;
1091 shared_module_list.FindModules(module_spec, matching_module_list);
1092 const size_t num_matching_modules = matching_module_list.
GetSize();
1094 if (num_matching_modules > 0) {
1095 for (
size_t module_idx = 0; module_idx < num_matching_modules;
1100 if (module_sp->FileHasChanged()) {
1102 old_modules->push_back(module_sp);
1107 "{0:x} '{1}' module changed: removing from global module list",
1108 static_cast<void *
>(module_sp.get()),
1109 module_sp->GetFileSpec().GetFilename());
1111 shared_module_list.Remove(module_sp);
1129 if (invoke_locate_callback) {
1132 if (target_sp->IsValid())
1133 platform_sp = target_sp->GetPlatform();
1140 platform_sp->CallLocateModuleCallbackIfSet(
1141 module_spec, module_sp, symbol_file_spec, did_create_ptr);
1149 module_sp = std::make_shared<Module>(module_spec);
1153 if (module_sp->GetObjectFile()) {
1156 if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) {
1159 if (module_sp->GetObjectFile() && module_sp->GetObjectFile()->GetType() ==
1163 if (did_create_ptr) {
1164 *did_create_ptr =
true;
1167 shared_module_list.ReplaceEquivalent(module_sp, old_modules);
1179 module_search_paths = target_sp->GetExecutableSearchPaths();
1181 if (!module_search_paths.
IsEmpty()) {
1182 const auto num_directories = module_search_paths.
GetSize();
1183 for (
size_t idx = 0; idx < num_directories; ++idx) {
1186 namespace fs = llvm::sys::fs;
1189 search_path_spec.AppendPathComponent(
1194 auto resolved_module_spec(module_spec);
1195 resolved_module_spec.GetFileSpec() = search_path_spec;
1196 module_sp = std::make_shared<Module>(resolved_module_spec);
1197 if (module_sp->GetObjectFile()) {
1200 if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) {
1203 if (module_sp->GetObjectFile()->GetType() ==
1208 *did_create_ptr =
true;
1210 shared_module_list.ReplaceEquivalent(module_sp, old_modules);
1223 if (!invoke_symbol_locators) {
1224 std::string uuid_str;
1225 if (uuid_ptr && uuid_ptr->
IsValid())
1227 if (!uuid_str.empty())
1229 "cannot locate module for UUID '{}'", uuid_str);
1238 module_spec, symbol_locator_map);
1241 if (located_binary_modulespec.
GetFileSpec() != module_file_spec) {
1245 if (path[0] ==
'\0')
1246 module_file_spec.
GetPath(path,
sizeof(path));
1251 std::string uuid_str;
1252 if (uuid_ptr && uuid_ptr->
IsValid())
1256 if (!uuid_str.empty())
1258 "'%s' does not contain the %s architecture and UUID %s", path,
1262 "'%s' does not contain the %s architecture.", path,
1276 ModuleSpec platform_module_spec(module_spec);
1284 shared_module_list.FindModules(platform_module_spec, matching_module_list);
1285 if (!matching_module_list.
IsEmpty()) {
1290 if (platform_module_spec.
GetUUIDPtr() ==
nullptr) {
1293 if (file_spec_mod_time != llvm::sys::TimePoint<>()) {
1294 if (file_spec_mod_time != module_sp->GetModificationTime()) {
1296 old_modules->push_back(module_sp);
1297 shared_module_list.Remove(module_sp);
1305 module_sp = std::make_shared<Module>(platform_module_spec);
1310 if (module_sp && module_sp->GetObjectFile()) {
1311 module_sp->GetSymbolLocatorStatistics().merge(symbol_locator_map);
1312 if (module_sp->GetObjectFile()->GetType() ==
1317 *did_create_ptr =
true;
1319 shared_module_list.ReplaceEquivalent(module_sp, old_modules);
1327 "unable to open %s architecture in '%s'",
1333 std::string uuid_str;
1334 if (uuid_ptr && uuid_ptr->
IsValid())
1337 if (!uuid_str.empty())
1339 "cannot locate a module for UUID '%s'", uuid_str.c_str());
1361 assert(scripting_fspec);
1368 nullptr, {}, target.shared_from_this());
1382 if (!script_interpreter) {
1394 llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile> file_specs =
1395 platform_sp->LocateExecutableScriptingResources(&target, module,
1398 if (!feedback_stream.
Empty())
1401 const bool trusted = platform_sp->IsSymbolFileTrusted(module);
1403 for (
const auto &[scripting_fspec, load_style] : file_specs) {
1410 switch (load_style) {
1412 llvm_unreachable(
"case already handled");
1423R
"('{0}' contains {1} debug script. To run this script in this debug session:
1425 command script import "{2}"
1427To run all discovered debug scripts in this session:
1429 settings set target.load-script-from-symbol-file true
1433 trusted ?
"a trusted" :
"an untrusted",
1434 scripting_fspec.GetPath()),
1440 LLDB_LOG(log,
"Auto-loading {0}", scripting_fspec.GetPath());
1444 LLDB_LOG(log,
"Failed to load '{0}'. Remaining scripts won't be loaded.",
1445 scripting_fspec.GetPath());
1454 std::list<Status> &errors,
1455 bool continue_on_error) {
1471 "unable to load scripting data for "
1472 "module {0} - error reported was {1}",
1473 module->GetFileSpec().GetFileNameStrippingExtension(),
1475 errors.push_back(std::move(
error));
1476 if (!continue_on_error)
1482 return errors.empty();
1490 assert(module_sp !=
nullptr);
1500 for (
const auto &module_sp :
m_modules) {
1501 assert(module_sp !=
nullptr);
1502 if (callback(*module_sp))
1511 std::scoped_lock<std::recursive_mutex, std::recursive_mutex> lock(
1527 task_group.async([module_sp] {
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
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.
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Represents a generic declaration context in a program.
A uniqued constant string class.
A class to manage flag bits.
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
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
const FileSpec & GetFileSpecAtIndex(size_t idx) const
Get file at index.
size_t GetSize() const
Get the number of files in the file list.
llvm::StringRef GetFileNameStrippingExtension() const
Return the filename without the extension part.
llvm::StringRef GetFilename() const
Filename string const get accessor.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void Dump(llvm::raw_ostream &s) const
Dump this object to a Stream.
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.
bool GetLoadSymbolOnDemand() const
bool SetClangModulesCachePath(const FileSpec &path)
lldb::SymbolDownload GetSymbolAutoDownload() const
bool GetEnableExternalLookup() const
bool SetLLDBIndexCachePath(const FileSpec &path)
bool GetEnableLLDBIndexCache() const
bool SetEnableExternalLookup(bool new_value)
FileSpec GetLLDBIndexCachePath() const
PathMappingList GetSymlinkMappings() const
uint64_t GetDemangledNameInfoCacheSize() const
lldb::SymbolSharedCacheUse GetSharedCacheBinaryLoading() const
uint64_t GetLLDBIndexCacheMaxByteSize()
PathMappingList m_symlink_paths
FileSpec GetClangModulesCachePath() const
llvm::sys::RWMutex m_symlink_paths_mutex
bool GetEnableLLDBIndexCacheMemoryModules() const
uint64_t GetLLDBIndexCacheMaxPercent()
void UpdateSymlinkMappings()
bool SetEnableLLDBIndexCache(bool new_value)
uint64_t GetLLDBIndexCacheExpirationDays()
bool SetEnableLLDBIndexCacheMemoryModules(bool new_value)
virtual void NotifyModuleRemoved(const ModuleList &module_list, const lldb::ModuleSP &module_sp)=0
A collection class for Module objects.
bool ReplaceModule(const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp)
collection m_modules
The collection of modules.
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)
void FindFunctions(ConstString name, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list) const
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.
ModuleIterableNoLocking ModulesNoLocking() const
static constexpr long kUseCountModuleListOrphaned
An orphaned module that lives only in the ModuleList has a count of 1.
static bool ModuleIsInCache(const Module *module_ptr)
void FindGlobalVariables(ConstString name, size_t max_matches, VariableList &variable_list) const
Find global and static variables by name.
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
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.
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
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 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 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.
void FindFunctionSymbols(ConstString name, lldb::FunctionNameType name_type_mask, SymbolContextList &sc_list)
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 ®ex, lldb::SymbolType symbol_type, 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()
lldb::PlatformSP GetPlatformSP() const
ArchSpec & GetArchitecture()
FileSpec & GetSymbolFileSpec()
lldb::TargetSP GetTargetSP() const
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.
A class that describes an executable image and its associated object and symbol files.
const lldb_private::UUID & GetUUID()
Get a reference to the UUID value contained in this object.
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
void FindTypes(const TypeQuery &query, TypeResults &results)
Find types using a type-matching object that contains all search parameters.
A plug-in interface definition class for object file parsers.
@ eTypeExecutable
A normal executable.
@ eTypeStubLibrary
A library that can be linked against but not used for execution.
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
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.
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
bool Success() const
Test for success condition.
const char * GetData() const
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
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.
Debugger & GetDebugger() const
lldb::PlatformSP GetPlatform()
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.
std::string GetAsString(llvm::StringRef separator="-") const
#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.
@ eLoadScriptFromSymFileTrue
@ eLoadScriptFromSymFileTrusted
@ eLoadScriptFromSymFileFalse
@ eLoadScriptFromSymFileWarn
IterationAction
Useful for callbacks whose return type indicates whether to continue iteration or short-circuit.
ScriptLanguage
Script interpreter types.
std::weak_ptr< lldb_private::Module > ModuleWP
std::shared_ptr< lldb_private::Platform > PlatformSP
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Target > TargetSP
@ eSymbolDownloadBackground
std::shared_ptr< lldb_private::Module > ModuleSP
Options used by Module::FindFunctions.
lldb::user_id_t GetID() const
Get accessor for the user ID.