LLDB  mainline
Function.cpp
Go to the documentation of this file.
1 //===-- Function.cpp --------------------------------------------*- C++ -*-===//
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 
9 #include "lldb/Symbol/Function.h"
10 #include "lldb/Core/Disassembler.h"
11 #include "lldb/Core/Module.h"
12 #include "lldb/Core/ModuleList.h"
13 #include "lldb/Core/Section.h"
14 #include "lldb/Host/Host.h"
17 #include "lldb/Symbol/LineTable.h"
18 #include "lldb/Symbol/SymbolFile.h"
20 #include "lldb/Target/Language.h"
21 #include "lldb/Utility/Log.h"
22 #include "llvm/Support/Casting.h"
23 
24 using namespace lldb;
25 using namespace lldb_private;
26 
27 // Basic function information is contained in the FunctionInfo class. It is
28 // designed to contain the name, linkage name, and declaration location.
29 FunctionInfo::FunctionInfo(const char *name, const Declaration *decl_ptr)
30  : m_name(name), m_declaration(decl_ptr) {}
31 
33  : m_name(name), m_declaration(decl_ptr) {}
34 
36 
37 void FunctionInfo::Dump(Stream *s, bool show_fullpaths) const {
38  if (m_name)
39  *s << ", name = \"" << m_name << "\"";
40  m_declaration.Dump(s, show_fullpaths);
41 }
42 
44  int result = ConstString::Compare(a.GetName(), b.GetName());
45  if (result)
46  return result;
47 
49 }
50 
52 
54  return m_declaration;
55 }
56 
58 
59 size_t FunctionInfo::MemorySize() const {
61 }
62 
63 InlineFunctionInfo::InlineFunctionInfo(const char *name, const char *mangled,
64  const Declaration *decl_ptr,
65  const Declaration *call_decl_ptr)
66  : FunctionInfo(name, decl_ptr), m_mangled(ConstString(mangled), true),
67  m_call_decl(call_decl_ptr) {}
68 
70  const Mangled &mangled,
71  const Declaration *decl_ptr,
72  const Declaration *call_decl_ptr)
73  : FunctionInfo(name, decl_ptr), m_mangled(mangled),
74  m_call_decl(call_decl_ptr) {}
75 
77 
79  const InlineFunctionInfo &b) {
80 
81  int result = FunctionInfo::Compare(a, b);
82  if (result)
83  return result;
84  // only compare the mangled names if both have them
85  return Mangled::Compare(a.m_mangled, a.m_mangled);
86 }
87 
88 void InlineFunctionInfo::Dump(Stream *s, bool show_fullpaths) const {
89  FunctionInfo::Dump(s, show_fullpaths);
90  if (m_mangled)
91  m_mangled.Dump(s);
92 }
93 
95  LanguageType language) const {
96  // s->Indent("[inlined] ");
97  s->Indent();
98  if (m_mangled)
99  s->PutCString(m_mangled.GetName(language).AsCString());
100  else
102 }
103 
105  if (m_mangled)
106  return m_mangled.GetName(language);
107  return m_name;
108 }
109 
111  if (m_mangled)
112  return m_mangled.GetDisplayDemangledName(language);
113  return m_name;
114 }
115 
117 
119  return m_call_decl;
120 }
121 
122 Mangled &InlineFunctionInfo::GetMangled() { return m_mangled; }
123 
124 const Mangled &InlineFunctionInfo::GetMangled() const { return m_mangled; }
125 
127  return FunctionInfo::MemorySize() + m_mangled.MemorySize();
128 }
129 
130 //
131 CallEdge::CallEdge(const char *symbol_name, lldb::addr_t return_pc)
132  : return_pc(return_pc), resolved(false) {
133  lazy_callee.symbol_name = symbol_name;
134 }
135 
136 void CallEdge::ParseSymbolFileAndResolve(ModuleList &images) {
137  if (resolved)
138  return;
139 
141  LLDB_LOG(log, "CallEdge: Lazily parsing the call graph for {0}",
142  lazy_callee.symbol_name);
143 
144  auto resolve_lazy_callee = [&]() -> Function * {
145  ConstString callee_name{lazy_callee.symbol_name};
146  SymbolContextList sc_list;
147  size_t num_matches =
148  images.FindFunctionSymbols(callee_name, eFunctionNameTypeAuto, sc_list);
149  if (num_matches == 0 || !sc_list[0].symbol) {
150  LLDB_LOG(log, "CallEdge: Found no symbols for {0}, cannot resolve it",
151  callee_name);
152  return nullptr;
153  }
154  Address callee_addr = sc_list[0].symbol->GetAddress();
155  if (!callee_addr.IsValid()) {
156  LLDB_LOG(log, "CallEdge: Invalid symbol address");
157  return nullptr;
158  }
159  Function *f = callee_addr.CalculateSymbolContextFunction();
160  if (!f) {
161  LLDB_LOG(log, "CallEdge: Could not find complete function");
162  return nullptr;
163  }
164  return f;
165  };
166  lazy_callee.def = resolve_lazy_callee();
167  resolved = true;
168 }
169 
171  ParseSymbolFileAndResolve(images);
172  return lazy_callee.def;
173 }
174 
176  Target &target) const {
177  const Address &base = caller.GetAddressRange().GetBaseAddress();
178  return base.GetLoadAddress(&target) + return_pc;
179 }
180 
181 //
183  lldb::user_id_t type_uid, const Mangled &mangled, Type *type,
184  const AddressRange &range)
185  : UserID(func_uid), m_comp_unit(comp_unit), m_type_uid(type_uid),
186  m_type(type), m_mangled(mangled), m_block(func_uid), m_range(range),
187  m_frame_base(nullptr), m_flags(), m_prologue_byte_size(0) {
188  m_block.SetParentScope(this);
189  assert(comp_unit != nullptr);
190 }
191 
193 
195  uint32_t &line_no) {
196  line_no = 0;
197  source_file.Clear();
198 
199  if (m_comp_unit == nullptr)
200  return;
201 
202  // Initialize m_type if it hasn't been initialized already
203  GetType();
204 
205  if (m_type != nullptr && m_type->GetDeclaration().GetLine() != 0) {
206  source_file = m_type->GetDeclaration().GetFile();
207  line_no = m_type->GetDeclaration().GetLine();
208  } else {
209  LineTable *line_table = m_comp_unit->GetLineTable();
210  if (line_table == nullptr)
211  return;
212 
213  LineEntry line_entry;
214  if (line_table->FindLineEntryByAddress(GetAddressRange().GetBaseAddress(),
215  line_entry, nullptr)) {
216  line_no = line_entry.line;
217  source_file = line_entry.file;
218  }
219  }
220 }
221 
222 void Function::GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no) {
223  line_no = 0;
224  source_file.Clear();
225 
226  // The -1 is kind of cheesy, but I want to get the last line entry for the
227  // given function, not the first entry of the next.
228  Address scratch_addr(GetAddressRange().GetBaseAddress());
229  scratch_addr.SetOffset(scratch_addr.GetOffset() +
230  GetAddressRange().GetByteSize() - 1);
231 
232  LineTable *line_table = m_comp_unit->GetLineTable();
233  if (line_table == nullptr)
234  return;
235 
236  LineEntry line_entry;
237  if (line_table->FindLineEntryByAddress(scratch_addr, line_entry, nullptr)) {
238  line_no = line_entry.line;
239  source_file = line_entry.file;
240  }
241 }
242 
243 llvm::MutableArrayRef<CallEdge> Function::GetCallEdges() {
245  return m_call_edges;
246 
248  LLDB_LOG(log, "GetCallEdges: Attempting to parse call site info for {0}",
249  GetDisplayName());
250 
251  m_call_edges_resolved = true;
252 
253  // Find the SymbolFile which provided this function's definition.
254  Block &block = GetBlock(/*can_create*/true);
255  SymbolFile *sym_file = block.GetSymbolFile();
256  if (!sym_file)
257  return llvm::None;
258 
259  // Lazily read call site information from the SymbolFile.
261 
262  // Sort the call edges to speed up return_pc lookups.
263  llvm::sort(m_call_edges.begin(), m_call_edges.end(),
264  [](const CallEdge &LHS, const CallEdge &RHS) {
265  return LHS.GetUnresolvedReturnPCAddress() <
266  RHS.GetUnresolvedReturnPCAddress();
267  });
268 
269  return m_call_edges;
270 }
271 
272 llvm::MutableArrayRef<CallEdge> Function::GetTailCallingEdges() {
273  // Call edges are sorted by return PC, and tail calling edges have invalid
274  // return PCs. Find them at the end of the list.
275  return GetCallEdges().drop_until([](const CallEdge &edge) {
277  });
278 }
279 
280 Block &Function::GetBlock(bool can_create) {
281  if (!m_block.BlockInfoHasBeenParsed() && can_create) {
282  ModuleSP module_sp = CalculateSymbolContextModule();
283  if (module_sp) {
284  module_sp->GetSymbolVendor()->ParseBlocksRecursive(*this);
285  } else {
287  "error: unable to find module "
288  "shared pointer for function '%s' "
289  "in %s\n",
290  GetName().GetCString(), m_comp_unit->GetPath().c_str());
291  }
293  }
294  return m_block;
295 }
296 
298 
300 
302  Target *target) {
303  ConstString name = GetName();
304  ConstString mangled = m_mangled.GetMangledName();
305 
306  *s << "id = " << (const UserID &)*this;
307  if (name)
308  *s << ", name = \"" << name.GetCString() << '"';
309  if (mangled)
310  *s << ", mangled = \"" << mangled.GetCString() << '"';
311  *s << ", range = ";
312  Address::DumpStyle fallback_style;
313  if (level == eDescriptionLevelVerbose)
315  else
316  fallback_style = Address::DumpStyleFileAddress;
318  fallback_style);
319 }
320 
321 void Function::Dump(Stream *s, bool show_context) const {
322  s->Printf("%p: ", static_cast<const void *>(this));
323  s->Indent();
324  *s << "Function" << static_cast<const UserID &>(*this);
325 
326  m_mangled.Dump(s);
327 
328  if (m_type)
329  s->Printf(", type = %p", static_cast<void *>(m_type));
330  else if (m_type_uid != LLDB_INVALID_UID)
331  s->Printf(", type_uid = 0x%8.8" PRIx64, m_type_uid);
332 
333  s->EOL();
334  // Dump the root object
337  show_context);
338 }
339 
341  sc->function = this;
343 }
344 
346  SectionSP section_sp(m_range.GetBaseAddress().GetSection());
347  if (section_sp)
348  return section_sp->GetModule();
349 
350  return this->GetCompileUnit()->GetModule();
351 }
352 
354  return this->GetCompileUnit();
355 }
356 
358 
359 lldb::DisassemblerSP Function::GetInstructions(const ExecutionContext &exe_ctx,
360  const char *flavor,
361  bool prefer_file_cache) {
362  ModuleSP module_sp(GetAddressRange().GetBaseAddress().GetModule());
363  if (module_sp) {
364  const bool prefer_file_cache = false;
365  return Disassembler::DisassembleRange(module_sp->GetArchitecture(), nullptr,
366  flavor, exe_ctx, GetAddressRange(),
367  prefer_file_cache);
368  }
369  return lldb::DisassemblerSP();
370 }
371 
373  const char *flavor, bool prefer_file_cache,
374  Stream &strm) {
375  lldb::DisassemblerSP disassembler_sp =
376  GetInstructions(exe_ctx, flavor, prefer_file_cache);
377  if (disassembler_sp) {
378  const bool show_address = true;
379  const bool show_bytes = false;
380  disassembler_sp->GetInstructionList().Dump(&strm, show_address, show_bytes,
381  &exe_ctx);
382  return true;
383  }
384  return false;
385 }
386 
387 // Symbol *
388 // Function::CalculateSymbolContextSymbol ()
389 //{
390 // return // TODO: find the symbol for the function???
391 //}
392 
395  s->Printf(", Function{0x%8.8" PRIx64 "}", GetID());
396 }
397 
398 size_t Function::MemorySize() const {
399  size_t mem_size = sizeof(Function) + m_block.MemorySize();
400  return mem_size;
401 }
402 
404  bool result = false;
405 
406  // Currently optimization is only indicted by the vendor extension
407  // DW_AT_APPLE_optimized which is set on a compile unit level.
408  if (m_comp_unit) {
409  result = m_comp_unit->GetIsOptimized();
410  }
411  return result;
412 }
413 
415  bool result = false;
416 
417  if (Language *language = Language::FindPlugin(GetLanguage()))
418  result = language->IsTopLevelFunction(*this);
419 
420  return result;
421 }
422 
424  return m_mangled.GetDisplayDemangledName(GetLanguage());
425 }
426 
428  ModuleSP module_sp = CalculateSymbolContextModule();
429 
430  if (module_sp) {
431  SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
432 
433  if (sym_vendor) {
434  SymbolFile *sym_file = sym_vendor->GetSymbolFile();
435 
436  if (sym_file)
437  return sym_file->GetDeclContextForUID(GetID());
438  }
439  }
440  return CompilerDeclContext();
441 }
442 
444  if (m_type == nullptr) {
445  SymbolContext sc;
446 
448 
449  if (!sc.module_sp)
450  return nullptr;
451 
452  SymbolVendor *sym_vendor = sc.module_sp->GetSymbolVendor();
453 
454  if (sym_vendor == nullptr)
455  return nullptr;
456 
457  SymbolFile *sym_file = sym_vendor->GetSymbolFile();
458 
459  if (sym_file == nullptr)
460  return nullptr;
461 
462  m_type = sym_file->ResolveTypeUID(m_type_uid);
463  }
464  return m_type;
465 }
466 
467 const Type *Function::GetType() const { return m_type; }
468 
470  Type *function_type = GetType();
471  if (function_type)
472  return function_type->GetFullCompilerType();
473  return CompilerType();
474 }
475 
477  if (m_prologue_byte_size == 0 &&
480  LineTable *line_table = m_comp_unit->GetLineTable();
481  uint32_t prologue_end_line_idx = 0;
482 
483  if (line_table) {
484  LineEntry first_line_entry;
485  uint32_t first_line_entry_idx = UINT32_MAX;
486  if (line_table->FindLineEntryByAddress(GetAddressRange().GetBaseAddress(),
487  first_line_entry,
488  &first_line_entry_idx)) {
489  // Make sure the first line entry isn't already the end of the prologue
490  addr_t prologue_end_file_addr = LLDB_INVALID_ADDRESS;
491  addr_t line_zero_end_file_addr = LLDB_INVALID_ADDRESS;
492 
493  if (first_line_entry.is_prologue_end) {
494  prologue_end_file_addr =
495  first_line_entry.range.GetBaseAddress().GetFileAddress();
496  prologue_end_line_idx = first_line_entry_idx;
497  } else {
498  // Check the first few instructions and look for one that has
499  // is_prologue_end set to true.
500  const uint32_t last_line_entry_idx = first_line_entry_idx + 6;
501  for (uint32_t idx = first_line_entry_idx + 1;
502  idx < last_line_entry_idx; ++idx) {
503  LineEntry line_entry;
504  if (line_table->GetLineEntryAtIndex(idx, line_entry)) {
505  if (line_entry.is_prologue_end) {
506  prologue_end_file_addr =
507  line_entry.range.GetBaseAddress().GetFileAddress();
508  prologue_end_line_idx = idx;
509  break;
510  }
511  }
512  }
513  }
514 
515  // If we didn't find the end of the prologue in the line tables, then
516  // just use the end address of the first line table entry
517  if (prologue_end_file_addr == LLDB_INVALID_ADDRESS) {
518  // Check the first few instructions and look for one that has a line
519  // number that's different than the first entry.
520  uint32_t last_line_entry_idx = first_line_entry_idx + 6;
521  for (uint32_t idx = first_line_entry_idx + 1;
522  idx < last_line_entry_idx; ++idx) {
523  LineEntry line_entry;
524  if (line_table->GetLineEntryAtIndex(idx, line_entry)) {
525  if (line_entry.line != first_line_entry.line) {
526  prologue_end_file_addr =
527  line_entry.range.GetBaseAddress().GetFileAddress();
528  prologue_end_line_idx = idx;
529  break;
530  }
531  }
532  }
533 
534  if (prologue_end_file_addr == LLDB_INVALID_ADDRESS) {
535  prologue_end_file_addr =
536  first_line_entry.range.GetBaseAddress().GetFileAddress() +
537  first_line_entry.range.GetByteSize();
538  prologue_end_line_idx = first_line_entry_idx;
539  }
540  }
541 
542  const addr_t func_start_file_addr =
544  const addr_t func_end_file_addr =
545  func_start_file_addr + m_range.GetByteSize();
546 
547  // Now calculate the offset to pass the subsequent line 0 entries.
548  uint32_t first_non_zero_line = prologue_end_line_idx;
549  while (1) {
550  LineEntry line_entry;
551  if (line_table->GetLineEntryAtIndex(first_non_zero_line,
552  line_entry)) {
553  if (line_entry.line != 0)
554  break;
555  }
556  if (line_entry.range.GetBaseAddress().GetFileAddress() >=
557  func_end_file_addr)
558  break;
559 
560  first_non_zero_line++;
561  }
562 
563  if (first_non_zero_line > prologue_end_line_idx) {
564  LineEntry first_non_zero_entry;
565  if (line_table->GetLineEntryAtIndex(first_non_zero_line,
566  first_non_zero_entry)) {
567  line_zero_end_file_addr =
568  first_non_zero_entry.range.GetBaseAddress().GetFileAddress();
569  }
570  }
571 
572  // Verify that this prologue end file address in the function's address
573  // range just to be sure
574  if (func_start_file_addr < prologue_end_file_addr &&
575  prologue_end_file_addr < func_end_file_addr) {
576  m_prologue_byte_size = prologue_end_file_addr - func_start_file_addr;
577  }
578 
579  if (prologue_end_file_addr < line_zero_end_file_addr &&
580  line_zero_end_file_addr < func_end_file_addr) {
582  line_zero_end_file_addr - prologue_end_file_addr;
583  }
584  }
585  }
586  }
587 
588  return m_prologue_byte_size;
589 }
590 
592  if (m_comp_unit)
593  return m_comp_unit->GetLanguage();
594  else
596 }
597 
600  if (m_comp_unit)
601  language = m_comp_unit->GetLanguage();
602  return m_mangled.GetName(language);
603 }
604 
607  if (m_comp_unit)
608  language = m_comp_unit->GetLanguage();
609  return m_mangled.GetName(language, Mangled::ePreferDemangledWithoutArguments);
610 }
bool m_call_edges_resolved
Whether call site info has been parsed.
Definition: Function.h:567
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object&#39;s symbol context into sc.
Definition: CompileUnit.cpp:47
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
A line table entry class.
Definition: LineEntry.h:20
const lldb_private::Declaration & GetDeclaration() const
Definition: Type.cpp:439
void DumpSymbolContext(Stream *s) override
Dump the object&#39;s symbol context to the stream s.
Definition: Function.cpp:393
void DumpSymbolContext(Stream *s) override
Dump the object&#39;s symbol context to the stream s.
Definition: CompileUnit.cpp:56
lldb::user_id_t m_type_uid
The user ID of for the prototype Type for this function.
Definition: Function.h:553
lldb::ModuleSP CalculateSymbolContextModule() override
Definition: Function.cpp:345
static int Compare(ConstString lhs, ConstString rhs, const bool case_sensitive=true)
Compare two string objects.
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition: Function.cpp:88
Have we already tried to calculate the prologue size?
Definition: Function.h:546
Function * CalculateSymbolContextFunction() const
Definition: Address.cpp:822
Defines a list of symbol context objects.
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:222
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
ConstString GetDisplayName(lldb::LanguageType language) const
Definition: Function.cpp:110
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
Definition: AddressRange.h:232
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:224
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
ConstString GetDisplayName() const
Definition: Function.cpp:423
InlineFunctionInfo(const char *name, const char *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:63
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition: Function.cpp:37
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:292
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target)
Definition: Function.cpp:301
bool GetDisassembly(const ExecutionContext &exe_ctx, const char *flavor, bool prefer_file_cache, Stream &strm)
Definition: Function.cpp:372
lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx, const char *flavor, bool prefer_file_cache)
Definition: Function.cpp:359
SymbolFile * GetSymbolFile()
Definition: SymbolVendor.h:125
static int Compare(const Declaration &lhs, const Declaration &rhs)
Compare two declaration objects.
Definition: Declaration.cpp:69
AddressRange m_range
The function address range that covers the widest range needed to contain all blocks.
Definition: Function.h:559
bool GetLineEntryAtIndex(uint32_t idx, LineEntry &line_entry)
Get the line entry from the line table at index idx.
Definition: LineTable.cpp:161
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:49
A mix in class that contains a generic user ID.
Definition: UserID.h:33
A file utility class.
Definition: FileSpec.h:55
~InlineFunctionInfo() override
Destructor.
Definition: Function.cpp:76
A class that describes a function.
Definition: Function.h:323
static void SystemLog(SystemLogType type, const char *format,...) __attribute__((format(printf
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:272
lldb::LanguageType GetLanguage()
size_t MemorySize() const override
Get the memory cost of this object.
Definition: Function.cpp:126
Mangled m_mangled
The mangled function name if any, if empty, there is no mangled information.
Definition: Function.h:556
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool IsTopLevelFunction()
Get whether this function represents a &#39;top-level&#39; function.
Definition: Function.cpp:414
void Clear()
Clears the object state.
Definition: FileSpec.cpp:285
ConstString m_name
Function method name (not a mangled name).
Definition: Function.h:115
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:159
virtual Type * ResolveTypeUID(lldb::user_id_t type_uid)=0
#define LLDB_INVALID_UID
Definition: lldb-defines.h:91
CompileUnit * CalculateSymbolContextCompileUnit() override
Definition: Function.cpp:353
A class that describes a single lexical block.
Definition: Block.h:41
lldb::addr_t GetUnresolvedReturnPCAddress() const
Like GetReturnPCAddress, but returns an unslid function-local PC offset.
Definition: Function.h:280
#define LLDB_LOG(log,...)
Definition: Log.h:209
virtual std::vector< CallEdge > ParseCallEdgesInFunction(UserID func_id)
Definition: SymbolFile.h:216
bool SetOffset(lldb::addr_t offset)
Set accessor for the offset.
Definition: Address.h:419
DumpStyle
Dump styles allow the Address::Dump(Stream *,DumpStyle) const function to display Address contents in...
Definition: Address.h:84
lldb::LanguageType GetLanguage() const
Definition: Function.cpp:591
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:27
Mangled & GetMangled()
Get accessor for the mangled name object.
Definition: Function.cpp:122
Function * GetCallee(ModuleList &images)
Get the callee&#39;s definition.
Definition: Function.cpp:170
A class that describes a compilation unit.
Definition: CompileUnit.h:35
Type * GetType()
Get accessor for the type that describes the function return value type, and parameter types...
Definition: Function.cpp:443
~Function() override
Destructor.
Definition: Function.cpp:192
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, function type, and a section offset based address range.
Definition: Function.cpp:182
Function * function
The Function for a given query.
uint32_t GetPrologueByteSize()
Get the size of the prologue instructions for this function.
Definition: Function.cpp:476
static int Compare(const FunctionInfo &lhs, const FunctionInfo &rhs)
Compare two function information objects.
Definition: Function.cpp:43
lldb::addr_t GetOffset() const
Get the section relative offset value.
Definition: Address.h:317
SymbolFile * GetSymbolFile()
Get the symbol file which contains debug info for this block&#39;s symbol context module.
Definition: Block.cpp:463
#define UINT32_MAX
Definition: lldb-defines.h:31
void Dump(Stream *s, lldb::addr_t base_addr, int32_t depth, bool show_context) const
Dump the block contents.
Definition: Block.cpp:59
FileSpec & GetFile()
Get accessor for file specification.
Definition: Declaration.h:148
CompilerType GetFullCompilerType()
Definition: Type.cpp:600
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
uint64_t user_id_t
Definition: lldb-types.h:84
LanguageType
Programming language type.
FunctionInfo(const char *name, const Declaration *decl_ptr)
Construct with the function method name and optional declaration information.
Definition: Function.cpp:29
size_t MemorySize() const
Get the memory cost of this object.
Definition: Block.cpp:364
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object&#39;s symbol context into sc.
Definition: Function.cpp:340
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:57
A collection class for Module objects.
Definition: ModuleList.h:91
const char * symbol_name
Definition: Function.h:288
void Dump(Stream *s, bool show_context) const
Dump a description of this object to a Stream.
Definition: Function.cpp:321
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:127
Represent a call made within a Function.
Definition: Function.h:253
size_t MemorySize() const
Get the memory cost of this object.
Definition: ConstString.h:435
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:194
Block & GetBlock(bool can_create)
Get accessor for the block list.
Definition: Function.cpp:280
static lldb::DisassemblerSP DisassembleRange(const ArchSpec &arch, const char *plugin_name, const char *flavor, const ExecutionContext &exe_ctx, const AddressRange &disasm_range, bool prefer_file_cache)
ConstString GetName() const
Definition: Function.cpp:598
ConstString GetNameNoArguments() const
Definition: Function.cpp:605
A line table class.
Definition: LineTable.h:37
void SetParentScope(SymbolContextScope *parent_scope)
Definition: Block.h:340
Declaration & GetCallSite()
Get accessor for the call site declaration information.
Definition: Function.cpp:116
CompileUnit * GetCompileUnit()
Get accessor for the compile unit that owns this function.
Definition: Function.cpp:297
llvm::MutableArrayRef< CallEdge > GetCallEdges()
Get the outgoing call edges from this function, sorted by their return PC addresses (in increasing or...
Definition: Function.cpp:243
bool GetIsOptimized()
Get whether compiler optimizations were enabled for this compile unit.
FileSpec file
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:151
uint32_t line
The source line number, or zero if there is no line number information.
Definition: LineEntry.h:154
virtual size_t MemorySize() const
Get the memory cost of this object.
Definition: Function.cpp:59
size_t MemorySize() const
Get the memory cost of this object.
Definition: Function.cpp:398
virtual CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid)
Definition: SymbolFile.h:153
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
size_t FindFunctionSymbols(ConstString name, lldb::FunctionNameType name_type_mask, SymbolContextList &sc_list)
Definition: ModuleList.cpp:374
uint32_t GetLine() const
Get accessor for the declaration line number.
Definition: Declaration.h:161
CompilerDeclContext GetDeclContext()
Get the DeclContext for this function, if available.
Definition: Function.cpp:427
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:343
A section + offset based address class.
Definition: Address.h:80
ValueType Set(ValueType mask)
Set one or more flags by logical OR&#39;ing mask with the current flags.
Definition: Flags.h:84
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition: Declaration.cpp:14
LineTable * GetLineTable()
Get the line table for the compile unit.
CompileUnit * m_comp_unit
The compile unit that owns this function.
Definition: Function.h:551
llvm::MutableArrayRef< CallEdge > GetTailCallingEdges()
Get the outgoing tail-calling edges from this function.
Definition: Function.cpp:272
bool BlockInfoHasBeenParsed() const
Definition: Block.h:355
uint32_t m_prologue_byte_size
Compute the prologue size once and cache it.
Definition: Function.h:565
void SetBlockInfoHasBeenParsed(bool b, bool set_children)
Definition: Block.cpp:476
CompilerType GetCompilerType()
Definition: Function.cpp:469
A class that contains generic function information.
Definition: Function.h:27
Declaration m_declaration
Information describing where this function information was defined.
Definition: Function.h:116
std::vector< CallEdge > m_call_edges
Outgoing call edges.
Definition: Function.h:569
Function * CalculateSymbolContextFunction() override
Definition: Function.cpp:357
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:170
Type * m_type
The function prototype type for this function that include the function info (FunctionInfo), return type and parameters.
Definition: Function.h:554
A class that describes information for an inlined function.
Definition: Function.h:122
uint64_t addr_t
Definition: lldb-types.h:83
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:175
Display as the load address (if resolved).
Definition: Address.h:104
A uniqued constant string class.
Definition: ConstString.h:38
Unknown or invalid language value.
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:247
CallEdge(const char *symbol_name, lldb::addr_t return_pc)
Construct a call edge using a symbol name to identify the calling function, and a return PC within th...
Definition: Function.cpp:131
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::ModuleSP module_sp
The Module for a given query.
static bool Compare(BreakpointLocationSP lhs, lldb::break_id_t val)
Definition: SBAddress.h:15
void DumpStopContext(Stream *s, lldb::LanguageType language) const
Definition: Function.cpp:94
size_t Indent(const char *s=nullptr)
Indent the current line in the stream.
Definition: Stream.cpp:131
Display as the file address with the module name prepended (if any).
Definition: Address.h:99
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:220
Declaration & GetDeclaration()
Get accessor for the declaration information.
Definition: Function.cpp:51
static Language * FindPlugin(lldb::LanguageType language)
Definition: Language.cpp:54
virtual ~FunctionInfo()
Destructor.
Definition: Function.cpp:35
int Compare(const InlineFunctionInfo &lhs, const InlineFunctionInfo &rhs)
Compare two inlined function information objects.
Definition: Function.cpp:78
bool GetIsOptimized()
Get whether compiler optimizations were enabled for this function.
Definition: Function.cpp:403
bool IsClear(ValueType bit) const
Test a single flag bit to see if it is clear (zero).
Definition: Flags.h:122
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:410
const AddressRange & GetAddressRange()
Definition: Function.h:371
size_t MemorySize() const
Get the memory cost of this object.
Definition: Declaration.cpp:67
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:376
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
#define LIBLLDB_LOG_STEP
Definition: Logging.h:21
A section + offset based address range class.
Definition: AddressRange.h:32
ConstString GetName() const
Get accessor for the method name.
Definition: Function.cpp:57
AddressRange range
The section offset address range for this line entry.
Definition: LineEntry.h:150
Block m_block
All lexical blocks contained in this function.
Definition: Function.h:558
Display as the file address (if any).
Definition: Address.h:95