9#ifndef LLDB_CORE_MODULE_H
10#define LLDB_CORE_MODULE_H
31#include "llvm/ADT/DenseSet.h"
32#include "llvm/ADT/STLFunctionalExtras.h"
33#include "llvm/ADT/StableHashing.h"
34#include "llvm/ADT/StringRef.h"
35#include "llvm/Support/Chrono.h"
47class CompilerDeclContext;
56class SymbolContextList;
88class Module :
public std::enable_shared_from_this<Module>,
129 const llvm::sys::TimePoint<> &object_mod_time = llvm::sys::TimePoint<>());
133 template <
typename ObjFilePlugin,
typename...
Args>
139 module_sp->m_objfile_sp =
140 std::make_shared<ObjFilePlugin>(module_sp, std::forward<Args>(args)...);
141 module_sp->m_did_load_objfile.store(
true, std::memory_order_relaxed);
146 ArchSpec arch = module_sp->m_objfile_sp->GetArchitecture();
149 module_sp->m_arch = arch;
152 module_sp->m_file = module_sp->m_objfile_sp->GetFileSpec();
337 lldb::FunctionNameType name_type_mask,
343 lldb::FunctionNameType name_type_mask,
385 const FileSpec &file, uint32_t line,
387 std::vector<Address> &output_local,
388 std::vector<Address> &output_extern);
598 size_t size_to_read = 512);
609 Stream *feedback_strm =
nullptr);
677 const Address &so_addr, lldb::SymbolContextItem resolve_scope,
720 const char *file_path, uint32_t line,
bool check_inlines,
764 const FileSpec &file_spec, uint32_t line,
bool check_inlines,
771 llvm::Expected<lldb::TypeSystemSP>
783 template <
typename...
Args>
785 LogMessage(log, llvm::formatv(format, std::forward<Args>(args)...));
788 template <
typename...
Args>
792 log, llvm::formatv(format, std::forward<Args>(args)...));
795 template <
typename...
Args>
797 ReportWarning(llvm::formatv(format, std::forward<Args>(args)...));
800 template <
typename...
Args>
802 ReportError(llvm::formatv(format, std::forward<Args>(args)...));
807 template <
typename...
Args>
810 llvm::formatv(format, std::forward<Args>(args)...));
817 std::optional<lldb::user_id_t> debugger_id);
866 std::optional<std::string>
RemapSourceFile(llvm::StringRef path)
const;
1032 std::vector<lldb::SymbolVendorUP>
1065 llvm::DenseMap<llvm::stable_hash, std::unique_ptr<std::once_flag>>
1070 std::vector<uint32_t> &symbol_indexes,
1089 void LogMessage(
Log *log,
const llvm::formatv_object_base &payload);
1091 const llvm::formatv_object_base &payload);
1092 void ReportWarning(
const llvm::formatv_object_base &payload);
1093 void ReportError(
const llvm::formatv_object_base &payload);
static llvm::raw_ostream & error(Stream &strm)
A section + offset based address class.
An architecture specification class.
A command line argument class.
Represents a generic declaration context in a program.
A uniqued constant string class.
This class enables data to be cached into a directory using the llvm caching code.
A class that describes a function.
PathMappingList GetSymlinkMappings() const
A collection class for Module objects.
static ModuleListProperties & GetGlobalModuleListProperties()
A class that encapsulates name lookup information.
void SetName(ConstString name)
void SetNameTypeMask(lldb::FunctionNameType mask)
lldb::FunctionNameType GetNameTypeMask() const
void SetLookupName(ConstString name)
lldb::LanguageType GetLanguageType() const
ConstString GetLookupName() const
LookupInfo(ConstString name, lldb::FunctionNameType name_type_mask, lldb::LanguageType language)
ConstString m_lookup_name
The actual name will lookup when calling in the object or symbol file.
lldb::FunctionNameType m_name_type_mask
One or more bits from lldb::FunctionNameType that indicate what kind of names we are looking for.
bool NameMatchesLookupInfo(ConstString function_name, lldb::LanguageType language_type=lldb::eLanguageTypeUnknown) const
lldb::LanguageType m_language
Limit matches to only be for this language.
ConstString m_name
What the user originally typed.
ConstString GetName() const
void Prune(SymbolContextList &sc_list, size_t start_idx) const
bool m_match_name_after_lookup
A class that describes an executable image and its associated object and symbol files.
static lldb::ModuleSP CreateModuleFromObjectFile(Args &&...args)
const lldb_private::UUID & GetUUID()
Get a reference to the UUID value contained in this object.
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.
std::atomic< bool > m_did_set_uuid
void ReportWarningOptimization(std::optional< lldb::user_id_t > debugger_id)
Module(const Module &)=delete
PathMappingList m_source_mappings
Module specific source remappings for when you have debug info for a module that doesn't match where ...
llvm::sys::TimePoint m_object_mod_time
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, VariableList &variable_list)
Find global and static variables by name.
void ReportWarning(const char *format, Args &&...args)
FileSpec m_file
The file representation on disk for this module (if there is one).
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
static DataFileCache * GetIndexCache()
Get the global index file cache.
std::vector< lldb::SymbolVendorUP > m_old_symfiles
If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file,.
void ReportWarningUnsupportedLanguage(lldb::LanguageType language, std::optional< lldb::user_id_t > debugger_id)
const llvm::sys::TimePoint & GetObjectModificationTime() const
std::once_flag * GetDiagnosticOnceFlag(llvm::StringRef msg)
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list)
Find compile units by partial or full path.
ConstString GetObjectName() const
uint32_t Hash()
Get a unique hash for this module.
lldb::ModuleSP CalculateSymbolContextModule() override
static Module * GetAllocatedModuleAtIndex(size_t idx)
std::recursive_mutex m_diagnostic_mutex
UUID m_uuid
Each module is assumed to have a unique identifier to help match it up to debug symbols.
std::optional< std::string > RemapSourceFile(llvm::StringRef path) const
Remaps a source file given path into new_path.
const FileSpec & GetSymbolFileFileSpec() const
llvm::sys::TimePoint m_mod_time
The modification time for this module when it was created.
lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx)
FileSpec m_remote_install_file
If set when debugging on remote platforms, this module will be installed at this location.
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 SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name)
std::recursive_mutex m_mutex
A mutex to keep this object happy in multi-threaded environments.
static std::recursive_mutex & GetAllocationModuleCollectionMutex()
lldb::DataBufferSP m_data_sp
DataBuffer containing the module image, if it was provided at construction time.
void FindFunctions(llvm::ArrayRef< CompilerContext > compiler_ctx, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list)
Find functions by compiler context.
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.
void SetSymbolFileFileSpec(const FileSpec &file)
void RegisterXcodeSDK(llvm::StringRef sdk, llvm::StringRef sysroot)
This callback will be called by SymbolFile implementations when parsing a compile unit that contains ...
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
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.
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...
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
PathMappingList & GetSourceMappingList()
ArchSpec m_arch
The architecture for this module.
void ReportError(const char *format, Args &&...args)
void SetPlatformFileSpec(const FileSpec &file)
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
lldb::SymbolVendorUP m_symfile_up
A pointer to the symbol vendor for this module.
const Symbol * FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type=lldb::eSymbolTypeAny)
Find a symbol in the object file's symbol table.
llvm::DenseMap< llvm::stable_hash, std::unique_ptr< std::once_flag > > m_shown_diagnostics
A set of hashes of all warnings and errors, to avoid reporting them multiple times to the same Debugg...
std::recursive_mutex & GetMutex() const
llvm::VersionTuple GetVersion()
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.
void FindFunctions(const LookupInfo &lookup_info, const CompilerDeclContext &parent_decl_ctx, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list)
Find functions by lookup info.
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
void FindFunctions(ConstString name, const CompilerDeclContext &parent_decl_ctx, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list)
Find functions by name.
void FindFunctionSymbols(ConstString name, uint32_t name_type_mask, SymbolContextList &sc_list)
Find a function symbols in the object file's symbol table.
size_t GetNumCompileUnits()
Get the number of compile units for this module.
ConstString m_object_name
The name an object within this module that is selected, or empty of the module is represented by m_fi...
void LogMessage(Log *log, const char *format, Args &&...args)
bool MatchesModuleSpec(const ModuleSpec &module_ref)
bool RemapSourceFile(const char *, std::string &) const =delete
~Module() override
Destructor.
static size_t GetNumberAllocatedModules()
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.
bool LoadScriptingResourceInTarget(Target *target, Status &error, Stream &feedback_stream)
TypeSystemMap m_type_system_map
A map of any type systems associated with this module.
const PathMappingList & GetSourceMappingList() const
void ForEachTypeSystem(llvm::function_ref< bool(lldb::TypeSystemSP)> callback)
Call callback for each TypeSystem in this Module.
lldb::SectionListUP m_sections_up
Unified section list for module that is used by the ObjectFile and ObjectFile instances for the debug...
bool IsExecutable()
Tells whether this module is capable of being the main executable for a process.
FileSpec m_platform_file
The path to the module on the platform on which it is being debugged.
bool MergeArchitecture(const ArchSpec &arch_spec)
Update the ArchSpec to a more specific variant.
bool FileHasChanged() const
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
void LogMessageVerboseBacktrace(Log *log, const char *format, Args &&...args)
bool GetIsDynamicLinkEditor()
std::string GetCacheKey()
Get a unique cache key for the current module.
virtual SectionList * GetSectionList()
Get the unified section list for the module.
uint64_t GetObjectOffset() const
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language)
void Dump(Stream *s)
Dump a description of this object to a Stream.
StatsDuration & GetSymtabIndexTime()
Accessor for the symbol table index time metric.
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.
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 ReportErrorIfModifyDetected(const char *format, Args &&...args)
void FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, lldb::SymbolType symbol_type, SymbolContextList &sc_list, Mangled::NamePreference mangling_preference=Mangled::ePreferDemangled)
std::atomic< bool > m_did_load_symfile
UnwindTable & GetUnwindTable()
Returns a reference to the UnwindTable for this Module.
void SetRemoteInstallFileSpec(const FileSpec &file)
std::string GetSpecificationDescription() const
Get the module path and object name.
UnwindTable m_unwind_table
Table of FuncUnwinders objects created for this Module's functions.
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
bool IsLoadedInTarget(Target *target)
Tells whether this module has been loaded in the target passed in.
void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
void SetUUID(const lldb_private::UUID &uuid)
bool m_first_file_changed_log
void SymbolIndicesToSymbolContextList(Symtab *symtab, std::vector< uint32_t > &symbol_indexes, SymbolContextList &sc_list)
const llvm::sys::TimePoint & GetModificationTime() const
const FileSpec & GetRemoteInstallFileSpec() const
virtual void SectionFileAddressesChanged()
Notify the module that the file addresses for the Sections have been updated.
std::atomic< bool > m_did_load_objfile
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).
const Module & operator=(const Module &)=delete
void FindTypes(const TypeQuery &query, TypeResults &results)
Find types using a type-matching object that contains all search parameters.
bool SetArchitecture(const ArchSpec &new_arch)
SectionList * GetUnifiedSectionList()
StatsDuration m_symtab_parse_time
See if the module was modified after it was initially opened.
void ParseAllDebugSymbols()
A debugging function that will cause everything in a module to be parsed.
StatsDuration & GetSymtabParseTime()
Accessor for the symbol table parse time metric.
A plug-in interface definition class for object file parsers.
A stream class that can stream formatted output to a file.
Defines a list of symbol context objects.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
Defines a symbol context baton that can be handed other debug core functions.
Provides public interface for all SymbolFiles.
A class that contains all state required for type lookups.
This class tracks the state and results of a TypeQuery.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::ObjectFile > ObjectFileSP
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Process > ProcessSP
std::unique_ptr< lldb_private::SymbolVendor > SymbolVendorUP
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::unique_ptr< lldb_private::SectionList > SectionListUP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::CompileUnit > CompUnitSP
Options used by Module::FindFunctions.
bool include_inlines
Include inlined functions.
bool include_symbols
Include the symbol table.