LLDB mainline
CompileUnit.cpp
Go to the documentation of this file.
1//===-- CompileUnit.cpp ---------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "lldb/Core/Module.h"
15#include "lldb/Utility/Timer.h"
16#include <optional>
17
18using namespace lldb;
19using namespace lldb_private;
20
21CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
22 const char *pathname, const lldb::user_id_t cu_sym_id,
23 lldb::LanguageType language,
24 lldb_private::LazyBool is_optimized)
25 : CompileUnit(module_sp, user_data,
26 std::make_shared<SupportFile>(FileSpec(pathname)), cu_sym_id,
27 language, is_optimized) {}
28
29CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
30 SupportFileNSP support_file_nsp,
31 const lldb::user_id_t cu_sym_id,
32 lldb::LanguageType language,
33 lldb_private::LazyBool is_optimized,
34 SupportFileList &&support_files)
35 : ModuleChild(module_sp), UserID(cu_sym_id), m_user_data(user_data),
36 m_language(language), m_flags(0),
37 m_primary_support_file_nsp(support_file_nsp),
38 m_support_files(std::move(support_files)), m_is_optimized(is_optimized) {
39 if (language != eLanguageTypeUnknown)
41 assert(module_sp);
42}
43
45 sc->comp_unit = this;
46 GetModule()->CalculateSymbolContext(sc);
47}
48
50
52
54 GetModule()->DumpSymbolContext(s);
55 s->Printf(", CompileUnit{0x%8.8" PRIx64 "}", GetID());
56}
57
59 lldb::DescriptionLevel level) const {
60 const char *language = GetCachedLanguage();
61 *s << "id = " << (const UserID &)*this << ", file = \""
62 << this->GetPrimaryFile() << "\", language = \"" << language << '"';
63}
64
66 llvm::function_ref<bool(const FunctionSP &)> lambda) const {
67 std::vector<lldb::FunctionSP> sorted_functions;
68 sorted_functions.reserve(m_functions_by_uid.size());
69 for (auto &p : m_functions_by_uid)
70 sorted_functions.push_back(p.second);
71 llvm::sort(sorted_functions,
72 [](const lldb::FunctionSP &a, const lldb::FunctionSP &b) {
73 return a->GetID() < b->GetID();
74 });
75
76 for (auto &f : sorted_functions)
77 if (lambda(f))
78 return;
79}
80
82 llvm::function_ref<bool(const FunctionSP &)> matching_lambda) {
84
86
87 if (!module)
88 return {};
89
90 SymbolFile *symbol_file = module->GetSymbolFile();
91
92 if (!symbol_file)
93 return {};
94
95 // m_functions_by_uid is filled in lazily but we need all the entries.
96 symbol_file->ParseFunctions(*this);
97
98 for (auto &p : m_functions_by_uid) {
99 if (matching_lambda(p.second))
100 return p.second;
101 }
102 return {};
103}
104
106 if (m_flags.IsClear(flagsParsedLanguage))
107 return "<not loaded>";
109}
110
111// Dump the current contents of this object. No functions that cause on demand
112// parsing of functions, globals, statics are called, so this is a good
113// function to call to get an idea of the current contents of the CompileUnit
114// object.
115void CompileUnit::Dump(Stream *s, bool show_context) const {
116 const char *language = GetCachedLanguage();
117
118 s->Printf("%p: ", static_cast<const void *>(this));
119 s->Indent();
120 *s << "CompileUnit" << static_cast<const UserID &>(*this) << ", language = \""
121 << language << "\", file = '" << GetPrimaryFile() << "'\n";
122
123 // m_types.Dump(s);
124
125 if (m_variables.get()) {
126 s->IndentMore();
127 m_variables->Dump(s, show_context);
128 s->IndentLess();
129 }
130
131 if (!m_functions_by_uid.empty()) {
132 s->IndentMore();
133 ForeachFunction([&s, show_context](const FunctionSP &f) {
134 f->Dump(s, show_context);
135 return false;
136 });
137
138 s->IndentLess();
139 s->EOL();
140 }
141}
142
143// Add a function to this compile unit
145 m_functions_by_uid[funcSP->GetID()] = funcSP;
146}
147
149 auto it = m_functions_by_uid.find(func_uid);
150 if (it == m_functions_by_uid.end())
151 return FunctionSP();
152 return it->second;
153}
154
156 ModuleSP module_sp = GetModule();
157
158 std::lock_guard<std::recursive_mutex> guard(GetMutex());
160 if (m_flags.IsClear(flagsParsedLanguage)) {
162 if (SymbolFile *symfile = module_sp->GetSymbolFile())
163 m_language = symfile->ParseLanguage(*this);
164 }
165 }
166 return m_language;
167}
168
170 ModuleSP module_sp = GetModule();
171
172 std::lock_guard<std::recursive_mutex> guard(GetMutex());
173 if (m_line_table_up == nullptr) {
174 // The flag is set before parsing so that a SymbolFile that asks for the
175 // line table while parsing it doesn't recurse forever.
176 if (m_flags.IsClear(flagsParsedLineTable)) {
178 if (SymbolFile *symfile = module_sp->GetSymbolFile())
179 symfile->ParseLineTable(*this);
180 }
181 }
182 return m_line_table_up.get();
183}
184
186 // SymbolFile calls this while holding the Module's lock, which is the lock
187 // GetLineTable() takes as well.
188 if (line_table == nullptr)
190 else
192 m_line_table_up.reset(line_table);
193}
194
196 ModuleSP module_sp = GetModule();
197
198 std::lock_guard<std::recursive_mutex> guard(GetMutex());
199 if (m_debug_macros_sp.get() == nullptr) {
200 if (m_flags.IsClear(flagsParsedDebugMacros)) {
202 if (SymbolFile *symfile = module_sp->GetSymbolFile())
203 symfile->ParseDebugMacros(*this);
204 }
205 }
206
207 return m_debug_macros_sp.get();
208}
209
210void CompileUnit::SetDebugMacros(const DebugMacrosSP &debug_macros_sp) {
211 if (debug_macros_sp.get() == nullptr)
213 else
215 m_debug_macros_sp = debug_macros_sp;
216}
217
219 if (m_variables.get() == nullptr && can_create) {
220 SymbolContext sc;
222 assert(sc.module_sp);
223 sc.module_sp->GetSymbolFile()->ParseVariablesForContext(sc);
224 }
225
226 return m_variables;
227}
228
229std::vector<uint32_t>
230FindFileIndexes(const SupportFileList &files, const FileSpec &file,
231 RealpathPrefixes *realpath_prefixes = nullptr) {
232 std::vector<uint32_t> result;
233 uint32_t idx = -1;
234 while ((idx = files.FindCompatibleIndex(idx + 1, file, realpath_prefixes)) !=
236 result.push_back(idx);
237 return result;
238}
239
240uint32_t CompileUnit::FindLineEntry(uint32_t start_idx, uint32_t line,
241 const FileSpec *file_spec_ptr, bool exact,
242 LineEntry *line_entry_ptr) {
243 if (!file_spec_ptr)
244 file_spec_ptr = &GetPrimaryFile();
245 std::vector<uint32_t> file_indexes = FindFileIndexes(GetSupportFiles(),
246 *file_spec_ptr);
247 if (file_indexes.empty())
248 return UINT32_MAX;
249
250 // TODO: Handle SourceLocationSpec column information
251 SourceLocationSpec location_spec(*file_spec_ptr, line,
252 /*column=*/std::nullopt,
253 /*check_inlines=*/false, exact);
254
255 LineTable *line_table = GetLineTable();
256 if (line_table)
257 return line_table->FindLineEntryIndexByFileIndex(
258 start_idx, file_indexes, location_spec, line_entry_ptr);
259 return UINT32_MAX;
260}
261
263 const SourceLocationSpec &src_location_spec,
264 SymbolContextItem resolve_scope, SymbolContextList &sc_list,
265 RealpathPrefixes *realpath_prefixes) {
266 const FileSpec file_spec = src_location_spec.GetFileSpec();
267 const uint32_t line =
268 src_location_spec.GetLine().value_or(LLDB_INVALID_LINE_NUMBER);
269 const uint32_t column_num =
270 src_location_spec.GetColumn().value_or(LLDB_INVALID_COLUMN_NUMBER);
271 const bool check_inlines = src_location_spec.GetCheckInlines();
272
273 // First find all of the file indexes that match our "file_spec". If
274 // "file_spec" has an empty directory, then only compare the basenames when
275 // finding file indexes
276 bool file_spec_matches_cu_file_spec =
277 FileSpec::Match(file_spec, this->GetPrimaryFile());
278
279 // If we are not looking for inlined functions and our file spec doesn't
280 // match then we are done...
281 if (!file_spec_matches_cu_file_spec && !check_inlines)
282 return;
283
285 sc.comp_unit = this;
286
287 if (line == LLDB_INVALID_LINE_NUMBER) {
288 if (file_spec_matches_cu_file_spec && !check_inlines) {
289 // only append the context if we aren't looking for inline call sites by
290 // file and line and if the file spec matches that of the compile unit
291 sc_list.Append(sc);
292 }
293 return;
294 }
295
296 std::vector<uint32_t> file_indexes =
297 FindFileIndexes(GetSupportFiles(), file_spec, realpath_prefixes);
298 const size_t num_file_indexes = file_indexes.size();
299 if (num_file_indexes == 0)
300 return;
301
302 // Found a matching source file in this compile unit load its debug info.
303 GetModule()->GetSymbolFile()->SetLoadDebugInfoEnabled();
304
305 LineTable *line_table = sc.comp_unit->GetLineTable();
306
307 if (line_table == nullptr) {
308 if (file_spec_matches_cu_file_spec && !check_inlines) {
309 sc_list.Append(sc);
310 }
311 return;
312 }
313
314 uint32_t line_idx;
315 LineEntry line_entry;
316
317 if (num_file_indexes == 1) {
318 // We only have a single support file that matches, so use the line
319 // table function that searches for a line entries that match a single
320 // support file index
321 line_idx = line_table->FindLineEntryIndexByFileIndex(
322 0, file_indexes.front(), src_location_spec, &line_entry);
323 } else {
324 // We found multiple support files that match "file_spec" so use the
325 // line table function that searches for a line entries that match a
326 // multiple support file indexes.
327 line_idx = line_table->FindLineEntryIndexByFileIndex(
328 0, file_indexes, src_location_spec, &line_entry);
329 }
330
331 // If we didn't manage to find a breakpoint that matched the line number
332 // requested, that might be because it is only an inline call site, and
333 // doesn't have a line entry in the line table. Scan for that here.
334 //
335 // We are making the assumption that if there was an inlined function it will
336 // contribute at least 1 non-call-site entry to the line table. That's handy
337 // because we don't move line breakpoints over function boundaries, so if we
338 // found a hit, and there were also a call site entry, it would have to be in
339 // the function containing the PC of the line table match. That way we can
340 // limit the call site search to that function.
341 // We will miss functions that ONLY exist as a call site entry.
342
343 if (line_entry.IsValid() &&
344 (line_entry.line != line ||
345 (column_num != 0 && line_entry.column != column_num)) &&
346 (resolve_scope & eSymbolContextLineEntry) && check_inlines) {
347 // We don't move lines over function boundaries, so the address in the
348 // line entry will be the in function that contained the line that might
349 // be a CallSite, and we can just iterate over that function to find any
350 // inline records, and dig up their call sites.
351 Address start_addr = line_entry.range.GetBaseAddress();
352 Function *function = start_addr.CalculateSymbolContextFunction();
353 // Record the size of the list to see if we added to it:
354 size_t old_sc_list_size = sc_list.GetSize();
355
356 Declaration sought_decl(file_spec, line, column_num);
357 // We use this recursive function to descend the block structure looking
358 // for a block that has this Declaration as in it's CallSite info.
359 // This function recursively scans the sibling blocks of the incoming
360 // block parameter.
361 std::function<void(Block &)> examine_block =
362 [&sought_decl, &sc_list, &src_location_spec, resolve_scope,
363 &examine_block](Block &block) -> void {
364 // Iterate over the sibling child blocks of the incoming block.
365 Block *sibling_block = block.GetFirstChild();
366 while (sibling_block) {
367 // We only have to descend through the regular blocks, looking for
368 // immediate inlines, since those are the only ones that will have this
369 // callsite.
370 const InlineFunctionInfo *inline_info =
371 sibling_block->GetInlinedFunctionInfo();
372 if (inline_info) {
373 // If this is the call-site we are looking for, record that:
374 // We need to be careful because the call site from the debug info
375 // will generally have a column, but the user might not have specified
376 // it.
377 Declaration found_decl = inline_info->GetCallSite();
378 uint32_t sought_column = sought_decl.GetColumn();
379 if (found_decl.FileAndLineEqual(sought_decl, false) &&
380 (sought_column == LLDB_INVALID_COLUMN_NUMBER ||
381 sought_column == found_decl.GetColumn())) {
382 // If we found a call site, it belongs not in this inlined block,
383 // but in the parent block that inlined it.
384 Address parent_start_addr;
385 if (sibling_block->GetParent()->GetStartAddress(
386 parent_start_addr)) {
387 SymbolContext sc;
388 parent_start_addr.CalculateSymbolContext(&sc, resolve_scope);
389 // Now swap out the line entry for the one we found.
390 LineEntry call_site_line = sc.line_entry;
391 call_site_line.line = found_decl.GetLine();
392 call_site_line.column = found_decl.GetColumn();
393 bool matches_spec = true;
394 // If the user asked for an exact match, we need to make sure the
395 // call site we found actually matches the location.
396 if (src_location_spec.GetExactMatch()) {
397 matches_spec = false;
398 if ((src_location_spec.GetFileSpec() ==
399 sc.line_entry.GetFile()) &&
400 (src_location_spec.GetLine() &&
401 *src_location_spec.GetLine() == call_site_line.line) &&
402 (src_location_spec.GetColumn() &&
403 *src_location_spec.GetColumn() == call_site_line.column))
404 matches_spec = true;
405 }
406 if (matches_spec &&
407 sibling_block->GetRangeAtIndex(0, call_site_line.range)) {
408 SymbolContext call_site_sc(sc.target_sp, sc.module_sp,
409 sc.comp_unit, sc.function, sc.block,
410 &call_site_line, sc.symbol);
411 sc_list.Append(call_site_sc);
412 }
413 }
414 }
415 }
416
417 // Descend into the child blocks:
418 examine_block(*sibling_block);
419 // Now go to the next sibling:
420 sibling_block = sibling_block->GetSibling();
421 }
422 };
423
424 if (function) {
425 // We don't need to examine the function block, it can't be inlined.
426 Block &func_block = function->GetBlock(true);
427 examine_block(func_block);
428 }
429 // If we found entries here, we are done. We only get here because we
430 // didn't find an exact line entry for this line & column, but if we found
431 // an exact match from the call site info that's strictly better than
432 // continuing to look for matches further on in the file.
433 // FIXME: Should I also do this for "call site line exists between the
434 // given line number and the later line we found in the line table"? That's
435 // a closer approximation to our general sliding algorithm.
436 if (sc_list.GetSize() > old_sc_list_size)
437 return;
438 }
439
440 // If "exact == true", then "found_line" will be the same as "line". If
441 // "exact == false", the "found_line" will be the closest line entry
442 // with a line number greater than "line" and we will use this for our
443 // subsequent line exact matches below.
444 const bool inlines = false;
445 const bool exact = true;
446 const std::optional<uint16_t> column =
447 src_location_spec.GetColumn() ? std::optional<uint16_t>(line_entry.column)
448 : std::nullopt;
449
450 SourceLocationSpec found_entry(line_entry.GetFile(), line_entry.line, column,
451 inlines, exact);
452
453 while (line_idx != UINT32_MAX) {
454 // If they only asked for the line entry, then we're done, we can
455 // just copy that over. But if they wanted more than just the line
456 // number, fill it in.
457 SymbolContext resolved_sc;
458 sc.line_entry = line_entry;
459 if (resolve_scope == eSymbolContextLineEntry) {
460 sc_list.Append(sc);
461 } else {
462 line_entry.range.GetBaseAddress().CalculateSymbolContext(&resolved_sc,
463 resolve_scope);
464 // Sometimes debug info is bad and isn't able to resolve the line entry's
465 // address back to the same compile unit and/or line entry. If the compile
466 // unit changed, then revert back to just the compile unit and line entry.
467 // Prior to this fix, the above code might end up not being able to lookup
468 // the address, and then it would clear compile unit and the line entry in
469 // the symbol context and the breakpoint would fail to get set even though
470 // we have a valid line table entry in this compile unit. The address
471 // lookup can also end up finding another function in another compiler
472 // unit if the DWARF has overlappging address ranges. So if we end up with
473 // no compile unit or a different one after the above function call,
474 // revert back to the same results as if resolve_scope was set exactly to
475 // eSymbolContextLineEntry.
476 if (resolved_sc.comp_unit == this) {
477 sc_list.Append(resolved_sc);
478 } else {
479 if (resolved_sc.comp_unit == nullptr && resolved_sc.module_sp) {
480 // Only report an error if we don't map back to any compile unit. With
481 // link time optimizations, the debug info might have many compile
482 // units that have the same address range due to function outlining
483 // or other link time optimizations. If the compile unit is NULL, then
484 // address resolving is completely failing and more deserving of an
485 // error message the user can see.
486 resolved_sc.module_sp->ReportError(
487 "unable to resolve a line table file address {0:x16} back "
488 "to a compile unit, please file a bug and attach the address "
489 "and file.",
490 line_entry.range.GetBaseAddress().GetFileAddress());
491 }
492 sc_list.Append(sc);
493 }
494 }
495
496 if (num_file_indexes == 1)
497 line_idx = line_table->FindLineEntryIndexByFileIndex(
498 line_idx + 1, file_indexes.front(), found_entry, &line_entry);
499 else
500 line_idx = line_table->FindLineEntryIndexByFileIndex(
501 line_idx + 1, file_indexes, found_entry, &line_entry);
502 }
503}
504
506 ModuleSP module_sp = GetModule();
507
508 std::lock_guard<std::recursive_mutex> guard(GetMutex());
511 if (SymbolFile *symfile = module_sp->GetSymbolFile()) {
512 if (symfile->ParseIsOptimized(*this))
514 }
515 }
516 return m_is_optimized;
517}
518
519std::recursive_mutex &CompileUnit::GetMutex() const {
520 ModuleSP module_sp = GetModule();
521 assert(module_sp && "Called without module?");
522 return module_sp->GetMutex();
523}
524
526 m_variables = variables;
527}
528
529const std::vector<SourceModule> &CompileUnit::GetImportedModules() {
530 ModuleSP module_sp = GetModule();
531
532 std::lock_guard<std::recursive_mutex> guard(GetMutex());
533 if (m_imported_modules.empty() &&
536 if (SymbolFile *symfile = module_sp->GetSymbolFile()) {
537 SymbolContext sc;
539 symfile->ParseImportedModules(sc, m_imported_modules);
540 }
541 }
542 return m_imported_modules;
543}
544
546 llvm::DenseSet<SymbolFile *> &visited_symbol_files,
547 llvm::function_ref<bool(Module &)> lambda) {
548 if (SymbolFile *symfile = GetModule()->GetSymbolFile())
549 return symfile->ForEachExternalModule(*this, visited_symbol_files, lambda);
550 return false;
551}
552
554 ModuleSP module_sp = GetModule();
555
556 std::lock_guard<std::recursive_mutex> guard(GetMutex());
557 if (m_support_files.GetSize() == 0) {
558 if (m_flags.IsClear(flagsParsedSupportFiles)) {
560 if (SymbolFile *symfile = module_sp->GetSymbolFile())
561 symfile->ParseSupportFiles(*this, m_support_files);
562 }
563 }
564 return m_support_files;
565}
566
567void *CompileUnit::GetUserData() const { return m_user_data; }
std::vector< uint32_t > FindFileIndexes(const SupportFileList &files, const FileSpec &file, RealpathPrefixes *realpath_prefixes=nullptr)
#define LLDB_SCOPED_TIMER()
Definition Timer.h:83
Address & GetBaseAddress()
Get accessor for the base address of the range.
A section + offset based address class.
Definition Address.h:62
uint32_t CalculateSymbolContext(SymbolContext *sc, lldb::SymbolContextItem resolve_scope=lldb::eSymbolContextEverything) const
Reconstruct a symbol context from an address.
Definition Address.cpp:820
Function * CalculateSymbolContextFunction() const
Definition Address.cpp:860
lldb::addr_t GetFileAddress() const
Get the file address.
Definition Address.cpp:283
A class that describes a single lexical block.
Definition Block.h:41
Block * GetFirstChild() const
Get the first child block.
Definition Block.h:194
bool GetRangeAtIndex(uint32_t range_idx, AddressRange &range)
Definition Block.cpp:294
const InlineFunctionInfo * GetInlinedFunctionInfo() const
Get const accessor for any inlined function information.
Definition Block.h:268
Block * GetSibling() const
Get the sibling block for this block.
Definition Block.cpp:488
Block * GetParent() const
Get the parent block.
Definition Block.cpp:202
bool GetStartAddress(Address &addr)
Definition Block.cpp:317
void SetVariableList(lldb::VariableListSP &variable_list_sp)
Set accessor for the variable list.
@ 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?
std::recursive_mutex & GetMutex() const
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.
SupportFileNSP m_primary_support_file_nsp
The primary file associated with this compile unit.
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.
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.
Definition Declaration.h:24
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.
A file utility class.
Definition FileSpec.h:56
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
Definition FileSpec.cpp:317
A class that describes a function.
Definition Function.h:386
Block & GetBlock(bool can_create)
Get accessor for the block list.
Definition Function.cpp:401
A class that describes information for an inlined function.
Definition Function.h:120
Declaration & GetCallSite()
Get accessor for the call site declaration information.
Definition Function.cpp:105
static const char * GetNameForLanguageType(lldb::LanguageType language)
Returns the internal LLDB name for the specified language.
Definition Language.cpp:305
A line table class.
Definition LineTable.h:25
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.
ModuleChild(const lldb::ModuleSP &module_sp)
Construct with owning module.
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.
Definition Module.h:91
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
std::optional< uint32_t > GetLine() const
std::optional< uint16_t > GetColumn() const
A stream class that can stream formatted output to a file.
Definition Stream.h:28
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition Stream.cpp:157
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
size_t EOL()
Output and End of Line character to the stream.
Definition Stream.cpp:155
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition Stream.cpp:204
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition Stream.cpp:201
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.
Definition SupportFile.h:22
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.
Definition SymbolFile.h:51
virtual size_t ParseFunctions(CompileUnit &comp_unit)=0
#define LLDB_INVALID_LINE_NUMBER
#define LLDB_INVALID_COLUMN_NUMBER
#define UINT32_MAX
A class that represents a running process on the host machine.
NonNullSharedPtr< lldb_private::SupportFile > SupportFileNSP
Definition SupportFile.h:80
std::shared_ptr< DebugMacros > DebugMacrosSP
Definition DebugMacros.h:22
std::shared_ptr< lldb_private::Function > FunctionSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::VariableList > VariableListSP
uint64_t user_id_t
Definition lldb-types.h:83
std::shared_ptr< lldb_private::Module > ModuleSP
A line table entry class.
Definition LineEntry.h:21
uint16_t column
The column number of the source line, or zero if there is no column information.
Definition LineEntry.h:155
bool IsValid() const
Check if a line entry object is valid.
Definition LineEntry.cpp:35
AddressRange range
The section offset address range for this line entry.
Definition LineEntry.h:137
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
Definition LineEntry.h:151
const FileSpec & GetFile() const
Helper to access the file.
Definition LineEntry.h:134
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
Definition UserID.h:33
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition UserID.h:47