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"
100 if (g_module_collection ==
nullptr)
103 return *g_module_collection;
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;
119 std::lock_guard<std::recursive_mutex> guard(
125 std::lock_guard<std::recursive_mutex> guard(
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_name(object_name),
240 m_object_offset(object_offset), m_object_mod_time(object_mod_time),
241 m_file_has_changed(false), m_first_file_changed_log(false) {
244 std::lock_guard<std::recursive_mutex> guard(
251 LLDB_LOGF(log,
"%p Module::Module((%s) '%s%s%s%s')",
258 std::lock_guard<std::recursive_mutex> guard(
266 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
269 std::lock_guard<std::recursive_mutex> guard(
272 ModuleCollection::iterator end = modules.end();
273 ModuleCollection::iterator pos = std::find(modules.begin(), end,
this);
279 LLDB_LOGF(log,
"%p Module::~Module((%s) '%s%s%s%s')",
295 size_t size_to_read) {
297 error.SetErrorString(
"object file already exists");
299 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
302 std::shared_ptr<DataBufferHeap> data_sp =
303 std::make_shared<DataBufferHeap>(size_to_read, 0);
305 const size_t bytes_read =
306 process_sp->ReadMemory(header_addr, data_sp->GetBytes(),
307 data_sp->GetByteSize(), readmem_error);
308 if (bytes_read < size_to_read)
309 data_sp->SetByteSize(bytes_read);
310 if (data_sp->GetByteSize() > 0) {
312 header_addr, data_sp);
315 s.
Printf(
"0x%16.16" PRIx64, header_addr);
327 error.SetErrorString(
"unable to find suitable object file plug-in");
330 error.SetErrorStringWithFormat(
"unable to read header from memory: %s",
334 error.SetErrorString(
"invalid process");
342 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
346 if (obj_file !=
nullptr) {
356 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
361 lldbassert(0 &&
"Attempting to overwrite the existing module UUID");
365llvm::Expected<TypeSystemSP>
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 return symbols->GetNumCompileUnits();
426 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
430 if (index < num_comp_units) {
432 cu_sp = symbols->GetCompileUnitAtIndex(index);
438 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
446 const Address &so_addr, lldb::SymbolContextItem resolve_scope,
448 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
449 uint32_t resolved_flags = 0;
459 if (section_sp && section_sp->GetModule().get() ==
this) {
463 resolved_flags |= eSymbolContextModule;
467 return resolved_flags;
471 if (resolve_scope & eSymbolContextCompUnit ||
472 resolve_scope & eSymbolContextFunction ||
473 resolve_scope & eSymbolContextBlock ||
474 resolve_scope & eSymbolContextLineEntry ||
475 resolve_scope & eSymbolContextVariable) {
483 if (resolve_scope & eSymbolContextSymbol &&
484 !(resolved_flags & eSymbolContextSymbol)) {
487 Symbol *matching_symbol =
nullptr;
491 [&matching_symbol](
Symbol *symbol) ->
bool {
492 if (symbol->GetType() != eSymbolTypeInvalid) {
493 matching_symbol = symbol;
498 sc.
symbol = matching_symbol;
499 if (!sc.
symbol && resolve_scope & eSymbolContextFunction &&
500 !(resolved_flags & eSymbolContextFunction)) {
501 bool verify_unique =
false;
506 obj_file->ResolveSymbolForAddress(so_addr, verify_unique);
517 if (symtab_objfile && symtab_objfile->
IsStripped()) {
519 if (symfile_objfile != symtab_objfile) {
521 if (symfile_symtab) {
532 resolved_flags |= eSymbolContextSymbol;
540 if (resolve_scope & eSymbolContextSymbol &&
541 !(resolved_flags & eSymbolContextSymbol) && resolve_tail_call_address &&
543 Address previous_addr = so_addr;
544 previous_addr.
Slide(-1);
546 bool do_resolve_tail_call_address =
false;
548 previous_addr, resolve_scope, sc, do_resolve_tail_call_address);
549 if (flags & eSymbolContextSymbol) {
551 if (sc.
GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0,
552 false, addr_range)) {
563 resolved_flags |= flags;
573 return resolved_flags;
577 const char *file_path, uint32_t line,
bool check_inlines,
581 resolve_scope, sc_list);
585 const FileSpec &file_spec, uint32_t line,
bool check_inlines,
587 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
589 "check_inlines = %s, resolve_scope = 0x%8.8x)",
590 file_spec.
GetPath().c_str(), line,
591 check_inlines ?
"yes" :
"no", resolve_scope);
593 const uint32_t initial_count = sc_list.
GetSize();
598 check_inlines,
false);
600 symbols->ResolveSymbolContext(location_spec, resolve_scope, sc_list);
603 return sc_list.
GetSize() - initial_count;
610 symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches, variables);
625 for (
size_t i = 0; i < num_compile_units; ++i) {
635 FunctionNameType name_type_mask,
637 : m_name(name), m_lookup_name(), m_language(language) {
639 llvm::StringRef basename;
640 llvm::StringRef context;
642 if (name_type_mask & eFunctionNameTypeAuto) {
644 m_name_type_mask = eFunctionNameTypeFull;
648 m_name_type_mask = eFunctionNameTypeFull;
650 m_name_type_mask = eFunctionNameTypeFull;
655 m_name_type_mask |= eFunctionNameTypeSelector;
658 basename = cpp_method.GetBasename();
659 if (basename.empty()) {
662 m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
664 m_name_type_mask |= eFunctionNameTypeFull;
666 m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
670 m_name_type_mask = name_type_mask;
671 if (name_type_mask & eFunctionNameTypeMethod ||
672 name_type_mask & eFunctionNameTypeBase) {
676 if (cpp_method.IsValid()) {
677 basename = cpp_method.GetBasename();
679 if (!cpp_method.GetQualifiers().empty()) {
682 m_name_type_mask &= ~(eFunctionNameTypeBase);
683 if (m_name_type_mask == eFunctionNameTypeNone)
695 if (name_type_mask & eFunctionNameTypeSelector) {
697 m_name_type_mask &= ~(eFunctionNameTypeSelector);
698 if (m_name_type_mask == eFunctionNameTypeNone)
705 if (basename.empty()) {
706 if (name_type_mask & eFunctionNameTypeFull &&
709 basename = cpp_method.GetBasename();
710 if (basename.empty())
717 if (!basename.empty()) {
722 m_lookup_name.SetString(basename);
723 m_match_name_after_lookup =
true;
727 m_lookup_name = name;
728 m_match_name_after_lookup =
false;
739 if (
m_name == function_name)
747 const bool function_name_may_be_mangled =
749 ConstString demangled_function_name = function_name;
750 if (function_name_may_be_mangled) {
751 Mangled mangled_function_name(function_name);
759 return language->DemangledNameContainsPath(
m_name, demangled_function_name);
761 llvm::StringRef function_name_ref = demangled_function_name;
762 return function_name_ref.contains(
m_name);
766 size_t start_idx)
const {
767 if (m_match_name_after_lookup && m_name) {
769 size_t i = start_idx;
770 while (i < sc_list.
GetSize()) {
787 if (m_name_type_mask == eFunctionNameTypeFull) {
789 size_t i = start_idx;
790 while (i < sc_list.
GetSize()) {
797 if (mangled_name != m_name && full_name != m_name) {
801 if (cpp_method.
GetBasename().compare(m_name) != 0) {
806 std::string qualified_name;
807 llvm::StringRef anon_prefix(
"(anonymous namespace)");
812 if (qualified_name != m_name.GetCString()) {
830 symbols->FindFunctions(lookup_info, parent_decl_ctx,
835 if (
Symtab *symtab = symbols->GetSymtab()) {
845 FunctionNameType name_type_mask,
848 const size_t old_size = sc_list.
GetSize();
850 FindFunctions(lookup_info, parent_decl_ctx, options, sc_list);
851 if (name_type_mask & eFunctionNameTypeAuto) {
852 const size_t new_size = sc_list.
GetSize();
853 if (old_size < new_size)
854 lookup_info.Prune(sc_list, old_size);
861 const size_t start_size = sc_list.
GetSize();
869 Symtab *symtab = symbols->GetSymtab();
871 std::vector<uint32_t> symbol_indexes;
875 const size_t num_matches = symbol_indexes.size();
878 const size_t end_functions_added_index = sc_list.
GetSize();
879 size_t num_functions_added_to_sc_list =
880 end_functions_added_index - start_size;
881 if (num_functions_added_to_sc_list == 0) {
884 for (
size_t i = 0; i < num_matches; ++i) {
892 typedef std::map<lldb::addr_t, uint32_t> FileAddrToIndexMap;
893 FileAddrToIndexMap file_addr_to_index;
894 for (
size_t i = start_size; i < end_functions_added_index; ++i) {
903 FileAddrToIndexMap::const_iterator end = file_addr_to_index.
end();
906 for (
size_t i = start_size; i < num_matches; ++i) {
912 FileAddrToIndexMap::const_iterator pos =
913 file_addr_to_index.find(
918 sc_list[pos->second].symbol = sc.
symbol;
929 const FileSpec &file, uint32_t line,
931 std::vector<Address> &output_local,
932 std::vector<Address> &output_extern) {
945 if (f && f == function)
946 output_local.push_back(addr);
948 output_extern.push_back(addr);
955 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
958 symbols->FindTypes(name, parent_decl_ctx, max_matches,
959 searched_symbol_files, types);
964 size_t max_matches,
TypeList &type_list) {
966 llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
967 FindTypes_Impl(type_name, parent_decl_ctx, max_matches, searched_symbol_files,
979 llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
980 FindTypes(name, exact_match, 1, searched_symbol_files, type_list);
987 ConstString name,
bool exact_match,
size_t max_matches,
988 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
990 const char *type_name_cstr = name.
GetCString();
991 llvm::StringRef type_scope;
992 llvm::StringRef type_basename;
993 TypeClass type_class = eTypeClassAny;
1002 exact_match = type_scope.consume_front(
"::");
1004 ConstString type_basename_const_str(type_basename);
1006 searched_symbol_files, typesmap);
1013 if (type_class != eTypeClassAny && !type_basename.empty()) {
1017 UINT_MAX, searched_symbol_files, typesmap);
1022 searched_symbol_files, typesmap);
1037 llvm::ArrayRef<CompilerContext> pattern,
LanguageSet languages,
1038 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
1044 symbols->FindTypes(pattern, languages, searched_symbol_files, types);
1052 if (requestors.empty())
1053 return interruptors;
1055 for (
auto debugger_sp : requestors) {
1056 if (!debugger_sp->InterruptRequested())
1058 if (debugger_sp->GetTargetList()
1059 .AnyTargetContainsModule(module))
1060 interruptors.push_back(debugger_sp);
1062 return interruptors;
1067 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1071 if (!interruptors.empty()) {
1072 for (
auto debugger_sp : interruptors) {
1074 "Interrupted fetching symbols for module {0}",
1075 this->GetFileSpec());
1080 if (obj_file !=
nullptr) {
1093 return symbols->GetSymtab();
1137 s << llvm::formatv(
"({0})", object_name);
1152 std::optional<lldb::user_id_t> debugger_id) {
1159 <<
" was compiled with optimization - stepping may behave "
1160 "oddly; variables may not be available.";
1166 LanguageType language, std::optional<lldb::user_id_t> debugger_id) {
1168 ss <<
"This version of LLDB has no plugin for the language \""
1171 "Inspection of frame variables will be limited.";
1177 const llvm::formatv_object_base &payload) {
1186 strm.
PutCString(
"The debug session should be aborted as the original "
1187 "debug information has been overwritten.");
1218 Log *log,
const llvm::formatv_object_base &payload) {
1224 std::string back_trace;
1225 llvm::raw_string_ostream stream(back_trace);
1226 llvm::sys::PrintStackTrace(stream);
1233 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1257 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1285 ReportError(
"failed to load objfile for {0}\nDebugging will be "
1286 "degraded for this module.",
1299 if (obj_file !=
nullptr)
1310 symbols->SectionFileAddressesChanged();
1331 "Module::FindFirstSymbolWithNameAndType (name = %s, type = %i)",
1334 return symtab->FindFirstSymbolWithNameAndType(
1339 Symtab *symtab, std::vector<uint32_t> &symbol_indexes,
1344 size_t num_indices = symbol_indexes.size();
1345 if (num_indices > 0) {
1348 for (
size_t i = 0; i < num_indices; i++) {
1361 symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
1370 std::vector<uint32_t> symbol_indexes;
1371 symtab->FindAllSymbolsWithNameAndType(name, symbol_type, symbol_indexes);
1382 "Module::FindSymbolsMatchingRegExAndType (regex = %s, type = %i)",
1383 regex.
GetText().str().c_str(), symbol_type);
1385 std::vector<uint32_t> symbol_indexes;
1386 symtab->FindAllSymbolsMatchingRexExAndType(
1388 symbol_indexes, mangling_preference);
1394 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1402 symtab->PreloadSymbols();
1417 if (section_list && symbol_file) {
1445 std::string new_path(file.
GetPath());
1447 if (llvm::StringRef(old_path).startswith(new_path)) {
1456 for (
size_t idx = num_sections; idx > 0; --idx) {
1459 if (section_sp->GetObjectFile() == obj_file) {
1486 if (sections !=
nullptr) {
1487 size_t num_sections = sections->
GetSize();
1488 for (
size_t sect_idx = 0; sect_idx < num_sections; sect_idx++) {
1500 Stream &feedback_stream) {
1502 error.SetErrorString(
"invalid destination Target");
1507 target->TargetProperties::GetLoadScriptFromSymbolFile();
1519 error.SetErrorString(
"invalid Platform");
1523 FileSpecList file_specs = platform_sp->LocateExecutableScriptingResources(
1524 target, *
this, feedback_stream);
1526 const uint32_t num_specs = file_specs.
GetSize();
1529 if (script_interpreter) {
1530 for (uint32_t i = 0; i < num_specs; ++i) {
1532 if (scripting_fspec &&
1536 "warning: '%s' contains a debug script. To run this script "
1538 "this debug session:\n\n command script import "
1540 "To run all discovered debug scripts in this session:\n\n"
1541 " settings set target.load-script-from-symbol-file "
1543 GetFileSpec().GetFileNameStrippingExtension().GetCString(),
1544 scripting_fspec.
GetPath().c_str());
1557 error.SetErrorString(
"invalid ScriptInterpreter");
1574 bool value_is_offset,
bool &changed) {
1576 if (object_file !=
nullptr) {
1577 changed = object_file->
SetLoadAddress(target, value, value_is_offset);
1618 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1620 new_spec = *remapped;
1627 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1629 return remapped->GetPath();
1634 llvm::StringRef sysroot) {
1635 auto sdk_path_or_err =
1636 HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk_name.str()});
1638 if (!sdk_path_or_err) {
1640 toString(sdk_path_or_err.takeError()));
1644 auto sdk_path = *sdk_path_or_err;
1645 if (sdk_path.empty())
1658 "module has arch %s, merging/replacing with arch %s",
1660 arch_spec.
GetTriple().getTriple().c_str());
1676 return obj_file->GetVersion();
1677 return llvm::VersionTuple();
1690 std::string identifier;
1691 llvm::raw_string_ostream id_strm(identifier);
1700 return llvm::djbHash(id_strm.str());
1705 llvm::raw_string_ostream strm(key);
1709 strm <<
'-' << llvm::format_hex(
Hash(), 10);
1720 .GetLLDBIndexCachePath()
1722 return g_data_file_cache;
static llvm::raw_ostream & error(Stream &strm)
#define REPORT_INTERRUPTION(debugger,...)
#define LLDB_LOGF(log,...)
std::vector< Module * > ModuleCollection
static ModuleCollection & GetModuleCollection()
static Debugger::DebuggerList DebuggersOwningModuleRequestingInterruption(Module &module)
#define LLDB_SCOPED_TIMER()
#define LLDB_SCOPED_TIMERF(...)
A section + offset based address range class.
Address & GetBaseAddress()
Get accessor for the base address of the range.
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
"lldb/Core/AddressResolverFileLine.h" This class finds address for source file and line.
size_t GetNumberOfAddresses()
virtual void ResolveAddress(SearchFilter &filter)
AddressRange & GetAddressRangeAtIndex(size_t idx)
A section + offset based address class.
bool ResolveAddressUsingFileSections(lldb::addr_t addr, const SectionList *sections)
Resolve a file virtual address using a section list.
lldb::SectionSP GetSection() const
Get const accessor for the section.
Function * CalculateSymbolContextFunction() const
bool Slide(int64_t offset)
lldb::addr_t GetFileAddress() const
Get the file address.
lldb::addr_t GetOffset() const
Get the section relative offset value.
bool IsSectionOffset() const
Check if an address is section offset.
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
void MergeFrom(const ArchSpec &other)
Merges fields from another ArchSpec into this ArchSpec.
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
std::string GetScopeQualifiedName()
llvm::StringRef GetContext()
llvm::StringRef GetBasename()
static bool IsCPPMangledName(llvm::StringRef name)
static bool ExtractContextAndIdentifier(const char *name, llvm::StringRef &context, llvm::StringRef &identifier)
const FileSpec & GetPrimaryFile() const
Return the primary source file associated with this compile unit.
void ForeachFunction(llvm::function_ref< bool(const lldb::FunctionSP &)> lambda) const
Apply a lambda to each function in this compile unit.
Represents a generic declaration context in a program.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
bool IsEmpty() const
Test for empty string.
void SetString(llvm::StringRef s)
const char * GetCString() const
Get the string value as a C string.
This class enables data to be cached into a directory using the llvm caching code.
A class to manage flag bits.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
lldb::ScriptLanguage GetScriptLanguage() const
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
std::vector< lldb::DebuggerSP > DebuggerList
static DebuggerList DebuggersRequestingInterruption()
const FileSpec & GetFileSpecAtIndex(size_t idx) const
Get file at index.
size_t GetSize() const
Get the number of files in the file list.
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
const ConstString & GetFilename() const
Filename string const get accessor.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void Dump(llvm::raw_ostream &s) const
Dump this object to a Stream.
uint64_t GetByteSize(const FileSpec &file_spec) const
Returns the on-disk size of the given file in bytes.
llvm::sys::TimePoint GetModificationTime(const FileSpec &file_spec) const
Returns the modification time of the given file.
static FileSystem & Instance()
A class that describes a function.
const AddressRange & GetAddressRange()
static Language * FindPlugin(lldb::LanguageType language)
static const char * GetNameForLanguageType(lldb::LanguageType language)
static bool LanguageIsC(lldb::LanguageType language)
static bool LanguageIsObjC(lldb::LanguageType language)
void PutCString(const char *cstr)
A class that handles mangled names.
static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef const name)
Try to identify the mangling scheme used.
ConstString GetDemangledName() const
Demangled name get accessor.
static ModuleListProperties & GetGlobalModuleListProperties()
bool FindMatchingModuleSpec(const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
uint64_t GetObjectOffset() const
ConstString & GetObjectName()
FileSpec & GetPlatformFileSpec()
lldb::DataBufferSP GetData() const
ArchSpec & GetArchitecture()
FileSpec & GetSymbolFileSpec()
llvm::sys::TimePoint & GetObjectModificationTime()
A class that encapsulates name lookup information.
lldb::FunctionNameType GetNameTypeMask() const
ConstString GetLookupName() const
bool NameMatchesLookupInfo(ConstString function_name, lldb::LanguageType language_type=lldb::eLanguageTypeUnknown) const
ConstString m_name
What the user originally typed.
void Prune(SymbolContextList &sc_list, size_t start_idx) const
A class that describes an executable image and its associated object and symbol files.
const lldb_private::UUID & GetUUID()
Get a reference to the UUID value contained in this object.
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)
std::once_flag m_optimization_warning
lldb::TypeSP FindFirstType(const SymbolContext &sc, ConstString type_name, bool exact_match)
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).
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.
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)
void FindTypes_Impl(ConstString name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, llvm::DenseSet< lldb_private::SymbolFile * > &searched_symbol_files, TypeMap &types)
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
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.
std::once_flag m_language_warning
static Module * GetAllocatedModuleAtIndex(size_t idx)
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.
llvm::sys::TimePoint m_mod_time
The modification time for this module when it was created.
lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx)
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.
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.
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
ArchSpec m_arch
The architecture for this module.
void ReportError(const char *format, Args &&...args)
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::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 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)
~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.
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.
std::optional< UnwindTable > m_unwind_table
Table of FuncUnwinders objects created for this Module's functions.
virtual SectionList * GetSectionList()
Get the unified section list for the module.
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language)
void Dump(Stream *s)
Dump a description of this object to a Stream.
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.
std::string GetSpecificationDescription() const
Get the module path and object name.
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)
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).
bool SetArchitecture(const ArchSpec &new_arch)
SectionList * GetUnifiedSectionList()
void ParseAllDebugSymbols()
A debugging function that will cause everything in a module to be parsed.
static bool IsPossibleObjCSelector(const char *name)
static bool IsPossibleObjCMethodName(const char *name)
A plug-in interface definition class for object file parsers.
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.
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...
virtual void Dump(Stream *s)=0
Dump a description of this object to a Stream.
Symtab * GetSymtab()
Gets the symbol table for the currently selected architecture (and object for archives).
virtual bool IsStripped()=0
Detect if this object file has been stripped of local symbols.
virtual bool IsExecutable() const =0
Tells whether this object file is capable of being the main executable for a process.
virtual void ClearSymtab()
Frees the symbol table.
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
virtual void CreateSections(SectionList &unified_section_list)=0
virtual void SectionFileAddressesChanged()
Notify the ObjectFile that the file addresses in the Sections for this module have been changed.
virtual UUID GetUUID()=0
Gets the UUID for this object file.
virtual bool GetIsDynamicLinkEditor()
Return true if this file is a dynamic link editor (dyld)
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())
std::optional< FileSpec > FindFile(const FileSpec &orig_spec) const
Finds a source file given a file spec using the path remappings.
bool Replace(llvm::StringRef path, llvm::StringRef replacement, bool notify)
void Append(llvm::StringRef path, llvm::StringRef replacement, bool notify)
bool RemapPath(ConstString path, ConstString &new_path) const
llvm::StringRef GetText() const
Access the regular expression text.
virtual bool LoadScriptingModule(const char *filename, const LoadScriptOptions &options, lldb_private::Status &error, StructuredData::ObjectSP *module_sp=nullptr, FileSpec extra_search_dir={})
This is a SearchFilter that restricts the search to a given module.
size_t GetNumSections(uint32_t depth) const
bool DeleteSection(size_t idx)
lldb::SectionSP GetSectionAtIndex(size_t idx) const
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
const char * GetData() const
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Defines a list of symbol context objects.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
uint32_t GetSize() const
Get accessor for a symbol context list size.
const_iterator end() const
bool RemoveContextAtIndex(size_t idx)
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
Defines a symbol context baton that can be handed other debug core functions.
lldb::LanguageType GetLanguage() const
Function * function
The Function for a given query.
ConstString GetFunctionName(Mangled::NamePreference preference=Mangled::ePreferDemangled) const
Find a name of the innermost function for the symbol context.
void SortTypeList(TypeMap &type_map, TypeList &type_list) const
Sorts the types in TypeMap according to SymbolContext to TypeList.
Block * block
The Block for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
void Clear(bool clear_target)
Clear the object's state.
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.
Symbol * symbol
The Symbol for a given query.
Provides public interface for all SymbolFiles.
virtual size_t ParseTypes(CompileUnit &comp_unit)=0
virtual Symtab * GetSymtab()=0
virtual void SetLoadDebugInfoEnabled()
Specify debug info should be loaded.
virtual void PreloadSymbols()
virtual void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, VariableList &variables)
virtual size_t ParseFunctions(CompileUnit &comp_unit)=0
virtual size_t ParseBlocksRecursive(Function &func)=0
virtual lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx)=0
virtual size_t ParseVariablesForContext(const SymbolContext &sc)=0
virtual ObjectFile * GetObjectFile()=0
virtual uint32_t ResolveSymbolContext(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc)=0
static void DownloadSymbolFileAsync(const UUID &uuid)
Locate the symbol file for the given UUID on a background thread.
static SymbolVendor * FindPlugin(const lldb::ModuleSP &module_sp, Stream *feedback_strm)
bool ValueIsAddress() const
Address & GetAddressRef()
lldb::SymbolType GetType() const
Symbol * SymbolAtIndex(size_t idx)
void ForEachSymbolContainingFileAddress(lldb::addr_t file_addr, std::function< bool(Symbol *)> const &callback)
Symbol * FindSymbolContainingFileAddress(lldb::addr_t file_addr)
ObjectFile * GetObjectFile() const
uint32_t AppendSymbolIndexesMatchingRegExAndType(const RegularExpression ®ex, lldb::SymbolType symbol_type, std::vector< uint32_t > &indexes, Mangled::NamePreference name_preference=Mangled::ePreferDemangled)
lldb::PlatformSP GetPlatform()
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
void RemoveMismatchedTypes(llvm::StringRef type_scope, llvm::StringRef type_basename, lldb::TypeClass type_class, bool exact_match)
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language, Module *module, bool can_create)
void ForEach(std::function< bool(lldb::TypeSystemSP)> const &callback)
static bool GetTypeScopeAndBasename(llvm::StringRef name, llvm::StringRef &scope, llvm::StringRef &basename, lldb::TypeClass &type_class)
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
@ eLoadScriptFromSymFileFalse
@ eLoadScriptFromSymFileWarn
const char * toString(AppleArm64ExceptionClass EC)
std::shared_ptr< lldb_private::Function > FunctionSP
ScriptLanguage
Script interpreter types.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::Platform > PlatformSP
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::CompileUnit > CompUnitSP
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Options used by Module::FindFunctions.
bool include_inlines
Include inlined functions.
bool include_symbols
Include the symbol table.