Go to the documentation of this file.
57 #include "llvm/ADT/STLExtras.h"
58 #include "llvm/Support/Compiler.h"
59 #include "llvm/Support/DJB.h"
60 #include "llvm/Support/FileSystem.h"
61 #include "llvm/Support/FormatVariadic.h"
62 #include "llvm/Support/JSON.h"
63 #include "llvm/Support/Signals.h"
64 #include "llvm/Support/raw_ostream.h"
72 #include <type_traits>
98 if (g_module_collection ==
nullptr)
101 return *g_module_collection;
104 std::recursive_mutex &Module::GetAllocationModuleCollectionMutex() {
110 static std::recursive_mutex *g_module_collection_mutex =
nullptr;
111 if (g_module_collection_mutex ==
nullptr)
112 g_module_collection_mutex =
new std::recursive_mutex;
113 return *g_module_collection_mutex;
116 size_t Module::GetNumberAllocatedModules() {
117 std::lock_guard<std::recursive_mutex> guard(
118 GetAllocationModuleCollectionMutex());
122 Module *Module::GetAllocatedModuleAtIndex(
size_t idx) {
123 std::lock_guard<std::recursive_mutex> guard(
124 GetAllocationModuleCollectionMutex());
126 if (idx < modules.size())
132 : m_file_has_changed(false), m_first_file_changed_log(false) {
135 std::lock_guard<std::recursive_mutex> guard(
142 LLDB_LOGF(log,
"%p Module::Module((%s) '%s%s%s%s')",
143 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')",
262 std::lock_guard<std::recursive_mutex> guard(
270 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
273 std::lock_guard<std::recursive_mutex> guard(
276 ModuleCollection::iterator end = modules.end();
277 ModuleCollection::iterator pos = std::find(modules.begin(), end,
this);
283 LLDB_LOGF(log,
"%p Module::~Module((%s) '%s%s%s%s')",
300 size_t size_to_read) {
302 error.SetErrorString(
"object file already exists");
304 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
307 std::shared_ptr<DataBufferHeap> data_sp =
308 std::make_shared<DataBufferHeap>(size_to_read, 0);
310 const size_t bytes_read =
311 process_sp->ReadMemory(header_addr, data_sp->GetBytes(),
312 data_sp->GetByteSize(), readmem_error);
313 if (bytes_read < size_to_read)
314 data_sp->SetByteSize(bytes_read);
315 if (data_sp->GetByteSize() > 0) {
317 header_addr, data_sp);
320 s.
Printf(
"0x%16.16" PRIx64, header_addr);
332 error.SetErrorString(
"unable to find suitable object file plug-in");
335 error.SetErrorStringWithFormat(
"unable to read header from memory: %s",
339 error.SetErrorString(
"invalid process");
347 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
351 if (obj_file !=
nullptr) {
361 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
366 lldbassert(0 &&
"Attempting to overwrite the existing module UUID");
370 llvm::Expected<TypeSystem &>
376 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
378 if (num_comp_units == 0)
383 for (
size_t cu_idx = 0; cu_idx < num_comp_units; cu_idx++) {
415 s->
Printf(
", Module{%p}",
static_cast<void *
>(
this));
419 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
421 static_cast<void *
>(
this));
423 return symbols->GetNumCompileUnits();
428 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
432 if (index < num_comp_units) {
434 cu_sp = symbols->GetCompileUnitAtIndex(index);
440 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
448 const Address &so_addr, lldb::SymbolContextItem resolve_scope,
450 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
461 if (section_sp && section_sp->GetModule().get() ==
this) {
465 resolved_flags |= eSymbolContextModule;
469 return resolved_flags;
473 if (resolve_scope & eSymbolContextCompUnit ||
474 resolve_scope & eSymbolContextFunction ||
475 resolve_scope & eSymbolContextBlock ||
476 resolve_scope & eSymbolContextLineEntry ||
477 resolve_scope & eSymbolContextVariable) {
485 if (resolve_scope & eSymbolContextSymbol &&
486 !(resolved_flags & eSymbolContextSymbol)) {
489 Symbol *matching_symbol =
nullptr;
493 [&matching_symbol](
Symbol *symbol) ->
bool {
494 if (symbol->GetType() != eSymbolTypeInvalid) {
495 matching_symbol = symbol;
500 sc.
symbol = matching_symbol;
501 if (!sc.
symbol && resolve_scope & eSymbolContextFunction &&
502 !(resolved_flags & eSymbolContextFunction)) {
503 bool verify_unique =
false;
508 obj_file->ResolveSymbolForAddress(so_addr, verify_unique);
519 if (symtab_objfile && symtab_objfile->
IsStripped()) {
521 if (symfile_objfile != symtab_objfile) {
523 if (symfile_symtab) {
534 resolved_flags |= eSymbolContextSymbol;
542 if (resolve_scope & eSymbolContextSymbol &&
543 !(resolved_flags & eSymbolContextSymbol) && resolve_tail_call_address &&
545 Address previous_addr = so_addr;
546 previous_addr.
Slide(-1);
548 bool do_resolve_tail_call_address =
false;
550 previous_addr, resolve_scope, sc, do_resolve_tail_call_address);
551 if (flags & eSymbolContextSymbol) {
553 if (sc.
GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0,
554 false, addr_range)) {
565 resolved_flags |= flags;
575 return resolved_flags;
579 const char *file_path,
uint32_t line,
bool check_inlines,
583 resolve_scope, sc_list);
589 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
591 "check_inlines = %s, resolve_scope = 0x%8.8x)",
592 file_spec.
GetPath().c_str(), line,
593 check_inlines ?
"yes" :
"no", resolve_scope);
600 check_inlines,
false);
602 symbols->ResolveSymbolContext(location_spec, resolve_scope, sc_list);
605 return sc_list.
GetSize() - initial_count;
612 symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches, variables);
627 for (
size_t i = 0; i < num_compile_units; ++i) {
637 FunctionNameType name_type_mask,
639 : m_name(name), m_lookup_name(), m_language(language) {
641 llvm::StringRef basename;
642 llvm::StringRef context;
644 if (name_type_mask & eFunctionNameTypeAuto) {
646 m_name_type_mask = eFunctionNameTypeFull;
650 m_name_type_mask = eFunctionNameTypeFull;
652 m_name_type_mask = eFunctionNameTypeFull;
657 m_name_type_mask |= eFunctionNameTypeSelector;
660 basename = cpp_method.GetBasename();
661 if (basename.empty()) {
664 m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
666 m_name_type_mask |= eFunctionNameTypeFull;
668 m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
672 m_name_type_mask = name_type_mask;
673 if (name_type_mask & eFunctionNameTypeMethod ||
674 name_type_mask & eFunctionNameTypeBase) {
678 if (cpp_method.IsValid()) {
679 basename = cpp_method.GetBasename();
681 if (!cpp_method.GetQualifiers().empty()) {
684 m_name_type_mask &= ~(eFunctionNameTypeBase);
685 if (m_name_type_mask == eFunctionNameTypeNone)
697 if (name_type_mask & eFunctionNameTypeSelector) {
699 m_name_type_mask &= ~(eFunctionNameTypeSelector);
700 if (m_name_type_mask == eFunctionNameTypeNone)
707 if (basename.empty()) {
708 if (name_type_mask & eFunctionNameTypeFull &&
711 basename = cpp_method.GetBasename();
712 if (basename.empty())
719 if (!basename.empty()) {
724 m_lookup_name.SetString(basename);
725 m_match_name_after_lookup =
true;
729 m_lookup_name = name;
730 m_match_name_after_lookup =
false;
735 size_t start_idx)
const {
738 size_t i = start_idx;
739 while (i < sc_list.
GetSize()) {
754 if (!full_name.empty())
755 keep_it = full_name.contains(user_name);
770 size_t i = start_idx;
771 while (i < sc_list.
GetSize()) {
788 llvm::StringRef anon_prefix(
"(anonymous namespace)");
807 FunctionNameType name_type_mask,
810 const size_t old_size = sc_list.
GetSize();
815 if (name_type_mask & eFunctionNameTypeAuto) {
819 symbols->
FindFunctions(lookup_info.GetLookupName(), parent_decl_ctx,
820 lookup_info.GetNameTypeMask(),
829 lookup_info.GetNameTypeMask(), sc_list);
833 const size_t new_size = sc_list.
GetSize();
835 if (old_size < new_size)
836 lookup_info.Prune(sc_list, old_size);
839 symbols->
FindFunctions(name, parent_decl_ctx, name_type_mask,
856 const size_t start_size = sc_list.
GetSize();
866 std::vector<uint32_t> symbol_indexes;
870 const size_t num_matches = symbol_indexes.size();
873 const size_t end_functions_added_index = sc_list.
GetSize();
874 size_t num_functions_added_to_sc_list =
875 end_functions_added_index - start_size;
876 if (num_functions_added_to_sc_list == 0) {
879 for (
size_t i = 0; i < num_matches; ++i) {
887 typedef std::map<lldb::addr_t, uint32_t> FileAddrToIndexMap;
888 FileAddrToIndexMap file_addr_to_index;
889 for (
size_t i = start_size; i < end_functions_added_index; ++i) {
898 FileAddrToIndexMap::const_iterator end = file_addr_to_index.end();
901 for (
size_t i = start_size; i < num_matches; ++i) {
907 FileAddrToIndexMap::const_iterator pos =
908 file_addr_to_index.find(
913 sc_list[pos->second].symbol = sc.
symbol;
926 std::vector<Address> &output_local,
927 std::vector<Address> &output_extern) {
940 if (f && f ==
function)
941 output_local.push_back(addr);
943 output_extern.push_back(addr);
950 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
953 symbols->
FindTypes(name, parent_decl_ctx, max_matches,
954 searched_symbol_files, types);
959 size_t max_matches,
TypeList &type_list) {
961 llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
962 FindTypes_Impl(type_name, parent_decl_ctx, max_matches, searched_symbol_files,
974 llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
975 FindTypes(name, exact_match, 1, searched_symbol_files, type_list);
982 ConstString name,
bool exact_match,
size_t max_matches,
983 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
985 const char *type_name_cstr = name.
GetCString();
986 llvm::StringRef type_scope;
987 llvm::StringRef type_basename;
988 TypeClass type_class = eTypeClassAny;
997 exact_match = type_scope.consume_front(
"::");
999 ConstString type_basename_const_str(type_basename);
1001 searched_symbol_files, typesmap);
1009 if (type_class != eTypeClassAny && !type_basename.empty()) {
1013 UINT_MAX, searched_symbol_files, typesmap);
1019 searched_symbol_files, typesmap);
1023 type_class, exact_match);
1035 llvm::ArrayRef<CompilerContext> pattern,
LanguageSet languages,
1036 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
1042 symbols->
FindTypes(pattern, languages, searched_symbol_files, types);
1047 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1050 if (obj_file !=
nullptr) {
1107 s << llvm::formatv(
"({0})", object_name);
1111 if (format && format[0]) {
1117 va_start(args, format);
1121 const int format_len = strlen(format);
1122 if (format_len > 0) {
1123 const char last_char = format[format_len - 1];
1124 if (last_char !=
'\n' && last_char !=
'\r')
1143 llvm::Optional<lldb::user_id_t> debugger_id) {
1150 <<
" was compiled with optimization - stepping may behave "
1151 "oddly; variables may not be available.";
1157 LanguageType language, llvm::Optional<lldb::user_id_t> debugger_id) {
1159 ss <<
"This version of LLDB has no plugin for the language \""
1162 "Inspection of frame variables will be limited.";
1178 va_start(args, format);
1182 const int format_len = strlen(format);
1183 if (format_len > 0) {
1184 const char last_char = format[format_len - 1];
1185 if (last_char !=
'\n' && last_char !=
'\r')
1188 strm.
PutCString(
"The debug session should be aborted as the original "
1189 "debug information has been overwritten.\n");
1197 if (format && format[0]) {
1204 va_start(args, format);
1208 const int format_len = strlen(format);
1209 if (format_len > 0) {
1210 const char last_char = format[format_len - 1];
1211 if (last_char !=
'\n' && last_char !=
'\r')
1219 if (log !=
nullptr) {
1224 va_start(args, format);
1232 if (log !=
nullptr) {
1237 va_start(args, format);
1242 llvm::raw_string_ostream stream(back_trace);
1243 llvm::sys::PrintStackTrace(stream);
1251 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1275 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1316 if (obj_file !=
nullptr)
1345 "Module::FindFirstSymbolWithNameAndType (name = %s, type = %i)",
1353 Symtab *symtab, std::vector<uint32_t> &symbol_indexes,
1358 size_t num_indices = symbol_indexes.size();
1359 if (num_indices > 0) {
1362 for (
size_t i = 0; i < num_indices; i++) {
1384 std::vector<uint32_t> symbol_indexes;
1396 "Module::FindSymbolsMatchingRegExAndType (regex = %s, type = %i)",
1397 regex.
GetText().str().c_str(), symbol_type);
1399 std::vector<uint32_t> symbol_indexes;
1408 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1431 if (section_list && symbol_file) {
1461 if (llvm::StringRef(old_path).startswith(new_path)) {
1470 for (
size_t idx = num_sections; idx > 0; --idx) {
1471 lldb::SectionSP section_sp(
1473 if (section_sp->GetObjectFile() == obj_file) {
1500 if (sections !=
nullptr) {
1501 size_t num_sections = sections->
GetSize();
1502 for (
size_t sect_idx = 0; sect_idx < num_sections; sect_idx++) {
1514 Stream *feedback_stream) {
1516 error.SetErrorString(
"invalid destination Target");
1521 target->TargetProperties::GetLoadScriptFromSymbolFile();
1533 error.SetErrorString(
"invalid Platform");
1537 FileSpecList file_specs = platform_sp->LocateExecutableScriptingResources(
1538 target, *
this, feedback_stream);
1540 const uint32_t num_specs = file_specs.GetSize();
1543 if (script_interpreter) {
1544 for (
uint32_t i = 0; i < num_specs; ++i) {
1545 FileSpec scripting_fspec(file_specs.GetFileSpecAtIndex(i));
1546 if (scripting_fspec &&
1549 if (feedback_stream)
1551 "warning: '%s' contains a debug script. To run this script "
1553 "this debug session:\n\n command script import "
1555 "To run all discovered debug scripts in this session:\n\n"
1556 " settings set target.load-script-from-symbol-file "
1558 GetFileSpec().GetFileNameStrippingExtension().GetCString(),
1559 scripting_fspec.
GetPath().c_str());
1572 error.SetErrorString(
"invalid ScriptInterpreter");
1589 bool value_is_offset,
bool &changed) {
1591 if (object_file !=
nullptr) {
1592 changed = object_file->
SetLoadAddress(target, value, value_is_offset);
1633 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1635 new_spec = *remapped;
1641 llvm::Optional<std::string>
1643 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1645 return remapped->GetPath();
1650 llvm::StringRef sysroot) {
1652 llvm::StringRef sdk_path(HostInfo::GetXcodeSDKPath(sdk));
1653 if (sdk_path.empty())
1666 "module has arch %s, merging/replacing with arch %s",
1668 arch_spec.
GetTriple().getTriple().c_str());
1684 return obj_file->GetVersion();
1685 return llvm::VersionTuple();
1699 llvm::raw_string_ostream id_strm(identifier);
1708 return llvm::djbHash(id_strm.str());
1713 llvm::raw_string_ostream strm(key);
1717 strm <<
'-' << llvm::format_hex(
Hash(), 10);
1728 .GetLLDBIndexCachePath()
1730 return g_data_file_cache;
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.
Provides public interface for all SymbolFiles.
Block * block
The Block for a given query.
virtual void FindTypes(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, llvm::DenseSet< lldb_private::SymbolFile * > &searched_symbol_files, TypeMap &types)
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 bool DemangledNameContainsPath(llvm::StringRef path, ConstString demangled) const
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
void FindFunctions(ConstString name, const CompilerDeclContext &parent_decl_ctx, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list)
Find functions by name.
virtual void ResolveAddress(SearchFilter &filter)
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
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)
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.
virtual void SectionFileAddressesChanged()=0
Notify the SymbolFile that the file addresses in the Sections for this module have been changed.
void ReportWarningUnsupportedLanguage(lldb::LanguageType language, llvm::Optional< lldb::user_id_t > debugger_id)
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.
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)
void RemoveMismatchedTypes(const char *qualified_typename, bool exact_match)
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 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
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, llvm::Optional< lldb::ScriptLanguage > language={})
~Module() override
Destructor.
lldb::ModuleSP CalculateSymbolContextModule() override
llvm::Expected< TypeSystem & > GetTypeSystemForLanguage(lldb::LanguageType language, Module *module, bool can_create)
void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name)
void void void void ReportError(const char *format,...) __attribute__((format(printf
llvm::StringRef GetString() const
FileSpec & GetSymbolFileSpec()
void void void void void ReportErrorIfModifyDetected(const char *format,...) __attribute__((format(printf
bool include_inlines
Include inlined functions.
void FindFunctionSymbols(ConstString name, uint32_t name_type_mask, SymbolContextList &sc_list)
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.
@ eLoadScriptFromSymFileWarn
static void ReportWarning(std::string messsage, llvm::Optional< lldb::user_id_t > debugger_id=llvm::None, std::once_flag *once=nullptr)
Report warning events.
bool IsCompatibleMatch(const ArchSpec &rhs) const
Compare an ArchSpec to another ArchSpec, requiring a compatible cpu type match between them.
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.
Symbol * FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility)
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)
Symbol * symbol
The Symbol for a given query.
virtual bool GetIsDynamicLinkEditor()
Return true if this file is a dynamic link editor (dyld)
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::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.
const char * GetData() const
virtual size_t ParseTypes(CompileUnit &comp_unit)=0
virtual void Dump(Stream &s)=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)
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)
void LogMessage(Log *log, const char *format,...) __attribute__((format(printf
ConstString GetFunctionName(Mangled::NamePreference preference=Mangled::ePreferDemangled) const
Find a name of the innermost function for the symbol context.
static void SystemLog(SystemLogType type, const char *format,...) __attribute__((format(printf
size_t size_t PrintfVarArg(const char *format, va_list args)
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.
bool Replace(llvm::StringRef path, llvm::StringRef replacement, bool notify)
void void void ReportWarning(const char *format,...) __attribute__((format(printf
virtual void FindFunctions(ConstString name, const CompilerDeclContext &parent_decl_ctx, lldb::FunctionNameType name_type_mask, bool include_inlines, SymbolContextList &sc_list)
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)
llvm::Optional< FileSpec > FindFile(const FileSpec &orig_spec) const
Finds a source file given a file spec using the path remappings.
std::string GetSpecificationDescription() const
Get the module path and object name.
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 DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
size_t EOL()
Output and End of Line character to the stream.
virtual void SetLoadDebugInfoEnabled()
Specify debug info should be loaded.
std::string GetCacheKey()
Get a unique cache key for the current module.
virtual void ClearSymtab()
Frees the symbol table.
void FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
bool ResolveAddressUsingFileSections(lldb::addr_t addr, const SectionList *sections)
Resolve a file virtual address using a section 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.
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()
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.
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()
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
llvm::Optional< std::string > RemapSourceFile(llvm::StringRef path) const
Remaps a source file given path into new_path.
uint32_t AppendSymbolIndexesMatchingRegExAndType(const RegularExpression ®ex, lldb::SymbolType symbol_type, std::vector< uint32_t > &indexes)
virtual Symtab * GetSymtab()=0
void FindAllSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, std::vector< uint32_t > &symbol_indexes)
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.
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 FindAllSymbolsMatchingRexExAndType(const RegularExpression ®ex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector< uint32_t > &symbol_indexes)
bool IsExecutable()
Tells whether this module is capable of being the main executable for a process.
ConstString & GetFilename()
Filename string get accessor.
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)