Go to the documentation of this file.
58 #include "llvm/ADT/STLExtras.h"
59 #include "llvm/Support/Compiler.h"
60 #include "llvm/Support/DJB.h"
61 #include "llvm/Support/FileSystem.h"
62 #include "llvm/Support/FormatVariadic.h"
63 #include "llvm/Support/JSON.h"
64 #include "llvm/Support/Signals.h"
65 #include "llvm/Support/raw_ostream.h"
74 #include <type_traits>
100 if (g_module_collection ==
nullptr)
103 return *g_module_collection;
106 std::recursive_mutex &Module::GetAllocationModuleCollectionMutex() {
112 static std::recursive_mutex *g_module_collection_mutex =
nullptr;
113 if (g_module_collection_mutex ==
nullptr)
114 g_module_collection_mutex =
new std::recursive_mutex;
115 return *g_module_collection_mutex;
118 size_t Module::GetNumberAllocatedModules() {
119 std::lock_guard<std::recursive_mutex> guard(
120 GetAllocationModuleCollectionMutex());
124 Module *Module::GetAllocatedModuleAtIndex(
size_t idx) {
125 std::lock_guard<std::recursive_mutex> guard(
126 GetAllocationModuleCollectionMutex());
128 if (idx < modules.size())
134 : m_file_has_changed(false), m_first_file_changed_log(false) {
137 std::lock_guard<std::recursive_mutex> guard(
144 LLDB_LOGF(log,
"%p Module::Module((%s) '%s%s%s%s')",
145 static_cast<void *
>(
this),
152 auto data_sp = module_spec.
GetData();
155 file_size = data_sp->GetByteSize();
161 module_spec.
GetFileSpec(), 0, file_size, modules_specs, data_sp) == 0)
173 matching_module_spec)) {
175 LLDB_LOGF(log,
"Found local object file but the specs didn't match");
183 if (
auto module_spec_data_sp = module_spec.
GetData()) {
237 const llvm::sys::TimePoint<> &object_mod_time)
238 : m_mod_time(
FileSystem::Instance().GetModificationTime(file_spec)),
239 m_arch(arch), m_file(file_spec), m_object_offset(object_offset),
240 m_object_mod_time(object_mod_time), m_file_has_changed(false),
241 m_first_file_changed_log(false) {
244 std::lock_guard<std::recursive_mutex> guard(
254 LLDB_LOGF(log,
"%p Module::Module((%s) '%s%s%s%s')",
261 std::lock_guard<std::recursive_mutex> guard(
269 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
272 std::lock_guard<std::recursive_mutex> guard(
275 ModuleCollection::iterator end = modules.end();
276 ModuleCollection::iterator pos = std::find(modules.begin(), end,
this);
282 LLDB_LOGF(log,
"%p Module::~Module((%s) '%s%s%s%s')",
298 size_t size_to_read) {
300 error.SetErrorString(
"object file already exists");
302 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
305 std::shared_ptr<DataBufferHeap> data_sp =
306 std::make_shared<DataBufferHeap>(size_to_read, 0);
308 const size_t bytes_read =
309 process_sp->ReadMemory(header_addr, data_sp->GetBytes(),
310 data_sp->GetByteSize(), readmem_error);
311 if (bytes_read < size_to_read)
312 data_sp->SetByteSize(bytes_read);
313 if (data_sp->GetByteSize() > 0) {
315 header_addr, data_sp);
318 s.
Printf(
"0x%16.16" PRIx64, header_addr);
330 error.SetErrorString(
"unable to find suitable object file plug-in");
333 error.SetErrorStringWithFormat(
"unable to read header from memory: %s",
337 error.SetErrorString(
"invalid process");
345 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
349 if (obj_file !=
nullptr) {
359 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
364 lldbassert(0 &&
"Attempting to overwrite the existing module UUID");
368 llvm::Expected<TypeSystemSP>
374 llvm::function_ref<
bool(lldb::TypeSystemSP)> callback) {
379 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
381 if (num_comp_units == 0)
386 for (
size_t cu_idx = 0; cu_idx < num_comp_units; cu_idx++) {
418 s->
Printf(
", Module{%p}",
static_cast<void *
>(
this));
422 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
424 return symbols->GetNumCompileUnits();
429 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
433 if (index < num_comp_units) {
435 cu_sp = symbols->GetCompileUnitAtIndex(index);
441 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
449 const Address &so_addr, lldb::SymbolContextItem resolve_scope,
451 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
462 if (section_sp && section_sp->GetModule().get() ==
this) {
466 resolved_flags |= eSymbolContextModule;
470 return resolved_flags;
474 if (resolve_scope & eSymbolContextCompUnit ||
475 resolve_scope & eSymbolContextFunction ||
476 resolve_scope & eSymbolContextBlock ||
477 resolve_scope & eSymbolContextLineEntry ||
478 resolve_scope & eSymbolContextVariable) {
486 if (resolve_scope & eSymbolContextSymbol &&
487 !(resolved_flags & eSymbolContextSymbol)) {
490 Symbol *matching_symbol =
nullptr;
494 [&matching_symbol](
Symbol *symbol) ->
bool {
495 if (symbol->GetType() != eSymbolTypeInvalid) {
496 matching_symbol = symbol;
501 sc.
symbol = matching_symbol;
502 if (!sc.
symbol && resolve_scope & eSymbolContextFunction &&
503 !(resolved_flags & eSymbolContextFunction)) {
504 bool verify_unique =
false;
509 obj_file->ResolveSymbolForAddress(so_addr, verify_unique);
520 if (symtab_objfile && symtab_objfile->
IsStripped()) {
522 if (symfile_objfile != symtab_objfile) {
524 if (symfile_symtab) {
535 resolved_flags |= eSymbolContextSymbol;
543 if (resolve_scope & eSymbolContextSymbol &&
544 !(resolved_flags & eSymbolContextSymbol) && resolve_tail_call_address &&
546 Address previous_addr = so_addr;
547 previous_addr.
Slide(-1);
549 bool do_resolve_tail_call_address =
false;
551 previous_addr, resolve_scope, sc, do_resolve_tail_call_address);
552 if (flags & eSymbolContextSymbol) {
554 if (sc.
GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0,
555 false, addr_range)) {
566 resolved_flags |= flags;
576 return resolved_flags;
580 const char *file_path,
uint32_t line,
bool check_inlines,
584 resolve_scope, sc_list);
590 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
592 "check_inlines = %s, resolve_scope = 0x%8.8x)",
593 file_spec.
GetPath().c_str(), line,
594 check_inlines ?
"yes" :
"no", resolve_scope);
601 check_inlines,
false);
603 symbols->ResolveSymbolContext(location_spec, resolve_scope, sc_list);
606 return sc_list.
GetSize() - initial_count;
613 symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches, variables);
628 for (
size_t i = 0; i < num_compile_units; ++i) {
638 FunctionNameType name_type_mask,
640 : m_name(name), m_lookup_name(), m_language(language) {
642 llvm::StringRef basename;
643 llvm::StringRef context;
645 if (name_type_mask & eFunctionNameTypeAuto) {
647 m_name_type_mask = eFunctionNameTypeFull;
651 m_name_type_mask = eFunctionNameTypeFull;
653 m_name_type_mask = eFunctionNameTypeFull;
658 m_name_type_mask |= eFunctionNameTypeSelector;
661 basename = cpp_method.GetBasename();
662 if (basename.empty()) {
665 m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
667 m_name_type_mask |= eFunctionNameTypeFull;
669 m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
673 m_name_type_mask = name_type_mask;
674 if (name_type_mask & eFunctionNameTypeMethod ||
675 name_type_mask & eFunctionNameTypeBase) {
679 if (cpp_method.IsValid()) {
680 basename = cpp_method.GetBasename();
682 if (!cpp_method.GetQualifiers().empty()) {
685 m_name_type_mask &= ~(eFunctionNameTypeBase);
686 if (m_name_type_mask == eFunctionNameTypeNone)
698 if (name_type_mask & eFunctionNameTypeSelector) {
700 m_name_type_mask &= ~(eFunctionNameTypeSelector);
701 if (m_name_type_mask == eFunctionNameTypeNone)
708 if (basename.empty()) {
709 if (name_type_mask & eFunctionNameTypeFull &&
712 basename = cpp_method.GetBasename();
713 if (basename.empty())
720 if (!basename.empty()) {
725 m_lookup_name.SetString(basename);
726 m_match_name_after_lookup =
true;
730 m_lookup_name = name;
731 m_match_name_after_lookup =
false;
742 if (
m_name == function_name)
750 const bool function_name_may_be_mangled =
751 Mangled::GetManglingScheme(function_name.
GetStringRef()) !=
752 Mangled::eManglingSchemeNone;
753 ConstString demangled_function_name = function_name;
754 if (function_name_may_be_mangled) {
755 Mangled mangled_function_name(function_name);
756 demangled_function_name = mangled_function_name.GetDemangledName();
764 demangled_function_name);
766 llvm::StringRef function_name_ref = demangled_function_name.
GetStringRef();
771 size_t start_idx)
const {
772 if (m_match_name_after_lookup && m_name) {
774 size_t i = start_idx;
775 while (i < sc_list.
GetSize()) {
792 if (m_name_type_mask == eFunctionNameTypeFull) {
794 size_t i = start_idx;
795 while (i < sc_list.
GetSize()) {
802 if (mangled_name != m_name && full_name != m_name) {
806 if (cpp_method.
GetBasename().compare(m_name.GetStringRef()) != 0) {
812 llvm::StringRef anon_prefix(
"(anonymous namespace)");
817 if (qualified_name != m_name.GetCString()) {
835 symbols->FindFunctions(lookup_info, parent_decl_ctx,
840 if (
Symtab *symtab = symbols->GetSymtab()) {
850 FunctionNameType name_type_mask,
853 const size_t old_size = sc_list.
GetSize();
855 FindFunctions(lookup_info, parent_decl_ctx, options, sc_list);
856 if (name_type_mask & eFunctionNameTypeAuto) {
857 const size_t new_size = sc_list.
GetSize();
858 if (old_size < new_size)
859 lookup_info.Prune(sc_list, old_size);
866 const size_t start_size = sc_list.
GetSize();
874 Symtab *symtab = symbols->GetSymtab();
876 std::vector<uint32_t> symbol_indexes;
880 const size_t num_matches = symbol_indexes.size();
883 const size_t end_functions_added_index = sc_list.
GetSize();
884 size_t num_functions_added_to_sc_list =
885 end_functions_added_index - start_size;
886 if (num_functions_added_to_sc_list == 0) {
889 for (
size_t i = 0; i < num_matches; ++i) {
897 typedef std::map<lldb::addr_t, uint32_t> FileAddrToIndexMap;
898 FileAddrToIndexMap file_addr_to_index;
899 for (
size_t i = start_size; i < end_functions_added_index; ++i) {
908 FileAddrToIndexMap::const_iterator end = file_addr_to_index.end();
911 for (
size_t i = start_size; i < num_matches; ++i) {
917 FileAddrToIndexMap::const_iterator pos =
918 file_addr_to_index.find(
923 sc_list[pos->second].symbol = sc.
symbol;
936 std::vector<Address> &output_local,
937 std::vector<Address> &output_extern) {
950 if (f && f ==
function)
951 output_local.push_back(addr);
953 output_extern.push_back(addr);
960 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
963 symbols->FindTypes(name, parent_decl_ctx, max_matches,
964 searched_symbol_files, types);
969 size_t max_matches,
TypeList &type_list) {
971 llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
972 FindTypes_Impl(type_name, parent_decl_ctx, max_matches, searched_symbol_files,
984 llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
985 FindTypes(name, exact_match, 1, searched_symbol_files, type_list);
992 ConstString name,
bool exact_match,
size_t max_matches,
993 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
995 const char *type_name_cstr = name.
GetCString();
996 llvm::StringRef type_scope;
997 llvm::StringRef type_basename;
998 TypeClass type_class = eTypeClassAny;
1007 exact_match = type_scope.consume_front(
"::");
1009 ConstString type_basename_const_str(type_basename);
1011 searched_symbol_files, typesmap);
1018 if (type_class != eTypeClassAny && !type_basename.empty()) {
1022 UINT_MAX, searched_symbol_files, typesmap);
1027 searched_symbol_files, typesmap);
1030 type_class, exact_match);
1042 llvm::ArrayRef<CompilerContext> pattern,
LanguageSet languages,
1043 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
1049 symbols->FindTypes(pattern, languages, searched_symbol_files, types);
1054 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1057 if (obj_file !=
nullptr) {
1070 return symbols->GetSymtab();
1114 s << llvm::formatv(
"({0})", object_name);
1129 std::optional<lldb::user_id_t> debugger_id) {
1136 <<
" was compiled with optimization - stepping may behave "
1137 "oddly; variables may not be available.";
1143 LanguageType language, std::optional<lldb::user_id_t> debugger_id) {
1145 ss <<
"This version of LLDB has no plugin for the language \""
1148 "Inspection of frame variables will be limited.";
1154 const llvm::formatv_object_base &payload) {
1163 strm.
PutCString(
"The debug session should be aborted as the original "
1164 "debug information has been overwritten.");
1195 Log *log,
const llvm::formatv_object_base &payload) {
1202 llvm::raw_string_ostream stream(back_trace);
1203 llvm::sys::PrintStackTrace(stream);
1210 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1234 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1275 if (obj_file !=
nullptr)
1286 symbols->SectionFileAddressesChanged();
1307 "Module::FindFirstSymbolWithNameAndType (name = %s, type = %i)",
1310 return symtab->FindFirstSymbolWithNameAndType(
1315 Symtab *symtab, std::vector<uint32_t> &symbol_indexes,
1320 size_t num_indices = symbol_indexes.size();
1321 if (num_indices > 0) {
1324 for (
size_t i = 0; i < num_indices; i++) {
1337 symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
1346 std::vector<uint32_t> symbol_indexes;
1347 symtab->FindAllSymbolsWithNameAndType(name, symbol_type, symbol_indexes);
1358 "Module::FindSymbolsMatchingRegExAndType (regex = %s, type = %i)",
1359 regex.
GetText().str().c_str(), symbol_type);
1361 std::vector<uint32_t> symbol_indexes;
1362 symtab->FindAllSymbolsMatchingRexExAndType(
1364 symbol_indexes, mangling_preference);
1370 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1378 symtab->PreloadSymbols();
1393 if (section_list && symbol_file) {
1423 if (llvm::StringRef(old_path).startswith(new_path)) {
1432 for (
size_t idx = num_sections; idx > 0; --idx) {
1433 lldb::SectionSP section_sp(
1435 if (section_sp->GetObjectFile() == obj_file) {
1462 if (sections !=
nullptr) {
1463 size_t num_sections = sections->
GetSize();
1464 for (
size_t sect_idx = 0; sect_idx < num_sections; sect_idx++) {
1476 Stream *feedback_stream) {
1478 error.SetErrorString(
"invalid destination Target");
1483 target->TargetProperties::GetLoadScriptFromSymbolFile();
1495 error.SetErrorString(
"invalid Platform");
1499 FileSpecList file_specs = platform_sp->LocateExecutableScriptingResources(
1500 target, *
this, feedback_stream);
1502 const uint32_t num_specs = file_specs.GetSize();
1505 if (script_interpreter) {
1506 for (
uint32_t i = 0; i < num_specs; ++i) {
1507 FileSpec scripting_fspec(file_specs.GetFileSpecAtIndex(i));
1508 if (scripting_fspec &&
1511 if (feedback_stream)
1513 "warning: '%s' contains a debug script. To run this script "
1515 "this debug session:\n\n command script import "
1517 "To run all discovered debug scripts in this session:\n\n"
1518 " settings set target.load-script-from-symbol-file "
1520 GetFileSpec().GetFileNameStrippingExtension().GetCString(),
1521 scripting_fspec.
GetPath().c_str());
1534 error.SetErrorString(
"invalid ScriptInterpreter");
1551 bool value_is_offset,
bool &changed) {
1553 if (object_file !=
nullptr) {
1554 changed = object_file->
SetLoadAddress(target, value, value_is_offset);
1595 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1597 new_spec = *remapped;
1604 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1606 return remapped->GetPath();
1611 llvm::StringRef sysroot) {
1613 auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(sdk);
1615 if (!sdk_path_or_err) {
1617 toString(sdk_path_or_err.takeError()));
1621 auto sdk_path = *sdk_path_or_err;
1622 if (sdk_path.empty())
1635 "module has arch %s, merging/replacing with arch %s",
1637 arch_spec.
GetTriple().getTriple().c_str());
1653 return obj_file->GetVersion();
1654 return llvm::VersionTuple();
1668 llvm::raw_string_ostream id_strm(identifier);
1677 return llvm::djbHash(id_strm.str());
1682 llvm::raw_string_ostream strm(key);
1686 strm <<
'-' << llvm::format_hex(
Hash(), 10);
1697 .GetLLDBIndexCachePath()
1699 return g_data_file_cache;
const char * toString(AppleArm64ExceptionClass EC)
void SymbolIndicesToSymbolContextList(Symtab *symtab, std::vector< uint32_t > &symbol_indexes, SymbolContextList &sc_list)
Address & GetBaseAddress()
Get accessor for the base address of the range.
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
static void DownloadSymbolFileAsync(const UUID &uuid)
Locate the symbol file for the given UUID on a background thread.
Provides public interface for all SymbolFiles.
Block * block
The Block for a given query.
void ReportError(const char *format, Args &&...args)
CompileUnit * comp_unit
The CompileUnit for a given query.
static ModuleListProperties & GetGlobalModuleListProperties()
#define LLDB_SCOPED_TIMERF(...)
ScriptLanguage
Script interpreter types.
virtual void CreateSections(SectionList &unified_section_list)=0
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
FileSpec & GetPlatformFileSpec()
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
bool FileHasChanged() const
virtual void ResolveAddress(SearchFilter &filter)
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
lldb::SymbolVendorUP m_symfile_up
A pointer to the symbol vendor for this module.
Function * CalculateSymbolContextFunction() const
const AddressRange & GetAddressRange()
bool GetIsDynamicLinkEditor()
static size_t GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, lldb::offset_t file_size, ModuleSpecList &specs, lldb::DataBufferSP data_sp=lldb::DataBufferSP())
bool ValueIsAddress() const
static DataFileCache * GetIndexCache()
Get the global index file cache.
std::optional< FileSpec > FindFile(const FileSpec &orig_spec) const
Finds a source file given a file spec using the path remappings.
bool GetAddressRange(uint32_t scope, uint32_t range_idx, bool use_inline_block_range, AddressRange &range) const
Get the address range contained within a symbol context.
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
void ParseAllDebugSymbols()
A debugging function that will cause everything in a module to be parsed.
FileSpec m_platform_file
The path to the module on the platform on which it is being debugged.
lldb::ObjectFileSP m_objfile_sp
A shared pointer to the object file parser for this module as it may or may not be shared with the Sy...
virtual bool LoadScriptingModule(const char *filename, const LoadScriptOptions &options, lldb_private::Status &error, StructuredData::ObjectSP *module_sp=nullptr, FileSpec extra_search_dir={})
#define LLDB_LOGF(log,...)
void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, VariableList &variable_list)
Find global and static variables by name.
ConstString m_name
What the user originally typed.
void MergeFrom(const ArchSpec &other)
Merges fields from another ArchSpec into this ArchSpec.
virtual size_t ParseFunctions(CompileUnit &comp_unit)=0
@ eLoadScriptFromSymFileFalse
virtual size_t ParseBlocksRecursive(Function &func)=0
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
ConstString & GetObjectName()
lldb::DataBufferSP GetData() const
static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file_spec, lldb::offset_t file_offset, lldb::offset_t file_size, lldb::DataBufferSP &data_sp, lldb::offset_t &data_offset)
Find a ObjectFile plug-in that can parse file_spec.
bool MergeArchitecture(const ArchSpec &arch_spec)
Update the ArchSpec to a more specific variant.
std::vector< Module * > ModuleCollection
virtual bool IsExecutable() const =0
Tells whether this object file is capable of being the main executable for a process.
An abstraction for Xcode-style SDKs that works like ArchSpec.
std::string GetScopeQualifiedName()
LanguageType
Programming language type.
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
llvm::StringRef GetBasename()
llvm::StringRef GetContext()
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const ConstString & GetFilename() const
Filename string const get accessor.
uint32_t Hash()
Get a unique hash for this module.
void FindTypes_Impl(ConstString name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, llvm::DenseSet< lldb_private::SymbolFile * > &searched_symbol_files, TypeMap &types)
static bool IsPossibleObjCSelector(const char *name)
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language, Module *module, bool can_create)
std::optional< UnwindTable > m_unwind_table
Table of FuncUnwinders objects created for this Module's functions.
llvm::Triple & GetTriple()
Architecture triple accessor.
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
Symbol * SymbolAtIndex(size_t idx)
void SortTypeList(TypeMap &type_map, TypeList &type_list) const
Sorts the types in TypeMap according to SymbolContext to TypeList.
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
bool include_symbols
Include the symbol table.
lldb::ScriptLanguage GetScriptLanguage() const
std::once_flag m_optimization_warning
void RegisterXcodeSDK(llvm::StringRef sdk, llvm::StringRef sysroot)
This callback will be called by SymbolFile implementations when parsing a compile unit that contains ...
static bool ExtractContextAndIdentifier(const char *name, llvm::StringRef &context, llvm::StringRef &identifier)
lldb::TypeSP FindFirstType(const SymbolContext &sc, ConstString type_name, bool exact_match)
size_t GetNumSections(uint32_t depth) const
~Module() override
Destructor.
lldb::ModuleSP CalculateSymbolContextModule() override
void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name)
llvm::StringRef GetString() const
FileSpec & GetSymbolFileSpec()
void ForEachTypeSystem(llvm::function_ref< bool(lldb::TypeSystemSP)> callback)
Call callback for each TypeSystem in this Module.
bool include_inlines
Include inlined functions.
void FindTypesInNamespace(ConstString type_name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, TypeList &type_list)
Find types by name that are in a namespace.
@ eLoadScriptFromSymFileWarn
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
std::atomic< bool > m_did_load_symfile
void SetSymbolFileFileSpec(const FileSpec &file)
Symtab * GetSymtab()
Gets the symbol table for the currently selected architecture (and object for archives).
lldb::PlatformSP GetPlatform()
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
lldb::SectionListUP m_sections_up
Unified section list for module that is used by the ObjectFile and and ObjectFile instances for the d...
void ReportWarningUnsupportedLanguage(lldb::LanguageType language, std::optional< lldb::user_id_t > debugger_id)
static llvm::raw_ostream & error(Stream &strm)
Symbol * symbol
The Symbol for a given query.
virtual bool GetIsDynamicLinkEditor()
Return true if this file is a dynamic link editor (dyld)
bool NameMatchesLookupInfo(ConstString function_name, lldb::LanguageType language_type=lldb::eLanguageTypeUnknown) const
void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
void SetString(const llvm::StringRef &s)
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
UUID m_uuid
Each module is assumed to have a unique identifier to help match it up to debug symbols.
ConstString m_object_name
The name an object within this module that is selected, or empty of the module is represented by m_fi...
llvm::sys::TimePoint & GetObjectModificationTime()
bool IsEmpty() const
Test for empty string.
static bool LanguageIsC(lldb::LanguageType language)
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
static ModuleCollection & GetModuleCollection()
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language)
llvm::sys::TimePoint m_object_mod_time
void RemoveMismatchedTypes(llvm::StringRef type_scope, llvm::StringRef type_basename, lldb::TypeClass type_class, bool exact_match)
std::once_flag m_language_warning
void FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, lldb::SymbolType symbol_type, SymbolContextList &sc_list, Mangled::NamePreference mangling_preference=Mangled::ePreferDemangled)
const char * GetData() const
virtual size_t ParseTypes(CompileUnit &comp_unit)=0
Function * function
The Function for a given query.
lldb::addr_t GetFileAddress() const
Get the file address.
uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list)
Resolve items in the symbol context for a given file and line.
Address & GetAddressRef()
AddressRange & GetAddressRangeAtIndex(size_t idx)
void ReportErrorIfModifyDetected(const char *format, Args &&...args)
virtual UUID GetUUID()=0
Gets the UUID for this object file.
SectionList * GetUnifiedSectionList()
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
llvm::VersionTuple GetVersion()
uint32_t GetSize() const
Get accessor for a symbol context list size.
size_t GetNumberOfAddresses()
bool LoadScriptingResourceInTarget(Target *target, Status &error, Stream *feedback_stream=nullptr)
virtual void SectionFileAddressesChanged()
Notify the module that the file addresses for the Sections have been updated.
static bool LanguageIsObjC(lldb::LanguageType language)
uint64_t GetByteSize(const FileSpec &file_spec) const
Returns the on-disk size of the given file in bytes.
Symbol * FindSymbolContainingFileAddress(lldb::addr_t file_addr)
ConstString GetFunctionName(Mangled::NamePreference preference=Mangled::ePreferDemangled) const
Find a name of the innermost function for the symbol context.
ObjectFile * GetMemoryObjectFile(const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, Status &error, size_t size_to_read=512)
Load an object file from memory.
lldb::SectionSP GetSectionAtIndex(size_t idx) const
ConstString GetObjectName() const
llvm::sys::TimePoint GetModificationTime(const FileSpec &file_spec) const
Returns the modification time of the given file.
#define LLDB_SCOPED_TIMER()
bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset, bool &changed)
Set the load address for all sections in a module to be the file address plus slide.
const FileSpec & GetPrimaryFile() const
Return the primary source file associated with this compile unit.
void FindFunctions(const LookupInfo &lookup_info, const CompilerDeclContext &parent_decl_ctx, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list)
Find functions by lookup info.
bool Replace(llvm::StringRef path, llvm::StringRef replacement, bool notify)
string(SUBSTRING ${p} 10 -1 pStripped) if($
lldb::DataBufferSP m_data_sp
DataBuffer containing the module image, if it was provided at construction time.
bool m_first_file_changed_log
virtual bool IsStripped()=0
Detect if this object file has been stripped of local symbols.
bool IsValid() const
Tests if this ArchSpec is valid.
bool FindMatchingModuleSpec(const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
lldb::SectionSP GetSection() const
Get const accessor for the section.
void Append(llvm::StringRef path, llvm::StringRef replacement, bool notify)
UnwindTable & GetUnwindTable()
Returns a reference to the UnwindTable for this Module.
llvm::sys::TimePoint m_mod_time
The modification time for this module when it was created.
virtual void Dump(Stream *s)=0
Dump a description of this object to a Stream.
static SymbolVendor * FindPlugin(const lldb::ModuleSP &module_sp, Stream *feedback_strm)
bool DeleteSection(size_t idx)
Represents a generic declaration context in a program.
static Language * FindPlugin(lldb::LanguageType language)
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list)
Find compile units by partial or full path.
size_t GetNumCompileUnits()
Get the number of compile units for this module.
Options used by Module::FindFunctions.
std::vector< lldb::SymbolVendorUP > m_old_symfiles
If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file,.
virtual void PreloadSymbols()
FileSpec m_symfile_spec
If this path is valid, then this is the file that will be used as the symbol file for this module.
void ForeachFunction(llvm::function_ref< bool(const lldb::FunctionSP &)> lambda) const
Apply a lambda to each function in this compile unit.
virtual SectionList * GetSectionList()
Get the unified section list for the module.
bool SetArchitecture(const ArchSpec &new_arch)
ConstString GetLookupName() const
std::string GetSpecificationDescription() const
Get the module path and object name.
std::optional< std::string > RemapSourceFile(llvm::StringRef path) const
Remaps a source file given path into new_path.
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
@ eLanguageTypeUnknown
Unknown or invalid language value.
void IndentMore(unsigned amount=2)
Increment the current indentation level.
void LogMessageVerboseBacktrace(Log *log, const char *format, Args &&...args)
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
virtual void SetLoadDebugInfoEnabled()
Specify debug info should be loaded.
lldb::FunctionNameType GetNameTypeMask() const
std::string GetCacheKey()
Get a unique cache key for the current module.
virtual void ClearSymtab()
Frees the symbol table.
bool ResolveAddressUsingFileSections(lldb::addr_t addr, const SectionList *sections)
Resolve a file virtual address using a section list.
uint32_t AppendSymbolIndexesMatchingRegExAndType(const RegularExpression ®ex, lldb::SymbolType symbol_type, std::vector< uint32_t > &indexes, Mangled::NamePreference name_preference=Mangled::ePreferDemangled)
uint32_t ResolveSymbolContextForAddress(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc, bool resolve_tail_call_address=false)
Resolve the symbol context for the given address.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
void SetUUID(const lldb_private::UUID &uuid)
bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const
Finds a source file given a file spec using the module source path remappings (if any).
bool MatchesModuleSpec(const ModuleSpec &module_ref)
virtual bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset)
Sets the load address for an entire module, assuming a rigid slide of sections, if possible in the im...
lldb::ModuleSP module_sp
The Module for a given query.
void Dump(llvm::raw_ostream &s) const
Dump this object to a Stream.
ArchSpec m_arch
The architecture for this module.
#define LLDB_INVALID_ADDRESS
const char * GetCString() const
Get the string value as a C string.
ArchSpec & GetArchitecture()
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.
TypeSystemMap m_type_system_map
A map of any type systems associated with this module.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
bool IsLoadedInTarget(Target *target)
Tells whether this module has been loaded in the target passed in.
static FileSystem & Instance()
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
This class enables data to be cached into a directory using the llvm caching code.
void FindTypes(ConstString type_name, bool exact_match, size_t max_matches, llvm::DenseSet< lldb_private::SymbolFile * > &searched_symbol_files, TypeList &types)
Find types by name.
void Clear(bool clear_target)
Clear the object's state.
static bool IsCPPMangledName(llvm::StringRef name)
virtual lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx)=0
A class that represents a running process on the host machine.
lldb::LanguageType GetLanguage() const
virtual uint32_t ResolveSymbolContext(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc)=0
void ReportWarningOptimization(std::optional< lldb::user_id_t > debugger_id)
void LogMessage(Log *log, const char *format, Args &&...args)
virtual Symtab * GetSymtab()=0
bool IsSectionOffset() const
Check if an address is section offset.
lldb::addr_t GetOffset() const
Get the section relative offset value.
static bool IsPossibleObjCMethodName(const char *name)
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
void Prune(SymbolContextList &sc_list, size_t start_idx) const
const Symbol * FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type=lldb::eSymbolTypeAny)
Find a symbol in the object file's symbol table.
PathMappingList m_source_mappings
Module specific source remappings for when you have debug info for a module that doesn't match where ...
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
const lldb_private::UUID & GetUUID()
Get a reference to the UUID value contained in this object.
void Dump(Stream *s)
Dump a description of this object to a Stream.
llvm::StringRef GetText() const
Access the regular expression text.
uint64_t GetObjectOffset() const
static const char * GetNameForLanguageType(lldb::LanguageType language)
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
void FindFunctionSymbols(ConstString name, uint32_t name_type_mask, SymbolContextList &sc_list)
Find a function symbols in the object file's symbol table.
virtual void SectionFileAddressesChanged()
Notify the ObjectFile that the file addresses in the Sections for this module have been changed.
virtual ObjectFile * GetObjectFile()=0
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
std::recursive_mutex m_mutex
A mutex to keep this object happy in multi-threaded environments.
lldb::SymbolType GetType() const
bool Slide(int64_t offset)
ObjectFile * GetObjectFile() const
virtual void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, VariableList &variables)
static std::recursive_mutex & GetAllocationModuleCollectionMutex()
void ReportWarning(const char *format, Args &&...args)
void ForEach(std::function< bool(lldb::TypeSystemSP)> const &callback)
bool IsExecutable()
Tells whether this module is capable of being the main executable for a process.
virtual size_t ParseVariablesForContext(const SymbolContext &sc)=0
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx)
FileSpec m_file
The file representation on disk for this module (if there is one).
std::atomic< bool > m_did_set_uuid
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
void ForEachSymbolContainingFileAddress(lldb::addr_t file_addr, std::function< bool(Symbol *)> const &callback)
bool RemoveContextAtIndex(size_t idx)
bool RemapPath(ConstString path, ConstString &new_path) const
void PutCString(const char *cstr)
std::atomic< bool > m_did_load_objfile
static bool GetTypeScopeAndBasename(llvm::StringRef name, llvm::StringRef &scope, llvm::StringRef &basename, lldb::TypeClass &type_class)