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 =
256 const uint32_t column_num =
263 bool file_spec_matches_cu_file_spec =
268 if (!file_spec_matches_cu_file_spec && !check_inlines)
275 if (file_spec_matches_cu_file_spec && !check_inlines) {
283 std::vector<uint32_t> file_indexes =
285 const size_t num_file_indexes = file_indexes.size();
286 if (num_file_indexes == 0)
290 GetModule()->GetSymbolFile()->SetLoadDebugInfoEnabled();
294 if (line_table ==
nullptr) {
295 if (file_spec_matches_cu_file_spec && !check_inlines) {
304 if (num_file_indexes == 1) {
309 0, file_indexes.front(), src_location_spec, &line_entry);
315 0, file_indexes, src_location_spec, &line_entry);
331 (line_entry.
line != line ||
332 (column_num != 0 && line_entry.
column != column_num)) &&
333 (resolve_scope & eSymbolContextLineEntry) && check_inlines) {
341 size_t old_sc_list_size = sc_list.
GetSize();
343 Declaration sought_decl(file_spec, line, column_num);
348 std::function<void(
Block &)> examine_block =
349 [&sought_decl, &sc_list, &src_location_spec, resolve_scope,
350 &examine_block](
Block &block) ->
void {
353 while (sibling_block) {
365 uint32_t sought_column = sought_decl.
GetColumn();
368 sought_column == found_decl.
GetColumn())) {
373 parent_start_addr)) {
380 bool matches_spec =
true;
383 if (src_location_spec.GetExactMatch()) {
384 matches_spec =
false;
385 if ((src_location_spec.GetFileSpec() ==
387 (src_location_spec.GetLine() &&
388 *src_location_spec.GetLine() == call_site_line.
line) &&
389 (src_location_spec.GetColumn() &&
390 *src_location_spec.GetColumn() == call_site_line.
column))
397 &call_site_line, sc.
symbol);
398 sc_list.Append(call_site_sc);
405 examine_block(*sibling_block);
414 examine_block(func_block);
423 if (sc_list.GetSize() > old_sc_list_size)
431 const bool inlines =
false;
432 const bool exact =
true;
433 const std::optional<uint16_t> column =
434 src_location_spec.
GetColumn() ? std::optional<uint16_t>(line_entry.
column)
446 if (resolve_scope == eSymbolContextLineEntry) {
464 sc_list.
Append(resolved_sc);
474 "unable to resolve a line table file address {0:x16} back "
475 "to a compile unit, please file a bug and attach the address "
483 if (num_file_indexes == 1)
485 line_idx + 1, file_indexes.front(), found_entry, &line_entry);
488 line_idx + 1, file_indexes, found_entry, &line_entry);
496 if (symfile->ParseIsOptimized(*
this))
521 llvm::DenseSet<SymbolFile *> &visited_symbol_files,
522 llvm::function_ref<
bool(
Module &)> lambda) {
524 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.
A section + offset based address class.
uint32_t CalculateSymbolContext(SymbolContext *sc, lldb::SymbolContextItem resolve_scope=lldb::eSymbolContextEverything) const
Reconstruct a symbol context from an address.
Function * CalculateSymbolContextFunction() const
lldb::addr_t GetFileAddress() const
Get the file address.
A class that describes a single lexical block.
Block * GetFirstChild() const
Get the first child block.
bool GetRangeAtIndex(uint32_t range_idx, AddressRange &range)
const InlineFunctionInfo * GetInlinedFunctionInfo() const
Get const accessor for any inlined function information.
Block * GetSibling() const
Get the sibling block for this block.
Block * GetParent() const
Get the parent block.
bool GetStartAddress(Address &addr)
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.
A class that describes the declaration location of a lldb object.
uint32_t GetLine() const
Get accessor for the declaration line number.
uint16_t GetColumn() const
Get accessor for the declaration column number.
bool FileAndLineEqual(const Declaration &declaration, bool full) const
Checks if this object has the same file and line as another declaration object.
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.
A class that describes a function.
Block & GetBlock(bool can_create)
Get accessor for the block list.
A class that describes information for an inlined function.
Declaration & GetCallSite()
Get accessor for the call site declaration information.
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 a FileSpec and an optional Checksum.
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
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.
Function * function
The Function for a given query.
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.
Symbol * symbol
The Symbol for a given query.
lldb::TargetSP target_sp
The Target 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
#define LLDB_INVALID_LINE_NUMBER
#define LLDB_INVALID_COLUMN_NUMBER
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.
bool IsValid() const
Check if a line entry object is valid.
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.