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"
78#define LLDB_PROPERTIES_modulelist_index_cache
79#include "CoreProperties.inc"
82#define LLDB_PROPERTIES_modulelist_index_cache
83#include "CorePropertiesEnum.inc"
86#define LLDB_PROPERTIES_modulelist_index_cache_type
87#include "CoreProperties.inc"
90#define LLDB_PROPERTIES_modulelist_index_cache_type
91#include "CorePropertiesEnum.inc"
94#define LLDB_PROPERTIES_modulelist_experimental
95#include "CoreProperties.inc"
98#define LLDB_PROPERTIES_modulelist_experimental
99#include "CorePropertiesEnum.inc"
106void ForwardDeprecatedSetting(
const OptionValueProperties &deprecated,
107 uint32_t deprecated_idx,
108 const OptionValueProperties &replacements,
109 llvm::ArrayRef<uint32_t> replacement_idxs) {
114 std::optional<T> value;
115 if (deprecated_sp->OptionWasSet())
116 value = deprecated_sp->GetValueAs<T>();
117 for (uint32_t idx : replacement_idxs) {
123 replacement_sp->SetValueAs(*value);
124 replacement_sp->SetOptionWasSet();
126 replacement_sp->Clear();
140 std::make_shared<OptionValueProperties>(
"lldb-index-cache");
144 "Settings for caching data from modules on disk, for improved "
145 "performance in subsequent debug sessions.",
150 g_modulelist_index_cache_type_properties_def);
152 "Settings for which kinds of data from "
153 "modules are cached on disk.",
161 g_modulelist_experimental_properties_def);
164 "Experimental settings - setting these won't produce "
165 "errors if the setting is not present.",
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");
176 ePropertyIndexCachePath);
187 ePropertyEnableLLDBIndexCache, [
this] {
188 ForwardDeprecatedSetting<bool>(
191 {ePropertyIndexCacheTypeSymtab, ePropertyIndexCacheTypeDwarfIndex});
194 ePropertyEnableLLDBIndexCacheMemoryModules, [
this] {
195 ForwardDeprecatedSetting<bool>(
198 {ePropertyIndexCacheTypeMemoryModuleSymtab});
200 m_collection_sp->SetValueChangedCallback(ePropertyLLDBIndexCachePath, [
this] {
201 ForwardDeprecatedSetting<FileSpec>(
203 {ePropertyIndexCachePath});
206 ePropertyLLDBIndexCacheMaxByteSize, [
this] {
207 ForwardDeprecatedSetting<uint64_t>(
212 ePropertyLLDBIndexCacheMaxPercent, [
this] {
213 ForwardDeprecatedSetting<uint64_t>(
218 ePropertyLLDBIndexCacheExpirationDays, [
this] {
219 ForwardDeprecatedSetting<uint64_t>(
226 const uint32_t idx = ePropertyEnableExternalLookup;
228 idx, g_modulelist_properties[idx].default_uint_value != 0);
236 const uint32_t idx = ePropertyEnableTypeSystemClike;
238 g_modulelist_experimental_properties[idx].default_uint_value != 0);
243 ePropertyEnableTypeSystemClike, new_value);
251 const uint32_t idx = ePropertyAutoDownload;
254 g_modulelist_properties[idx].default_uint_value));
258 const uint32_t idx = ePropertySharedCacheBinaryLoading;
261 g_modulelist_properties[idx].default_uint_value));
265 const uint32_t idx = ePropertyClangModulesCachePath;
270 const uint32_t idx = ePropertyClangModulesCachePath;
276 ->GetPropertyAtIndexAs<
FileSpec>(ePropertyIndexCachePath)
281 const uint32_t idx = ePropertyIndexCacheForceDisable;
283 g_modulelist_index_cache_properties[idx].default_uint_value != 0);
287 const uint32_t idx = ePropertyIndexCacheTypeSymtab;
289 g_modulelist_index_cache_type_properties[idx].default_uint_value != 0);
293 const uint32_t idx = ePropertyIndexCacheTypeDwarfIndex;
295 g_modulelist_index_cache_type_properties[idx].default_uint_value != 0);
299 const uint32_t idx = ePropertyIndexCacheTypeMemoryModuleSymtab;
301 g_modulelist_index_cache_type_properties[idx].default_uint_value != 0);
306 const uint32_t idx = ePropertyIndexCacheTypeMemoryModuleHeaderBytes;
308 g_modulelist_index_cache_type_properties[idx].default_uint_value != 0);
312 const uint32_t idx = ePropertyIndexCacheMaxByteSize;
314 g_modulelist_index_cache_properties[idx].default_uint_value);
318 const uint32_t idx = ePropertyIndexCacheMaxPercent;
320 g_modulelist_index_cache_properties[idx].default_uint_value);
324 const uint32_t idx = ePropertyIndexCacheExpirationDays;
326 g_modulelist_index_cache_properties[idx].default_uint_value);
333 const bool notify =
false;
335 for (
auto symlink : list) {
349 const uint32_t idx = ePropertyLoadSymbolOnDemand;
351 idx, g_modulelist_properties[idx].default_uint_value != 0);
355 const uint32_t idx = ePropertyDemangledNameInfoCacheSize;
357 idx, g_modulelist_properties[idx].default_uint_value);
403 const bool elem_zero_is_executable =
407 if (!elem_zero_is_executable && obj &&
418 m_notifier->NotifyModuleAdded(*
this, module_sp);
433 ModuleSpec equivalent_module_spec(module_sp->GetFileSpec(),
434 module_sp->GetArchitecture());
436 module_sp->GetPlatformFileSpec();
441 if (test_module_sp->MatchesModuleSpec(equivalent_module_spec)) {
443 old_modules->push_back(test_module_sp);
458 if (module_sp.get() == new_module.get())
462 Append(new_module, notify);
485 collection::iterator pos, end =
m_modules.end();
486 for (pos =
m_modules.begin(); pos != end; ++pos) {
487 if (pos->get() == module_sp.get()) {
490 m_notifier->NotifyModuleRemoved(*
this, module_sp);
498ModuleList::collection::iterator
502 collection::iterator retval =
m_modules.erase(pos);
518 m_notifier->NotifyModuleUpdated(*
this, old_module_sp, new_module_sp);
523 if (
auto module_sp = module_wp.lock()) {
525 collection::iterator pos, end =
m_modules.end();
526 for (pos =
m_modules.begin(); pos != end; ++pos) {
527 if (pos->get() == module_sp.get()) {
531 if (pos->use_count() == kUseCountOrphaned) {
543 std::unique_lock<std::recursive_mutex> lock(
m_modules_mutex, std::defer_lock);
549 if (!lock.try_lock())
552 size_t remove_count = 0;
556 bool made_progress =
true;
557 while (made_progress) {
559 made_progress =
false;
560 collection::iterator pos =
m_modules.begin();
566 made_progress =
true;
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) {
584 m_notifier->NotifyModulesRemoved(module_list);
619 FunctionNameType name_type_mask,
622 if (name_type_mask & eFunctionNameTypeAuto) {
623 std::vector<Module::LookupInfo> lookup_infos =
627 for (
const auto &lookup_info : lookup_infos) {
628 const size_t old_size = sc_list.
GetSize();
634 const size_t new_size = sc_list.
GetSize();
635 if (old_size < new_size)
636 lookup_info.Prune(sc_list, old_size);
641 module_sp->FindFunctions(ConstString(name), CompilerDeclContext(),
642 name_type_mask, options, sc_list);
648 lldb::FunctionNameType name_type_mask,
650 if (name_type_mask & eFunctionNameTypeAuto) {
651 std::vector<Module::LookupInfo> lookup_infos =
656 for (
const auto &lookup_info : lookup_infos) {
657 const size_t old_size = sc_list.
GetSize();
659 module_sp->FindFunctionSymbols(lookup_info.GetLookupName(),
660 lookup_info.GetNameTypeMask(), sc_list);
663 const size_t new_size = sc_list.
GetSize();
665 if (old_size < new_size)
666 lookup_info.Prune(sc_list, old_size);
671 module_sp->FindFunctionSymbols(
ConstString(name), name_type_mask,
682 module_sp->FindFunctions(name, options, sc_list);
689 module_sp->FindCompileUnits(path, sc_list);
697 max_matches, variable_list);
706 module_sp->FindGlobalVariables(regex, max_matches, variable_list);
714 module_sp->FindSymbolsWithNameAndType(
ConstString(name), symbol_type,
723 module_sp->FindSymbolsMatchingRegExAndType(regex, symbol_type, sc_list);
730 if (module_sp->MatchesModuleSpec(module_spec))
731 matching_module_list.
Append(module_sp);
741 collection::const_iterator pos, end =
m_modules.end();
743 for (pos =
m_modules.begin(); pos != end; ++pos) {
744 if ((*pos).get() == module_ptr) {
758 collection::const_iterator pos, end =
m_modules.end();
760 for (pos =
m_modules.begin(); pos != end; ++pos) {
761 if ((*pos)->GetUUID() == uuid) {
773 if (m->GetID() == uid) {
789 if (results.
Done(query))
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))
805 if (module_sp->FindSourceFile(orig_spec, new_spec))
812 const FileSpec &file, uint32_t line,
814 std::vector<Address> &output_local,
815 std::vector<Address> &output_extern) {
818 module_sp->FindAddressesForLine(target_sp, file, line, function,
819 output_local, output_extern);
826 collection::const_iterator pos, end =
m_modules.end();
827 for (pos =
m_modules.begin(); pos != end; ++pos) {
829 if (module_sp->MatchesModuleSpec(module_spec))
851 if (log !=
nullptr) {
853 collection::const_iterator pos, begin =
m_modules.begin(),
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),
862 module_file_spec.
GetPath().c_str());
871 if (module_sp->ResolveFileAddress(vm_addr, so_addr))
880 SymbolContextItem resolve_scope,
883 uint32_t resolved_flags = 0;
887 module_sp->ResolveSymbolContextForAddress(so_addr, resolve_scope, sc);
890 collection::const_iterator pos, end =
m_modules.end();
891 for (pos =
m_modules.begin(); pos != end; ++pos) {
893 (*pos)->ResolveSymbolContextForAddress(so_addr, resolve_scope, sc);
894 if (resolved_flags != 0)
899 return resolved_flags;
903 const char *file_path, uint32_t line,
bool check_inlines,
907 resolve_scope, sc_list);
911 const FileSpec &file_spec, uint32_t line,
bool check_inlines,
915 module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
916 resolve_scope, sc_list);
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);
939class SharedModuleList {
943 void FindModules(
const ModuleSpec &module_spec,
945 std::lock_guard<std::recursive_mutex> guard(GetMutex());
948 FindModulesInMap(module_spec, matching_module_list);
949 if (!matching_module_list.
IsEmpty())
951 m_list.FindModules(module_spec, matching_module_list);
956 assert((matching_module_list.
IsEmpty() ||
962 "Search by name not found in SharedModuleList's map");
967 std::lock_guard<std::recursive_mutex> guard(GetMutex());
968 if (
ModuleSP result = FindModuleInMap(module))
970 return m_list.FindModule(&module);
974 ModuleSP FindModule(
const UUID &uuid)
const {
975 return m_list.FindModule(uuid);
978 void Append(
const ModuleSP &module_sp,
bool use_notifier) {
981 std::lock_guard<std::recursive_mutex> guard(GetMutex());
982 m_list.Append(module_sp, use_notifier);
986 size_t RemoveOrphans(
bool mandatory) {
987 std::unique_lock<std::recursive_mutex> lock(GetMutex(), std::defer_lock);
991 if (!lock.try_lock())
994 size_t total_count = 0;
1000 run_count = RemoveOrphansFromMapAndList();
1001 run_count += m_list.RemoveOrphans(mandatory);
1002 total_count += run_count;
1005 }
while (run_count != 0);
1010 bool Remove(
const ModuleSP &module_sp,
bool use_notifier =
true) {
1013 std::lock_guard<std::recursive_mutex> guard(GetMutex());
1014 RemoveFromMap(module_sp);
1015 return m_list.Remove(module_sp, use_notifier);
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);
1025 bool RemoveIfOrphaned(
const ModuleWP module_wp) {
1026 std::lock_guard<std::recursive_mutex> guard(GetMutex());
1027 RemoveFromMap(module_wp,
true);
1028 return m_list.RemoveIfOrphaned(module_wp);
1031 std::recursive_mutex &GetMutex()
const {
return m_list.GetMutex(); }
1037 llvm::StringRef name =
module.GetFileSpec().GetFilename();
1038 auto it = m_name_to_modules.find(name);
1039 if (it == m_name_to_modules.end())
1041 const llvm::SmallVectorImpl<ModuleSP> &vector = it->second;
1042 for (
const ModuleSP &module_sp : vector) {
1043 if (module_sp.get() == &module)
1049 void FindModulesInMap(
const ModuleSpec &module_spec,
1050 ModuleList &matching_module_list)
const {
1052 if (it == m_name_to_modules.end())
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);
1061 void AddToMap(
const ModuleSP &module_sp) {
1062 llvm::StringRef name = module_sp->GetFileSpec().GetFilename();
1065 m_name_to_modules[name].push_back(module_sp);
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))
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()) {
1078 constexpr long kUseCountOrphaned =
1079 kUseCountSharedModuleListOrphaned + 1;
1080 if (!if_orphaned || it->use_count() == kUseCountOrphaned) {
1089 void ReplaceEquivalentInMap(
const ModuleSP &module_sp) {
1090 RemoveEquivalentModulesFromMap(module_sp);
1091 AddToMap(module_sp);
1094 void RemoveEquivalentModulesFromMap(
const ModuleSP &module_sp) {
1095 llvm::StringRef name = module_sp->GetFileSpec().GetFilename();
1099 auto it = m_name_to_modules.find(name);
1100 if (it == m_name_to_modules.end())
1105 ModuleSpec equivalent_module_spec(module_sp->GetFileSpec(),
1106 module_sp->GetArchitecture());
1107 equivalent_module_spec.GetPlatformFileSpec() =
1108 module_sp->GetPlatformFileSpec();
1110 llvm::SmallVectorImpl<ModuleSP> &vec = it->second;
1111 llvm::erase_if(vec, [&equivalent_module_spec](
ModuleSP &element) {
1112 return element->MatchesModuleSpec(equivalent_module_spec);
1117 ModuleList RemoveOrphansFromVector(llvm::SmallVectorImpl<ModuleSP> &vec) {
1120 auto *to_remove_start = llvm::remove_if(vec, [](
const ModuleSP &module) {
1121 return module.use_count() == kUseCountSharedModuleListOrphaned;
1124 ModuleList to_remove;
1125 for (
ModuleSP *it = to_remove_start; it != vec.end(); ++it)
1126 to_remove.Append(*it);
1128 vec.erase(to_remove_start, vec.end());
1136 int RemoveOrphansFromMapAndList() {
1140 int remove_count = 0;
1141 int previous_remove_count;
1143 previous_remove_count = remove_count;
1144 for (
auto &[name, vec] : m_name_to_modules) {
1147 ModuleList to_remove = RemoveOrphansFromVector(vec);
1148 remove_count += to_remove.
GetSize();
1149 m_list.Remove(to_remove);
1152 }
while (previous_remove_count != remove_count);
1154 return remove_count;
1161 llvm::StringMap<llvm::SmallVector<ModuleSP, 1>> m_name_to_modules;
1164 static constexpr long kUseCountSharedModuleListOrphaned = 2;
1167struct SharedModuleListInfo {
1168 SharedModuleList module_list;
1169 ModuleListProperties module_list_properties;
1173 static SharedModuleListInfo *g_shared_module_list_info =
nullptr;
1174 static llvm::once_flag g_once_flag;
1175 llvm::call_once(g_once_flag, []() {
1179 if (g_shared_module_list_info ==
nullptr)
1180 g_shared_module_list_info =
new SharedModuleListInfo();
1182 return *g_shared_module_list_info;
1196 return shared_module_list.FindModule(*module_ptr).get() !=
nullptr;
1217 bool *did_create_ptr,
bool invoke_locate_callback,
1218 bool invoke_symbol_locators) {
1220 std::lock_guard<std::recursive_mutex> guard(shared_module_list.GetMutex());
1228 *did_create_ptr =
false;
1239 shared_module_list.FindModules(module_spec, matching_module_list);
1240 const size_t num_matching_modules = matching_module_list.
GetSize();
1242 if (num_matching_modules > 0) {
1243 for (
size_t module_idx = 0; module_idx < num_matching_modules;
1248 if (module_sp->FileHasChanged()) {
1250 old_modules->push_back(module_sp);
1255 "{0:x} '{1}' module changed: removing from global module list",
1256 static_cast<void *
>(module_sp.get()),
1257 module_sp->GetFileSpec().GetFilename());
1259 shared_module_list.Remove(module_sp);
1277 if (invoke_locate_callback) {
1280 if (target_sp->IsValid())
1281 platform_sp = target_sp->GetPlatform();
1288 platform_sp->CallLocateModuleCallbackIfSet(
1289 module_spec, module_sp, symbol_file_spec, did_create_ptr);
1297 module_sp = std::make_shared<Module>(module_spec);
1301 if (module_sp->GetObjectFile()) {
1304 if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) {
1307 if (module_sp->GetObjectFile() && module_sp->GetObjectFile()->GetType() ==
1311 if (did_create_ptr) {
1312 *did_create_ptr =
true;
1315 shared_module_list.ReplaceEquivalent(module_sp, old_modules);
1327 module_search_paths = target_sp->GetExecutableSearchPaths();
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) {
1334 namespace fs = llvm::sys::fs;
1337 search_path_spec.AppendPathComponent(
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()) {
1348 if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) {
1351 if (module_sp->GetObjectFile()->GetType() ==
1356 *did_create_ptr =
true;
1358 shared_module_list.ReplaceEquivalent(module_sp, old_modules);
1371 if (!invoke_symbol_locators) {
1372 std::string uuid_str;
1373 if (uuid_ptr && uuid_ptr->
IsValid())
1375 if (!uuid_str.empty())
1377 "cannot locate module for UUID '{}'", uuid_str);
1386 module_spec, symbol_locator_map);
1389 if (located_binary_modulespec.
GetFileSpec() != module_file_spec) {
1393 if (path[0] ==
'\0')
1394 module_file_spec.
GetPath(path,
sizeof(path));
1399 std::string uuid_str;
1400 if (uuid_ptr && uuid_ptr->
IsValid())
1404 if (!uuid_str.empty())
1406 "'%s' does not contain the %s architecture and UUID %s", path,
1410 "'%s' does not contain the %s architecture.", path,
1424 ModuleSpec platform_module_spec(module_spec);
1432 shared_module_list.FindModules(platform_module_spec, matching_module_list);
1433 if (!matching_module_list.
IsEmpty()) {
1438 if (platform_module_spec.
GetUUIDPtr() ==
nullptr) {
1441 if (file_spec_mod_time != llvm::sys::TimePoint<>()) {
1442 if (file_spec_mod_time != module_sp->GetModificationTime()) {
1444 old_modules->push_back(module_sp);
1445 shared_module_list.Remove(module_sp);
1453 module_sp = std::make_shared<Module>(platform_module_spec);
1458 if (module_sp && module_sp->GetObjectFile()) {
1459 module_sp->GetSymbolLocatorStatistics().merge(symbol_locator_map);
1460 if (module_sp->GetObjectFile()->GetType() ==
1465 *did_create_ptr =
true;
1467 shared_module_list.ReplaceEquivalent(module_sp, old_modules);
1475 "unable to open %s architecture in '%s'",
1481 std::string uuid_str;
1482 if (uuid_ptr && uuid_ptr->
IsValid())
1485 if (!uuid_str.empty())
1487 "cannot locate a module for UUID '%s'", uuid_str.c_str());
1509 assert(scripting_fspec);
1516 nullptr, {}, target.shared_from_this());
1530 if (!script_interpreter) {
1542 llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile> file_specs =
1543 platform_sp->LocateExecutableScriptingResources(&target, module,
1546 if (!feedback_stream.
Empty())
1549 const bool trusted = platform_sp->IsSymbolFileTrusted(module);
1551 llvm::SmallVector<const FileSpec *> scripts_to_load;
1552 for (
const auto &[scripting_fspec, load_style] : file_specs) {
1559 switch (load_style) {
1561 llvm_unreachable(
"case already handled");
1572R
"('{0}' contains {1} debug script. To run this script in this debug session:
1574 command script import "{2}"
1576To run all discovered debug scripts in this session:
1578 settings set target.load-script-from-symbol-file true
1582 trusted ?
"a trusted" :
"an untrusted",
1583 scripting_fspec.GetPath()),
1589 scripts_to_load.push_back(&scripting_fspec);
1599 for (
const FileSpec *scripting_fspec : scripts_to_load) {
1600 LLDB_LOG(log,
"Auto-loading {0}", scripting_fspec->GetPath());
1604 LLDB_LOG(log,
"Failed to load '{0}'. Remaining scripts won't be loaded.",
1605 scripting_fspec->GetPath());
1621 std::list<Status> &errors,
1622 bool continue_on_error) {
1638 "unable to load scripting data for "
1639 "module {0} - error reported was {1}",
1642 errors.push_back(std::move(
error));
1643 if (!continue_on_error)
1649 return errors.empty();
1657 assert(module_sp !=
nullptr);
1667 for (
const auto &module_sp :
m_modules) {
1668 assert(module_sp !=
nullptr);
1669 if (callback(*module_sp))
1678 std::scoped_lock<std::recursive_mutex, std::recursive_mutex> lock(
1694 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 GetEnableTypeSystemClike() const
bool GetLLDBIndexCacheForceDisable() const
bool SetClangModulesCachePath(const FileSpec &path)
lldb::SymbolDownload GetSymbolAutoDownload() const
bool GetEnableExternalLookup() const
bool GetLLDBIndexCacheTypeMemoryModuleHeaderBytes() 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
lldb::OptionValuePropertiesSP m_experimental_properties_sp
void ForwardDeprecatedIndexCacheSettings()
Make the deprecated "symbols.*lldb-index-cache*" settings set their replacements in "symbols....
FileSpec GetClangModulesCachePath() const
bool GetLLDBIndexCacheTypeSymtab() const
llvm::sys::RWMutex m_symlink_paths_mutex
lldb::OptionValuePropertiesSP m_index_cache_type_sp
The "symbols.lldb-index-cache.type" settings.
bool GetLLDBIndexCacheTypeDwarfIndex() const
uint64_t GetLLDBIndexCacheMaxPercent()
void UpdateSymlinkMappings()
bool SetEnableTypeSystemClike(bool new_value)
uint64_t GetLLDBIndexCacheExpirationDays()
bool GetLLDBIndexCacheTypeMemoryModuleSymtab() const
lldb::OptionValuePropertiesSP m_index_cache_sp
The "symbols.lldb-index-cache" settings.
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)
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
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 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.
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 ®ex, 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()
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.
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.
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.
void RunCollectedInitialStopHooks()
Run the collected stop hooks and hooks that were added with –at-initial-stop if the process is stoppe...
bool RecordScriptingResources(Module &module)
Record that we're auto-loading module's scripts in this target, so we only load them once.
Debugger & GetDebugger() const
bool IsCollectingHooks() 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
std::shared_ptr< lldb_private::OptionValue > OptionValueSP
Options used by Module::FindFunctions.
lldb::user_id_t GetID() const
Get accessor for the user ID.