27 language, is_optimized) {}
36 m_language(language), m_flags(0),
37 m_primary_support_file_sp(support_file_sp),
38 m_support_files(std::move(support_files)), m_is_optimized(is_optimized) {
55 s->
Printf(
", CompileUnit{0x%8.8" PRIx64
"}",
GetID());
61 *s <<
"id = " << (
const UserID &)*
this <<
", file = \""
62 << this->
GetPrimaryFile() <<
"\", language = \"" << language <<
'"';
66 llvm::function_ref<
bool(
const FunctionSP &)> lambda)
const {
67 std::vector<lldb::FunctionSP> sorted_functions;
70 sorted_functions.push_back(p.second);
71 llvm::sort(sorted_functions,
73 return a->GetID() < b->GetID();
76 for (
auto &f : sorted_functions)
82 llvm::function_ref<
bool(
const FunctionSP &)> matching_lambda) {
90 SymbolFile *symbol_file = module->GetSymbolFile();
99 if (matching_lambda(p.second))
107 return "<not loaded>";
118 s->
Printf(
"%p: ",
static_cast<const void *
>(
this));
120 *s <<
"CompileUnit" <<
static_cast<const UserID &
>(*this) <<
", language = \""
134 f->Dump(s, show_context);
171 symfile->ParseLineTable(*
this);
178 if (line_table ==
nullptr)
190 symfile->ParseDebugMacros(*
this);
198 if (debug_macros_sp.get() ==
nullptr)
210 sc.
module_sp->GetSymbolFile()->ParseVariablesForContext(sc);
219 std::vector<uint32_t> result;
223 result.push_back(idx);
228 const FileSpec *file_spec_ptr,
bool exact,
234 if (file_indexes.empty())
245 start_idx, file_indexes, location_spec, line_entry_ptr);
254 const uint32_t line = src_location_spec.
GetLine().value_or(0);
260 bool file_spec_matches_cu_file_spec =
265 if (!file_spec_matches_cu_file_spec && !check_inlines)
272 if (file_spec_matches_cu_file_spec && !check_inlines) {
280 std::vector<uint32_t> file_indexes =
282 const size_t num_file_indexes = file_indexes.size();
283 if (num_file_indexes == 0)
287 GetModule()->GetSymbolFile()->SetLoadDebugInfoEnabled();
291 if (line_table ==
nullptr) {
292 if (file_spec_matches_cu_file_spec && !check_inlines) {
301 if (num_file_indexes == 1) {
306 0, file_indexes.front(), src_location_spec, &line_entry);
312 0, file_indexes, src_location_spec, &line_entry);
319 const bool inlines =
false;
320 const bool exact =
true;
321 const std::optional<uint16_t> column =
322 src_location_spec.
GetColumn() ? std::optional<uint16_t>(line_entry.
column)
334 if (resolve_scope == eSymbolContextLineEntry) {
352 sc_list.
Append(resolved_sc);
362 "unable to resolve a line table file address {0:x16} back "
363 "to a compile unit, please file a bug and attach the address "
371 if (num_file_indexes == 1)
373 line_idx + 1, file_indexes.front(), found_entry, &line_entry);
376 line_idx + 1, file_indexes, found_entry, &line_entry);
384 if (symfile->ParseIsOptimized(*
this))
409 llvm::DenseSet<SymbolFile *> &visited_symbol_files,
410 llvm::function_ref<
bool(
Module &)> lambda) {
412 return symfile->ForEachExternalModule(*
this, visited_symbol_files, lambda);
std::vector< uint32_t > FindFileIndexes(const SupportFileList &files, const FileSpec &file, RealpathPrefixes *realpath_prefixes=nullptr)
#define LLDB_SCOPED_TIMER()
Address & GetBaseAddress()
Get accessor for the base address of the range.
uint32_t CalculateSymbolContext(SymbolContext *sc, lldb::SymbolContextItem resolve_scope=lldb::eSymbolContextEverything) const
Reconstruct a symbol context from an address.
lldb::addr_t GetFileAddress() const
Get the file address.
A class that describes a compilation unit.
void SetVariableList(lldb::VariableListSP &variable_list_sp)
Set accessor for the variable list.
void Dump(Stream *s, bool show_context) const
Dump the compile unit contents to the stream s.
const SupportFileList & GetSupportFiles()
Get the compile unit's support file list.
lldb::LanguageType m_language
The programming language enumeration value.
const std::vector< SourceModule > & GetImportedModules()
Get the compile unit's imported module list.
lldb::VariableListSP GetVariableList(bool can_create)
Get the variable list for a compile unit.
lldb_private::LazyBool m_is_optimized
eLazyBoolYes if this compile unit was compiled with optimization.
void SetDebugMacros(const DebugMacrosSP &debug_macros)
const FileSpec & GetPrimaryFile() const
Return the primary source spec 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.
@ flagsParsedLanguage
Have we parsed the language already?
@ flagsParsedSupportFiles
Have we already parsed the support files for this compile unit?
@ flagsParsedImportedModules
Have we parsed the imported modules already?
@ flagsParsedDebugMacros
Have we parsed the debug macros already?
@ flagsParsedLineTable
Have we parsed the line table already?
Flags m_flags
Compile unit flags that help with partial parsing.
lldb::FunctionSP FindFunction(llvm::function_ref< bool(const lldb::FunctionSP &)> matching_lambda)
Find a function in the compile unit based on the predicate matching_lambda.
void * GetUserData() const
Get the SymbolFile plug-in user data.
bool GetIsOptimized()
Get whether compiler optimizations were enabled for this compile unit.
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
lldb::ModuleSP CalculateSymbolContextModule() override
void ResolveSymbolContext(const SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list, RealpathPrefixes *realpath_prefixes=nullptr)
Resolve symbol contexts by file and line.
DebugMacros * GetDebugMacros()
void SetLineTable(LineTable *line_table)
Set the line table for the compile unit.
virtual bool ForEachExternalModule(llvm::DenseSet< lldb_private::SymbolFile * > &visited_symbol_files, llvm::function_ref< bool(Module &)> lambda)
Apply a lambda to each external lldb::Module referenced by this compilation unit.
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
void AddFunction(lldb::FunctionSP &function_sp)
Add a function to this compile unit.
lldb::FunctionSP FindFunctionByUID(lldb::user_id_t uid)
Finds a function by user ID.
DebugMacrosSP m_debug_macros_sp
Debug macros that will get parsed on demand.
std::unique_ptr< LineTable > m_line_table_up
Line table that will get parsed on demand.
const char * GetCachedLanguage() const
CompileUnit * CalculateSymbolContextCompileUnit() override
CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, lldb::user_id_t uid, lldb::LanguageType language, lldb_private::LazyBool is_optimized)
Construct with a module, path, UID and language.
SupportFileList m_support_files
Files associated with this compile unit's line table and declarations.
lldb::VariableListSP m_variables
Global and static variable list that will get parsed on demand.
uint32_t FindLineEntry(uint32_t start_idx, uint32_t line, const FileSpec *file_spec_ptr, bool exact, LineEntry *line_entry)
Find the line entry by line and optional inlined file spec.
void GetDescription(Stream *s, lldb::DescriptionLevel level) const
std::vector< SourceModule > m_imported_modules
All modules, including the current module, imported by this compile unit.
lldb::LanguageType GetLanguage()
llvm::DenseMap< lldb::user_id_t, lldb::FunctionSP > m_functions_by_uid
Maps UIDs to functions.
LineTable * GetLineTable()
Get the line table for the compile unit.
void * m_user_data
User data for the SymbolFile parser to store information into.
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
bool IsClear(ValueType bit) const
Test a single flag bit to see if it is clear (zero).
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
static const char * GetNameForLanguageType(lldb::LanguageType language)
uint32_t FindLineEntryIndexByFileIndex(uint32_t start_idx, uint32_t file_idx, const SourceLocationSpec &src_location_spec, LineEntry *line_entry_ptr)
Find a line entry index that has a matching file index and source line number.
A mix in class that contains a pointer back to the module that owns the object which inherits from it...
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
A class that describes an executable image and its associated object and symbol files.
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
std::optional< uint32_t > GetLine() const
bool GetCheckInlines() const
std::optional< uint16_t > GetColumn() const
FileSpec GetFileSpec() const
A stream class that can stream formatted output to a file.
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 EOL()
Output and End of Line character to the stream.
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
void IndentMore(unsigned amount=2)
Increment the current indentation level.
A list of support files for a CompileUnit.
size_t FindCompatibleIndex(size_t idx, const FileSpec &file, RealpathPrefixes *realpath_prefixes=nullptr) const
Find a compatible file index.
Wraps either a FileSpec that represents a local file or a source file whose contents is known (for ex...
Defines a list of symbol context objects.
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::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
LineEntry line_entry
The LineEntry for a given query.
Provides public interface for all SymbolFiles.
virtual size_t ParseFunctions(CompileUnit &comp_unit)=0
A class that represents a running process on the host machine.
std::shared_ptr< DebugMacros > DebugMacrosSP
std::shared_ptr< lldb_private::Function > FunctionSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::SupportFile > SupportFileSP
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::Module > ModuleSP
A line table entry class.
uint16_t column
The column number of the source line, or zero if there is no column information.
AddressRange range
The section offset address range for this line entry.
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
const FileSpec & GetFile() const
Helper to access the file.
A mix in class that contains a generic user ID.
lldb::user_id_t GetID() const
Get accessor for the user ID.