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