LLDB mainline
Function.cpp
Go to the documentation of this file.
1//===-- Function.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/Debugger.h"
12#include "lldb/Core/Module.h"
14#include "lldb/Core/Section.h"
15#include "lldb/Host/Host.h"
21#include "lldb/Target/Target.h"
23#include "lldb/Utility/Log.h"
24#include "llvm/Support/Casting.h"
25
26using namespace lldb;
27using namespace lldb_private;
28
29// Basic function information is contained in the FunctionInfo class. It is
30// designed to contain the name, linkage name, and declaration location.
31FunctionInfo::FunctionInfo(const char *name, const Declaration *decl_ptr)
32 : m_name(name), m_declaration(decl_ptr) {}
33
35 : m_name(name), m_declaration(decl_ptr) {}
36
38
39void FunctionInfo::Dump(Stream *s, bool show_fullpaths) const {
40 if (m_name)
41 *s << ", name = \"" << m_name << "\"";
42 m_declaration.Dump(s, show_fullpaths);
43}
44
46 int result = ConstString::Compare(a.GetName(), b.GetName());
47 if (result)
48 return result;
49
51}
52
54
56 return m_declaration;
57}
58
60
63}
64
66 llvm::StringRef mangled,
67 const Declaration *decl_ptr,
68 const Declaration *call_decl_ptr)
69 : FunctionInfo(name, decl_ptr), m_mangled(mangled),
70 m_call_decl(call_decl_ptr) {}
71
73 const Mangled &mangled,
74 const Declaration *decl_ptr,
75 const Declaration *call_decl_ptr)
76 : FunctionInfo(name, decl_ptr), m_mangled(mangled),
77 m_call_decl(call_decl_ptr) {}
78
80
81void InlineFunctionInfo::Dump(Stream *s, bool show_fullpaths) const {
82 FunctionInfo::Dump(s, show_fullpaths);
83 if (m_mangled)
84 m_mangled.Dump(s);
85}
86
88 // s->Indent("[inlined] ");
89 s->Indent();
90 if (m_mangled)
91 s->PutCString(m_mangled.GetName().AsCString());
92 else
94}
95
97 if (m_mangled)
98 return m_mangled.GetName();
99 return m_name;
100}
101
103 if (m_mangled)
104 return m_mangled.GetDisplayDemangledName();
105 return m_name;
106}
107
109
111 return m_call_decl;
112}
113
115
116const Mangled &InlineFunctionInfo::GetMangled() const { return m_mangled; }
117
119 return FunctionInfo::MemorySize() + m_mangled.MemorySize();
120}
121
122/// @name Call site related structures
123/// @{
124
126 Function &caller, Target &target) {
127 Log *log = GetLog(LLDBLog::Step);
128
129 const Address &caller_start_addr = caller.GetAddressRange().GetBaseAddress();
130
131 ModuleSP caller_module_sp = caller_start_addr.GetModule();
132 if (!caller_module_sp) {
133 LLDB_LOG(log, "GetLoadAddress: cannot get Module for caller");
135 }
136
137 SectionList *section_list = caller_module_sp->GetSectionList();
138 if (!section_list) {
139 LLDB_LOG(log, "GetLoadAddress: cannot get SectionList for Module");
141 }
142
143 Address the_addr = Address(unresolved_pc, section_list);
144 lldb::addr_t load_addr = the_addr.GetLoadAddress(&target);
145 return load_addr;
146}
147
149 Target &target) const {
150 return GetLoadAddress(GetUnresolvedReturnPCAddress(), caller, target);
151}
152
154 if (resolved)
155 return;
156
157 Log *log = GetLog(LLDBLog::Step);
158 LLDB_LOG(log, "DirectCallEdge: Lazily parsing the call graph for {0}",
159 lazy_callee.symbol_name);
160
161 auto resolve_lazy_callee = [&]() -> Function * {
162 ConstString callee_name{lazy_callee.symbol_name};
163 SymbolContextList sc_list;
164 images.FindFunctionSymbols(callee_name, eFunctionNameTypeAuto, sc_list);
165 size_t num_matches = sc_list.GetSize();
166 if (num_matches == 0 || !sc_list[0].symbol) {
167 LLDB_LOG(log,
168 "DirectCallEdge: Found no symbols for {0}, cannot resolve it",
169 callee_name);
170 return nullptr;
171 }
172 Address callee_addr = sc_list[0].symbol->GetAddress();
173 if (!callee_addr.IsValid()) {
174 LLDB_LOG(log, "DirectCallEdge: Invalid symbol address");
175 return nullptr;
176 }
177 Function *f = callee_addr.CalculateSymbolContextFunction();
178 if (!f) {
179 LLDB_LOG(log, "DirectCallEdge: Could not find complete function");
180 return nullptr;
181 }
182 return f;
183 };
184 lazy_callee.def = resolve_lazy_callee();
185 resolved = true;
186}
187
190 assert(resolved && "Did not resolve lazy callee");
191 return lazy_callee.def;
192}
193
195 ExecutionContext &exe_ctx) {
196 Log *log = GetLog(LLDBLog::Step);
198 Value callee_addr_val;
200 &exe_ctx, exe_ctx.GetRegisterContext(), LLDB_INVALID_ADDRESS,
201 /*initial_value_ptr=*/nullptr,
202 /*object_address_ptr=*/nullptr, callee_addr_val, &error)) {
203 LLDB_LOGF(log, "IndirectCallEdge: Could not evaluate expression: %s",
204 error.AsCString());
205 return nullptr;
206 }
207
208 addr_t raw_addr = callee_addr_val.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
209 if (raw_addr == LLDB_INVALID_ADDRESS) {
210 LLDB_LOG(log, "IndirectCallEdge: Could not extract address from scalar");
211 return nullptr;
212 }
213
214 Address callee_addr;
215 if (!exe_ctx.GetTargetPtr()->ResolveLoadAddress(raw_addr, callee_addr)) {
216 LLDB_LOG(log, "IndirectCallEdge: Could not resolve callee's load address");
217 return nullptr;
218 }
219
220 Function *f = callee_addr.CalculateSymbolContextFunction();
221 if (!f) {
222 LLDB_LOG(log, "IndirectCallEdge: Could not find complete function");
223 return nullptr;
224 }
225
226 return f;
227}
228
229/// @}
230
231//
233 lldb::user_id_t type_uid, const Mangled &mangled, Type *type,
234 const AddressRange &range)
235 : UserID(func_uid), m_comp_unit(comp_unit), m_type_uid(type_uid),
236 m_type(type), m_mangled(mangled), m_block(func_uid), m_range(range),
237 m_frame_base(), m_flags(), m_prologue_byte_size(0) {
239 assert(comp_unit != nullptr);
240}
241
242Function::~Function() = default;
243
245 uint32_t &line_no) {
246 line_no = 0;
247 source_file.Clear();
248
249 if (m_comp_unit == nullptr)
250 return;
251
252 // Initialize m_type if it hasn't been initialized already
253 GetType();
254
255 if (m_type != nullptr && m_type->GetDeclaration().GetLine() != 0) {
256 source_file = m_type->GetDeclaration().GetFile();
257 line_no = m_type->GetDeclaration().GetLine();
258 } else {
259 LineTable *line_table = m_comp_unit->GetLineTable();
260 if (line_table == nullptr)
261 return;
262
263 LineEntry line_entry;
264 if (line_table->FindLineEntryByAddress(GetAddressRange().GetBaseAddress(),
265 line_entry, nullptr)) {
266 line_no = line_entry.line;
267 source_file = line_entry.file;
268 }
269 }
270}
271
273 line_no = 0;
274 source_file.Clear();
275
276 // The -1 is kind of cheesy, but I want to get the last line entry for the
277 // given function, not the first entry of the next.
278 Address scratch_addr(GetAddressRange().GetBaseAddress());
279 scratch_addr.SetOffset(scratch_addr.GetOffset() +
280 GetAddressRange().GetByteSize() - 1);
281
282 LineTable *line_table = m_comp_unit->GetLineTable();
283 if (line_table == nullptr)
284 return;
285
286 LineEntry line_entry;
287 if (line_table->FindLineEntryByAddress(scratch_addr, line_entry, nullptr)) {
288 line_no = line_entry.line;
289 source_file = line_entry.file;
290 }
291}
292
293llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetCallEdges() {
294 std::lock_guard<std::mutex> guard(m_call_edges_lock);
295
297 return m_call_edges;
298
299 Log *log = GetLog(LLDBLog::Step);
300 LLDB_LOG(log, "GetCallEdges: Attempting to parse call site info for {0}",
302
304
305 // Find the SymbolFile which provided this function's definition.
306 Block &block = GetBlock(/*can_create*/true);
307 SymbolFile *sym_file = block.GetSymbolFile();
308 if (!sym_file)
309 return std::nullopt;
310
311 // Lazily read call site information from the SymbolFile.
313
314 // Sort the call edges to speed up return_pc lookups.
315 llvm::sort(m_call_edges, [](const std::unique_ptr<CallEdge> &LHS,
316 const std::unique_ptr<CallEdge> &RHS) {
317 return LHS->GetSortKey() < RHS->GetSortKey();
318 });
319
320 return m_call_edges;
321}
322
323llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetTailCallingEdges() {
324 // Tail calling edges are sorted at the end of the list. Find them by dropping
325 // all non-tail-calls.
326 return GetCallEdges().drop_until(
327 [](const std::unique_ptr<CallEdge> &edge) { return edge->IsTailCall(); });
328}
329
331 Target &target) {
332 auto edges = GetCallEdges();
333 auto edge_it =
334 llvm::partition_point(edges, [&](const std::unique_ptr<CallEdge> &edge) {
335 return std::make_pair(edge->IsTailCall(),
336 edge->GetReturnPCAddress(*this, target)) <
337 std::make_pair(false, return_pc);
338 });
339 if (edge_it == edges.end() ||
340 edge_it->get()->GetReturnPCAddress(*this, target) != return_pc)
341 return nullptr;
342 return edge_it->get();
343}
344
345Block &Function::GetBlock(bool can_create) {
346 if (!m_block.BlockInfoHasBeenParsed() && can_create) {
347 ModuleSP module_sp = CalculateSymbolContextModule();
348 if (module_sp) {
349 module_sp->GetSymbolFile()->ParseBlocksRecursive(*this);
350 } else {
351 Debugger::ReportError(llvm::formatv(
352 "unable to find module shared pointer for function '{0}' in {1}",
353 GetName().GetCString(), m_comp_unit->GetPrimaryFile().GetPath()));
354 }
356 }
357 return m_block;
358}
359
361
363
365 Target *target) {
366 ConstString name = GetName();
367 ConstString mangled = m_mangled.GetMangledName();
368
369 *s << "id = " << (const UserID &)*this;
370 if (name)
371 s->AsRawOstream() << ", name = \"" << name << '"';
372 if (mangled)
373 s->AsRawOstream() << ", mangled = \"" << mangled << '"';
374 *s << ", range = ";
375 Address::DumpStyle fallback_style;
376 if (level == eDescriptionLevelVerbose)
378 else
379 fallback_style = Address::DumpStyleFileAddress;
381 fallback_style);
382}
383
384void Function::Dump(Stream *s, bool show_context) const {
385 s->Printf("%p: ", static_cast<const void *>(this));
386 s->Indent();
387 *s << "Function" << static_cast<const UserID &>(*this);
388
389 m_mangled.Dump(s);
390
391 if (m_type)
392 s->Printf(", type = %p", static_cast<void *>(m_type));
393 else if (m_type_uid != LLDB_INVALID_UID)
394 s->Printf(", type_uid = 0x%8.8" PRIx64, m_type_uid);
395
396 s->EOL();
397 // Dump the root object
400 show_context);
401}
402
404 sc->function = this;
406}
407
409 SectionSP section_sp(m_range.GetBaseAddress().GetSection());
410 if (section_sp)
411 return section_sp->GetModule();
412
413 return this->GetCompileUnit()->GetModule();
414}
415
417 return this->GetCompileUnit();
418}
419
421
422lldb::DisassemblerSP Function::GetInstructions(const ExecutionContext &exe_ctx,
423 const char *flavor,
424 bool prefer_file_cache) {
425 ModuleSP module_sp(GetAddressRange().GetBaseAddress().GetModule());
426 if (module_sp && exe_ctx.HasTargetScope()) {
427 return Disassembler::DisassembleRange(module_sp->GetArchitecture(), nullptr,
428 flavor, exe_ctx.GetTargetRef(),
429 GetAddressRange(), !prefer_file_cache);
430 }
431 return lldb::DisassemblerSP();
432}
433
435 const char *flavor, Stream &strm,
436 bool prefer_file_cache) {
437 lldb::DisassemblerSP disassembler_sp =
438 GetInstructions(exe_ctx, flavor, prefer_file_cache);
439 if (disassembler_sp) {
440 const bool show_address = true;
441 const bool show_bytes = false;
442 const bool show_control_flow_kind = false;
443 disassembler_sp->GetInstructionList().Dump(
444 &strm, show_address, show_bytes, show_control_flow_kind, &exe_ctx);
445 return true;
446 }
447 return false;
448}
449
450// Symbol *
451// Function::CalculateSymbolContextSymbol ()
452//{
453// return // TODO: find the symbol for the function???
454//}
455
458 s->Printf(", Function{0x%8.8" PRIx64 "}", GetID());
459}
460
461size_t Function::MemorySize() const {
462 size_t mem_size = sizeof(Function) + m_block.MemorySize();
463 return mem_size;
464}
465
467 bool result = false;
468
469 // Currently optimization is only indicted by the vendor extension
470 // DW_AT_APPLE_optimized which is set on a compile unit level.
471 if (m_comp_unit) {
472 result = m_comp_unit->GetIsOptimized();
473 }
474 return result;
475}
476
478 bool result = false;
479
480 if (Language *language = Language::FindPlugin(GetLanguage()))
481 result = language->IsTopLevelFunction(*this);
482
483 return result;
484}
485
487 return m_mangled.GetDisplayDemangledName();
488}
489
491 ModuleSP module_sp = CalculateSymbolContextModule();
492
493 if (module_sp) {
494 if (SymbolFile *sym_file = module_sp->GetSymbolFile())
495 return sym_file->GetDeclContextForUID(GetID());
496 }
497 return CompilerDeclContext();
498}
499
501 if (m_type == nullptr) {
502 SymbolContext sc;
503
505
506 if (!sc.module_sp)
507 return nullptr;
508
509 SymbolFile *sym_file = sc.module_sp->GetSymbolFile();
510
511 if (sym_file == nullptr)
512 return nullptr;
513
514 m_type = sym_file->ResolveTypeUID(m_type_uid);
515 }
516 return m_type;
517}
518
519const Type *Function::GetType() const { return m_type; }
520
522 Type *function_type = GetType();
523 if (function_type)
524 return function_type->GetFullCompilerType();
525 return CompilerType();
526}
527
529 if (m_prologue_byte_size == 0 &&
532 LineTable *line_table = m_comp_unit->GetLineTable();
533 uint32_t prologue_end_line_idx = 0;
534
535 if (line_table) {
536 LineEntry first_line_entry;
537 uint32_t first_line_entry_idx = UINT32_MAX;
538 if (line_table->FindLineEntryByAddress(GetAddressRange().GetBaseAddress(),
539 first_line_entry,
540 &first_line_entry_idx)) {
541 // Make sure the first line entry isn't already the end of the prologue
542 addr_t prologue_end_file_addr = LLDB_INVALID_ADDRESS;
543 addr_t line_zero_end_file_addr = LLDB_INVALID_ADDRESS;
544
545 if (first_line_entry.is_prologue_end) {
546 prologue_end_file_addr =
547 first_line_entry.range.GetBaseAddress().GetFileAddress();
548 prologue_end_line_idx = first_line_entry_idx;
549 } else {
550 // Check the first few instructions and look for one that has
551 // is_prologue_end set to true.
552 const uint32_t last_line_entry_idx = first_line_entry_idx + 6;
553 for (uint32_t idx = first_line_entry_idx + 1;
554 idx < last_line_entry_idx; ++idx) {
555 LineEntry line_entry;
556 if (line_table->GetLineEntryAtIndex(idx, line_entry)) {
557 if (line_entry.is_prologue_end) {
558 prologue_end_file_addr =
559 line_entry.range.GetBaseAddress().GetFileAddress();
560 prologue_end_line_idx = idx;
561 break;
562 }
563 }
564 }
565 }
566
567 // If we didn't find the end of the prologue in the line tables, then
568 // just use the end address of the first line table entry
569 if (prologue_end_file_addr == LLDB_INVALID_ADDRESS) {
570 // Check the first few instructions and look for one that has a line
571 // number that's different than the first entry.
572 uint32_t last_line_entry_idx = first_line_entry_idx + 6;
573 for (uint32_t idx = first_line_entry_idx + 1;
574 idx < last_line_entry_idx; ++idx) {
575 LineEntry line_entry;
576 if (line_table->GetLineEntryAtIndex(idx, line_entry)) {
577 if (line_entry.line != first_line_entry.line) {
578 prologue_end_file_addr =
579 line_entry.range.GetBaseAddress().GetFileAddress();
580 prologue_end_line_idx = idx;
581 break;
582 }
583 }
584 }
585
586 if (prologue_end_file_addr == LLDB_INVALID_ADDRESS) {
587 prologue_end_file_addr =
588 first_line_entry.range.GetBaseAddress().GetFileAddress() +
589 first_line_entry.range.GetByteSize();
590 prologue_end_line_idx = first_line_entry_idx;
591 }
592 }
593
594 const addr_t func_start_file_addr =
596 const addr_t func_end_file_addr =
597 func_start_file_addr + m_range.GetByteSize();
598
599 // Now calculate the offset to pass the subsequent line 0 entries.
600 uint32_t first_non_zero_line = prologue_end_line_idx;
601 while (true) {
602 LineEntry line_entry;
603 if (line_table->GetLineEntryAtIndex(first_non_zero_line,
604 line_entry)) {
605 if (line_entry.line != 0)
606 break;
607 }
608 if (line_entry.range.GetBaseAddress().GetFileAddress() >=
609 func_end_file_addr)
610 break;
611
612 first_non_zero_line++;
613 }
614
615 if (first_non_zero_line > prologue_end_line_idx) {
616 LineEntry first_non_zero_entry;
617 if (line_table->GetLineEntryAtIndex(first_non_zero_line,
618 first_non_zero_entry)) {
619 line_zero_end_file_addr =
620 first_non_zero_entry.range.GetBaseAddress().GetFileAddress();
621 }
622 }
623
624 // Verify that this prologue end file address in the function's address
625 // range just to be sure
626 if (func_start_file_addr < prologue_end_file_addr &&
627 prologue_end_file_addr < func_end_file_addr) {
628 m_prologue_byte_size = prologue_end_file_addr - func_start_file_addr;
629 }
630
631 if (prologue_end_file_addr < line_zero_end_file_addr &&
632 line_zero_end_file_addr < func_end_file_addr) {
634 line_zero_end_file_addr - prologue_end_file_addr;
635 }
636 }
637 }
638 }
639
641}
642
644 lldb::LanguageType lang = m_mangled.GuessLanguage();
645 if (lang != lldb::eLanguageTypeUnknown)
646 return lang;
647
648 if (m_comp_unit)
649 return m_comp_unit->GetLanguage();
650
652}
653
655 return m_mangled.GetName();
656}
657
659 return m_mangled.GetName(Mangled::ePreferDemangledWithoutArguments);
660}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:337
#define LLDB_LOGF(log,...)
Definition: Log.h:344
A section + offset based address range class.
Definition: AddressRange.h:25
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
bool Dump(Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style=Address::DumpStyleInvalid) const
Dump a description of this object to a Stream.
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
Definition: AddressRange.h:221
A section + offset based address class.
Definition: Address.h:59
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:311
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:429
Function * CalculateSymbolContextFunction() const
Definition: Address.cpp:865
DumpStyle
Dump styles allow the Address::Dump(Stream *,DumpStyle) const function to display Address contents in...
Definition: Address.h:63
@ DumpStyleFileAddress
Display as the file address (if any).
Definition: Address.h:84
@ DumpStyleModuleWithFileAddress
Display as the file address with the module name prepended (if any).
Definition: Address.h:90
@ DumpStyleLoadAddress
Display as the load address (if resolved).
Definition: Address.h:96
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
Definition: Address.cpp:283
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:291
lldb::addr_t GetOffset() const
Get the section relative offset value.
Definition: Address.h:319
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:345
bool SetOffset(lldb::addr_t offset)
Set accessor for the offset.
Definition: Address.h:438
A class that describes a single lexical block.
Definition: Block.h:41
bool BlockInfoHasBeenParsed() const
Definition: Block.h:335
void SetBlockInfoHasBeenParsed(bool b, bool set_children)
Definition: Block.cpp:486
void SetParentScope(SymbolContextScope *parent_scope)
Definition: Block.h:320
SymbolFile * GetSymbolFile()
Get the symbol file which contains debug info for this block's symbol context module.
Definition: Block.cpp:474
void Dump(Stream *s, lldb::addr_t base_addr, int32_t depth, bool show_context) const
Dump the block contents.
Definition: Block.cpp:59
size_t MemorySize() const
Get the memory cost of this object.
Definition: Block.cpp:376
Represent a call made within a Function.
Definition: Function.h:267
lldb::addr_t GetReturnPCAddress(Function &caller, Target &target) const
Get the load PC address of the instruction which executes after the call returns.
Definition: Function.cpp:148
static lldb::addr_t GetLoadAddress(lldb::addr_t unresolved_pc, Function &caller, Target &target)
Helper that finds the load address of unresolved_pc, a file address which refers to an instruction wi...
Definition: Function.cpp:125
lldb::addr_t GetUnresolvedReturnPCAddress() const
Like GetReturnPCAddress, but returns an unresolved file address.
Definition: Function.h:319
A class that describes a compilation unit.
Definition: CompileUnit.h:41
const FileSpec & GetPrimaryFile() const
Return the primary source file associated with this compile unit.
Definition: CompileUnit.h:227
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.
Definition: CompileUnit.cpp:40
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
Definition: CompileUnit.cpp:49
lldb::LanguageType GetLanguage()
LineTable * GetLineTable()
Get the line table for the compile unit.
Represents a generic declaration context in a program.
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
A uniqued constant string class.
Definition: ConstString.h:40
size_t MemorySize() const
Get the memory cost of this object.
Definition: ConstString.h:402
static int Compare(ConstString lhs, ConstString rhs, const bool case_sensitive=true)
Compare two string objects.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:198
bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::addr_t func_load_addr, const Value *initial_value_ptr, const Value *object_address_ptr, Value &result, Status *error_ptr) 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.
Definition: Debugger.cpp:1488
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.
Definition: Declaration.h:120
size_t MemorySize() const
Get the memory cost of this object.
Definition: Declaration.cpp:56
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition: Declaration.cpp:14
static int Compare(const Declaration &lhs, const Declaration &rhs)
Compare two declaration objects.
Definition: Declaration.cpp:58
FileSpec & GetFile()
Get accessor for file specification.
Definition: Declaration.h:107
Function * GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override
Get the callee's definition.
Definition: Function.cpp:188
bool resolved
Whether or not an attempt was made to find the callee's definition.
Definition: Function.h:363
void ParseSymbolFileAndResolve(ModuleList &images)
Definition: Function.cpp:153
union lldb_private::DirectCallEdge::@23 lazy_callee
static lldb::DisassemblerSP DisassembleRange(const ArchSpec &arch, const char *plugin_name, const char *flavor, Target &target, const AddressRange &disasm_range, bool force_live_memory=false)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Target * GetTargetPtr() const
Returns a pointer to the target object.
bool HasTargetScope() const
Returns true the ExecutionContext object contains a valid target.
Target & GetTargetRef() const
Returns a reference to the target object.
RegisterContext * GetRegisterContext() const
A file utility class.
Definition: FileSpec.h:56
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:366
void Clear()
Clears the object state.
Definition: FileSpec.cpp:258
bool IsClear(ValueType bit) const
Test a single flag bit to see if it is clear (zero).
Definition: Flags.h:111
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
Definition: Flags.h:73
A class that contains generic function information.
Definition: Function.h:31
Declaration & GetDeclaration()
Get accessor for the declaration information.
Definition: Function.cpp:53
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition: Function.cpp:39
virtual ~FunctionInfo()
Destructor.
ConstString GetName() const
Get accessor for the method name.
Definition: Function.cpp:59
FunctionInfo(const char *name, const Declaration *decl_ptr)
Construct with the function method name and optional declaration information.
Definition: Function.cpp:31
ConstString m_name
Function method name (not a mangled name).
Definition: Function.h:117
virtual size_t MemorySize() const
Get the memory cost of this object.
Definition: Function.cpp:61
static int Compare(const FunctionInfo &lhs, const FunctionInfo &rhs)
Compare two function information objects.
Definition: Function.cpp:45
Declaration m_declaration
Information describing where this function information was defined.
Definition: Function.h:120
A class that describes a function.
Definition: Function.h:409
std::vector< std::unique_ptr< CallEdge > > m_call_edges
Outgoing call edges.
Definition: Function.h:677
uint32_t m_prologue_byte_size
Compute the prologue size once and cache it.
Definition: Function.h:667
bool GetIsOptimized()
Get whether compiler optimizations were enabled for this function.
Definition: Function.cpp:466
lldb::user_id_t m_type_uid
The user ID of for the prototype Type for this function.
Definition: Function.h:643
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target)
Definition: Function.cpp:364
@ flagsCalculatedPrologueSize
Whether we already tried to calculate the prologue size.
Definition: Function.h:636
const AddressRange & GetAddressRange()
Definition: Function.h:457
CompilerType GetCompilerType()
Definition: Function.cpp:521
bool IsTopLevelFunction()
Get whether this function represents a 'top-level' function.
Definition: Function.cpp:477
lldb::ModuleSP CalculateSymbolContextModule() override
Definition: Function.cpp:408
CompileUnit * m_comp_unit
The compile unit that owns this function.
Definition: Function.h:640
ConstString GetName() const
Definition: Function.cpp:654
CallEdge * GetCallEdgeForReturnAddress(lldb::addr_t return_pc, Target &target)
Get the outgoing call edge from this function which has the given return address return_pc,...
Definition: Function.cpp:330
llvm::ArrayRef< std::unique_ptr< CallEdge > > GetCallEdges()
Get the outgoing call edges from this function, sorted by their return PC addresses (in increasing or...
Definition: Function.cpp:293
void Dump(Stream *s, bool show_context) const
Dump a description of this object to a Stream.
Definition: Function.cpp:384
Block m_block
All lexical blocks contained in this function.
Definition: Function.h:654
Function(CompileUnit *comp_unit, lldb::user_id_t func_uid, lldb::user_id_t func_type_uid, const Mangled &mangled, Type *func_type, const AddressRange &range)
Construct with a compile unit, function UID, function type UID, optional mangled name,...
Definition: Function.cpp:232
Type * m_type
The function prototype type for this function that includes the function info (FunctionInfo),...
Definition: Function.h:647
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
Definition: Function.cpp:403
void GetStartLineSourceInfo(FileSpec &source_file, uint32_t &line_no)
Find the file and line number of the source location of the start of the function.
Definition: Function.cpp:244
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
Definition: Function.cpp:456
llvm::ArrayRef< std::unique_ptr< CallEdge > > GetTailCallingEdges()
Get the outgoing tail-calling edges from this function.
Definition: Function.cpp:323
bool GetDisassembly(const ExecutionContext &exe_ctx, const char *flavor, Stream &strm, bool force_live_memory=false)
Definition: Function.cpp:434
Type * GetType()
Get accessor for the type that describes the function return value type, and parameter types.
Definition: Function.cpp:500
AddressRange m_range
The function address range that covers the widest range needed to contain all blocks.
Definition: Function.h:658
std::mutex m_call_edges_lock
Exclusive lock that controls read/write access to m_call_edges and m_call_edges_resolved.
Definition: Function.h:671
lldb::LanguageType GetLanguage() const
Definition: Function.cpp:643
uint32_t GetPrologueByteSize()
Get the size of the prologue instructions for this function.
Definition: Function.cpp:528
CompilerDeclContext GetDeclContext()
Get the DeclContext for this function, if available.
Definition: Function.cpp:490
void GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no)
Find the file and line number of the source location of the end of the function.
Definition: Function.cpp:272
CompileUnit * CalculateSymbolContextCompileUnit() override
Definition: Function.cpp:416
CompileUnit * GetCompileUnit()
Get accessor for the compile unit that owns this function.
Definition: Function.cpp:360
~Function() override
Destructor.
bool m_call_edges_resolved
Whether call site info has been parsed.
Definition: Function.h:674
ConstString GetDisplayName() const
Definition: Function.cpp:486
ConstString GetNameNoArguments() const
Definition: Function.cpp:658
lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx, const char *flavor, bool force_live_memory=false)
Definition: Function.cpp:422
Function * CalculateSymbolContextFunction() override
Definition: Function.cpp:420
size_t MemorySize() const
Get the memory cost of this object.
Definition: Function.cpp:461
Mangled m_mangled
The mangled function name if any.
Definition: Function.h:651
Block & GetBlock(bool can_create)
Get accessor for the block list.
Definition: Function.cpp:345
Function * GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override
Get the callee's definition.
Definition: Function.cpp:194
DWARFExpressionList call_target
Definition: Function.h:386
size_t MemorySize() const override
Get the memory cost of this object.
Definition: Function.cpp:118
void DumpStopContext(Stream *s) const
Definition: Function.cpp:87
ConstString GetDisplayName() const
Definition: Function.cpp:102
Declaration & GetCallSite()
Get accessor for the call site declaration information.
Definition: Function.cpp:108
ConstString GetName() const
Definition: Function.cpp:96
~InlineFunctionInfo() override
Destructor.
Mangled m_mangled
Mangled inlined function name (can be empty if there is no mangled information).
Definition: Function.h:244
InlineFunctionInfo(const char *name, llvm::StringRef mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr)
Construct with the function method name, mangled name, and optional declaration information.
Definition: Function.cpp:65
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition: Function.cpp:81
Mangled & GetMangled()
Get accessor for the mangled name object.
Definition: Function.cpp:114
static Language * FindPlugin(lldb::LanguageType language)
Definition: Language.cpp:53
A line table class.
Definition: LineTable.h:40
bool FindLineEntryByAddress(const Address &so_addr, LineEntry &line_entry, uint32_t *index_ptr=nullptr)
Find a line entry that contains the section offset address so_addr.
Definition: LineTable.cpp:188
bool GetLineEntryAtIndex(uint32_t idx, LineEntry &line_entry)
Get the line entry from the line table at index idx.
Definition: LineTable.cpp:179
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
A collection class for Module objects.
Definition: ModuleList.h:82
void FindFunctionSymbols(ConstString name, lldb::FunctionNameType name_type_mask, SymbolContextList &sc_list)
Definition: ModuleList.cpp:443
unsigned long long ULongLong(unsigned long long fail_value=0) const
Definition: Scalar.cpp:334
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:357
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
Function * function
The Function for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:49
virtual Type * ResolveTypeUID(lldb::user_id_t type_uid)=0
virtual std::vector< std::unique_ptr< CallEdge > > ParseCallEdgesInFunction(UserID func_id)
Definition: SymbolFile.h:349
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow)
Definition: Target.cpp:3009
const lldb_private::Declaration & GetDeclaration() const
Definition: Type.cpp:480
CompilerType GetFullCompilerType()
Definition: Type.cpp:657
const Scalar & GetScalar() const
Definition: Value.h:112
#define LLDB_INVALID_UID
Definition: lldb-defines.h:80
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
Definition: SBAddress.h:15
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
uint64_t user_id_t
Definition: lldb-types.h:80
uint64_t addr_t
Definition: lldb-types.h:79
A line table entry class.
Definition: LineEntry.h:20
FileSpec file
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:140
AddressRange range
The section offset address range for this line entry.
Definition: LineEntry.h:139
uint32_t line
The source line number, or zero if there is no line number information.
Definition: LineEntry.h:143
uint16_t is_prologue_end
Indicates this entry is one (of possibly many) where execution should be suspended for an entry break...
Definition: LineEntry.h:155
A mix in class that contains a generic user ID.
Definition: UserID.h:31
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47