Go to the documentation of this file.
9 #ifndef LLDB_CORE_MODULE_H
10 #define LLDB_CORE_MODULE_H
31 #include "llvm/ADT/DenseSet.h"
32 #include "llvm/ADT/StringRef.h"
33 #include "llvm/Support/Chrono.h"
44 class CompilerDeclContext;
53 class SymbolContextList;
85 class Module :
public std::enable_shared_from_this<Module>,
126 const llvm::sys::TimePoint<> &object_mod_time = llvm::sys::TimePoint<>());
130 template <
typename ObjFilePlugin,
typename...
Args>
135 lldb::ModuleSP module_sp(
new Module());
136 module_sp->m_objfile_sp =
137 std::make_shared<ObjFilePlugin>(module_sp, std::forward<Args>(args)...);
138 module_sp->m_did_load_objfile.store(
true, std::memory_order_relaxed);
143 ArchSpec arch = module_sp->m_objfile_sp->GetArchitecture();
146 module_sp->m_arch = arch;
149 module_sp->m_file = module_sp->m_objfile_sp->GetFileSpec();
316 lldb::FunctionNameType name_type_mask,
360 std::vector<Address> &output_local,
361 std::vector<Address> &output_extern);
430 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
443 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
461 size_t max_matches,
TypeList &type_list);
545 Stream *feedback_stream =
nullptr);
622 size_t size_to_read = 512);
633 Stream *feedback_strm =
nullptr);
701 const Address &so_addr, lldb::SymbolContextItem resolve_scope,
744 const char *file_path,
uint32_t line,
bool check_inlines,
795 llvm::Expected<TypeSystem &>
804 __attribute__((format(printf, 3, 4)));
807 __attribute__((format(printf, 3, 4)));
810 __attribute__((format(printf, 2, 3)));
813 __attribute__((format(printf, 2, 3)));
818 __attribute__((format(printf, 2, 3)));
873 llvm::Optional<std::string>
RemapSourceFile(llvm::StringRef path)
const;
1029 lldb::SymbolVendorUP
1031 std::vector<lldb::SymbolVendorUP>
1098 bool vm_addr_is_file_addr,
1099 lldb::SymbolContextItem resolve_scope,
1103 std::vector<uint32_t> &symbol_indexes,
1122 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
1131 #endif // LLDB_CORE_MODULE_H
void SymbolIndicesToSymbolContextList(Symtab *symtab, std::vector< uint32_t > &symbol_indexes, SymbolContextList &sc_list)
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Provides public interface for all SymbolFiles.
static ModuleListProperties & GetGlobalModuleListProperties()
PathMappingList & GetSourceMappingList()
StatsDuration & GetSymtabIndexTime()
Accessor for the symbol table index time metric.
StatsDuration & GetSymtabParseTime()
Accessor for the symbol table parse time metric.
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
bool FileHasChanged() const
void FindFunctions(ConstString name, const CompilerDeclContext &parent_decl_ctx, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list)
Find functions by name.
PathMappingList GetSymlinkMappings() const
lldb::SymbolVendorUP m_symfile_up
A pointer to the symbol vendor for this module.
bool GetIsDynamicLinkEditor()
llvm::Optional< UnwindTable > m_unwind_table
Table of FuncUnwinders objects created for this Module's functions.
static DataFileCache * GetIndexCache()
Get the global index file cache.
llvm::Expected< TypeSystem & > GetTypeSystemForLanguage(lldb::LanguageType language)
const FileSpec & GetSymbolFileFileSpec() const
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...
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 SetName(ConstString name)
bool MergeArchitecture(const ArchSpec &arch_spec)
Update the ArchSpec to a more specific variant.
void ReportWarningUnsupportedLanguage(lldb::LanguageType language, llvm::Optional< lldb::user_id_t > debugger_id)
LanguageType
Programming language type.
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
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)
StatsDuration m_symtab_parse_time
See if the module was modified after it was initially opened.
bool include_symbols
Include the symbol table.
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 ...
void SetPlatformFileSpec(const FileSpec &file)
lldb::TypeSP FindFirstType(const SymbolContext &sc, ConstString type_name, bool exact_match)
~Module() override
Destructor.
lldb::ModuleSP CalculateSymbolContextModule() override
void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name)
uint32_t ResolveSymbolContextForFilePath(const char *file_path, 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.
void void void void ReportError(const char *format,...) __attribute__((format(printf
void void void void void ReportErrorIfModifyDetected(const char *format,...) __attribute__((format(printf
void SetNameTypeMask(lldb::FunctionNameType mask)
static Module * GetAllocatedModuleAtIndex(size_t idx)
lldb::LanguageType m_language
Limit matches to only be for this language.
bool include_inlines
Include inlined functions.
void void void void void void ReportWarningOptimization(llvm::Optional< lldb::user_id_t > debugger_id)
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.
void SetRemoteInstallFileSpec(const FileSpec &file)
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
std::atomic< bool > m_did_load_symfile
void SetSymbolFileFileSpec(const FileSpec &file)
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 void LogMessageVerboseBacktrace(Log *log, const char *format,...) __attribute__((format(printf
static llvm::raw_ostream & error(Stream &strm)
void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
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...
static lldb::ModuleSP CreateModuleFromObjectFile(Args &&...args)
llvm::sys::TimePoint m_object_mod_time
std::once_flag m_language_warning
lldb::FunctionNameType m_name_type_mask
One or more bits from lldb::FunctionNameType that indicate what kind of names we are looking for.
ConstString GetName() const
uint64_t GetObjectOffset() const
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.
SectionList * GetUnifiedSectionList()
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
llvm::VersionTuple GetVersion()
virtual void SectionFileAddressesChanged()
Notify the module that the file addresses for the Sections have been updated.
bool LoadScriptingResourceInTarget(Target *target, Status &error, Stream *feedback_stream=nullptr)
void LogMessage(Log *log, const char *format,...) __attribute__((format(printf
void SetLookupName(ConstString name)
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.
ConstString GetObjectName() const
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.
FileSpec m_remote_install_file
If set when debugging on remote platforms, this module will be installed at this location.
void void void ReportWarning(const char *format,...) __attribute__((format(printf
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
std::recursive_mutex & GetMutex() const
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.
Represents a generic declaration context in a program.
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.
const PathMappingList & GetSourceMappingList() const
std::vector< lldb::SymbolVendorUP > m_old_symfiles
If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file,.
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.
const FileSpec & GetRemoteInstallFileSpec() const
virtual SectionList * GetSectionList()
Get the unified section list for the module.
bool SetArchitecture(const ArchSpec &new_arch)
const Module & operator=(const Module &)=delete
ConstString GetLookupName() const
std::string GetSpecificationDescription() const
Get the module path and object name.
ConstString m_lookup_name
The actual name will lookup when calling in the object or symbol file.
@ eLanguageTypeUnknown
Unknown or invalid language value.
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
lldb::FunctionNameType GetNameTypeMask() const
std::string GetCacheKey()
Get a unique cache key for the current module.
void FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
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.
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)
ArchSpec m_arch
The architecture for this module.
bool m_match_name_after_lookup
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.
bool IsLoadedInTarget(Target *target)
Tells whether this module has been loaded in the target passed in.
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.
A class that represents a running process on the host machine.
StatsDuration m_symtab_index_time
We store a symbol named index time duration here because we might have an object file and a symbol fi...
static size_t GetNumberAllocatedModules()
llvm::Optional< std::string > RemapSourceFile(llvm::StringRef path) const
Remaps a source file given path into new_path.
const llvm::sys::TimePoint & GetObjectModificationTime() const
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 ...
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.
void FindFunctionSymbols(ConstString name, uint32_t name_type_mask, SymbolContextList &sc_list)
Find a function symbols in the object file's symbol table.
std::recursive_mutex m_mutex
A mutex to keep this object happy in multi-threaded environments.
static std::recursive_mutex & GetAllocationModuleCollectionMutex()
bool IsExecutable()
Tells whether this module is capable of being the main executable for a process.
const llvm::sys::TimePoint & GetModificationTime() const
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
std::atomic< bool > m_did_load_objfile