LLDB mainline
Function.h
Go to the documentation of this file.
1//===-- Function.h ----------------------------------------------*- 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#ifndef LLDB_SYMBOL_FUNCTION_H
10#define LLDB_SYMBOL_FUNCTION_H
11
14#include "lldb/Core/Mangled.h"
16#include "lldb/Symbol/Block.h"
19#include "lldb/Utility/UserID.h"
20#include "lldb/lldb-forward.h"
21#include "llvm/ADT/ArrayRef.h"
22
23#include <mutex>
24
25namespace lldb_private {
26
28
29/// \class FunctionInfo Function.h "lldb/Symbol/Function.h"
30/// A class that contains generic function information.
31///
32/// This provides generic function information that gets reused between inline
33/// functions and function types.
35public:
36 /// Construct with the function method name and optional declaration
37 /// information.
38 ///
39 /// \param[in] name
40 /// A C string name for the method name for this function. This
41 /// value should not be the mangled named, but the simple method
42 /// name.
43 ///
44 /// \param[in] decl_ptr
45 /// Optional declaration information that describes where the
46 /// function was declared. This can be NULL.
47 FunctionInfo(const char *name, const Declaration *decl_ptr);
48
49 /// Construct with the function method name and optional declaration
50 /// information.
51 ///
52 /// \param[in] name
53 /// A name for the method name for this function. This value
54 /// should not be the mangled named, but the simple method name.
55 ///
56 /// \param[in] decl_ptr
57 /// Optional declaration information that describes where the
58 /// function was declared. This can be NULL.
59 FunctionInfo(ConstString name, const Declaration *decl_ptr);
60
61 /// Destructor.
62 ///
63 /// The destructor is virtual since classes inherit from this class.
64 virtual ~FunctionInfo();
65
66 /// Compare two function information objects.
67 ///
68 /// First compares the method names, and if equal, then compares the
69 /// declaration information.
70 ///
71 /// \param[in] lhs
72 /// The Left Hand Side const FunctionInfo object reference.
73 ///
74 /// \param[in] rhs
75 /// The Right Hand Side const FunctionInfo object reference.
76 ///
77 /// \return
78 /// -1 if lhs < rhs
79 /// 0 if lhs == rhs
80 /// 1 if lhs > rhs
81 static int Compare(const FunctionInfo &lhs, const FunctionInfo &rhs);
82
83 /// Dump a description of this object to a Stream.
84 ///
85 /// Dump a description of the contents of this object to the supplied stream
86 /// \a s.
87 ///
88 /// \param[in] s
89 /// The stream to which to dump the object description.
90 void Dump(Stream *s, bool show_fullpaths) const;
91
92 /// Get accessor for the declaration information.
93 ///
94 /// \return
95 /// A reference to the declaration object.
97
98 /// Get const accessor for the declaration information.
99 ///
100 /// \return
101 /// A const reference to the declaration object.
102 const Declaration &GetDeclaration() const;
103
104 /// Get accessor for the method name.
105 ///
106 /// \return
107 /// A const reference to the method name object.
108 ConstString GetName() const;
109
110protected:
111 /// Function method name (not a mangled name).
113
114 /// Information describing where this function information was defined.
116};
117
118/// \class InlineFunctionInfo Function.h "lldb/Symbol/Function.h"
119/// A class that describes information for an inlined function.
121public:
122 /// Construct with the function method name, mangled name, and optional
123 /// declaration information.
124 ///
125 /// \param[in] name
126 /// A C string name for the method name for this function. This
127 /// value should not be the mangled named, but the simple method
128 /// name.
129 ///
130 /// \param[in] mangled
131 /// A C string name for the mangled name for this function. This
132 /// value can be NULL if there is no mangled information.
133 ///
134 /// \param[in] decl_ptr
135 /// Optional declaration information that describes where the
136 /// function was declared. This can be NULL.
137 ///
138 /// \param[in] call_decl_ptr
139 /// Optional calling location declaration information that
140 /// describes from where this inlined function was called.
141 InlineFunctionInfo(const char *name, llvm::StringRef mangled,
142 const Declaration *decl_ptr,
143 const Declaration *call_decl_ptr);
144
145 /// Construct with the function method name, mangled name, and optional
146 /// declaration information.
147 ///
148 /// \param[in] name
149 /// A name for the method name for this function. This value
150 /// should not be the mangled named, but the simple method name.
151 ///
152 /// \param[in] mangled
153 /// A name for the mangled name for this function. This value
154 /// can be empty if there is no mangled information.
155 ///
156 /// \param[in] decl_ptr
157 /// Optional declaration information that describes where the
158 /// function was declared. This can be NULL.
159 ///
160 /// \param[in] call_decl_ptr
161 /// Optional calling location declaration information that
162 /// describes from where this inlined function was called.
163 InlineFunctionInfo(ConstString name, const Mangled &mangled,
164 const Declaration *decl_ptr,
165 const Declaration *call_decl_ptr);
166
167 /// Destructor.
169
170 /// Compare two inlined function information objects.
171 ///
172 /// First compares the FunctionInfo objects, and if equal, compares the
173 /// mangled names.
174 ///
175 /// \param[in] lhs
176 /// The Left Hand Side const InlineFunctionInfo object
177 /// reference.
178 ///
179 /// \param[in] rhs
180 /// The Right Hand Side const InlineFunctionInfo object
181 /// reference.
182 ///
183 /// \return
184 /// -1 if lhs < rhs
185 /// 0 if lhs == rhs
186 /// 1 if lhs > rhs
187 int Compare(const InlineFunctionInfo &lhs, const InlineFunctionInfo &rhs);
188
189 /// Dump a description of this object to a Stream.
190 ///
191 /// Dump a description of the contents of this object to the supplied stream
192 /// \a s.
193 ///
194 /// \param[in] s
195 /// The stream to which to dump the object description.
196 void Dump(Stream *s, bool show_fullpaths) const;
197
198 void DumpStopContext(Stream *s) const;
199
200 ConstString GetName() const;
201
203
204 /// Get accessor for the call site declaration information.
205 ///
206 /// \return
207 /// A reference to the declaration object.
209
210 /// Get const accessor for the call site declaration information.
211 ///
212 /// \return
213 /// A const reference to the declaration object.
214 const Declaration &GetCallSite() const;
215
216 /// Get accessor for the mangled name object.
217 ///
218 /// \return
219 /// A reference to the mangled name object.
221
222 /// Get const accessor for the mangled name object.
223 ///
224 /// \return
225 /// A const reference to the mangled name object.
226 const Mangled &GetMangled() const;
227
228private:
229 /// Mangled inlined function name (can be empty if there is no mangled
230 /// information).
232
234};
235
236class Function;
237
238/// \class CallSiteParameter Function.h "lldb/Symbol/Function.h"
239///
240/// Represent the locations of a parameter at a call site, both in the caller
241/// and in the callee.
246
247/// A vector of \c CallSiteParameter.
248using CallSiteParameterArray = llvm::SmallVector<CallSiteParameter, 0>;
249
250/// \class CallEdge Function.h "lldb/Symbol/Function.h"
251///
252/// Represent a call made within a Function. This can be used to find a path
253/// in the call graph between two functions, or to evaluate DW_OP_entry_value.
254class CallEdge {
255public:
256 enum class AddrType : uint8_t { Call, AfterCall };
257 virtual ~CallEdge();
258
259 /// Get the callee's definition, resolved against \p images.
260 ///
261 /// The result is never cached. A CallEdge is owned by a Module in the shared
262 /// module cache, so it outlives any one Target, while the callee it resolves
263 /// to depends on that Target's image list and dies with its own module. The
264 /// returned symbol context anchors that module.
265 ///
266 /// Note that this might lazily invoke the DWARF parser. A register context
267 /// from the caller's activation is needed to find indirect call targets.
269 ExecutionContext &exe_ctx) = 0;
270
271 /// Get the load PC address of the instruction which executes after the call
272 /// returns. Returns LLDB_INVALID_ADDRESS iff this is a tail call. \p caller
273 /// is the Function containing this call, and \p target is the Target which
274 /// made the call.
275 lldb::addr_t GetReturnPCAddress(Function &caller, Target &target) const;
276
277 /// Return an address in the caller. This can either be the address of the
278 /// call instruction, or the address of the instruction after the call.
279 std::pair<AddrType, lldb::addr_t> GetCallerAddress(Function &caller,
280 Target &target) const {
281 return {caller_address_type,
282 GetLoadAddress(caller_address, caller, target)};
283 }
284
285 bool IsTailCall() const { return is_tail_call; }
286
287 /// Get the call site parameters available at this call edge.
288 llvm::ArrayRef<CallSiteParameter> GetCallSiteParameters() const {
289 return parameters;
290 }
291
292 /// Non-tail-calls go first, sorted by the return address. They are followed
293 /// by tail calls, which have no specific order.
294 std::pair<bool, lldb::addr_t> GetSortKey() const {
296 }
297
298protected:
301
302 /// Helper that finds the load address of \p unresolved_pc, a file address
303 /// which refers to an instruction within \p caller.
304 static lldb::addr_t GetLoadAddress(lldb::addr_t unresolved_pc,
305 Function &caller, Target &target);
306
307 /// Find the function containing \p addr.
308 static SymbolContext ResolveCallee(const Address &addr);
309
310 /// Like \ref GetReturnPCAddress, but returns an unresolved file address.
316
317private:
321
323};
324
325/// A direct call site. Used to represent call sites where the address of the
326/// callee is fixed (e.g. a function call in C in which the call target is not
327/// a function pointer).
328class DirectCallEdge : public CallEdge {
329public:
330 /// Construct a call edge using a symbol name to identify the callee, and a
331 /// return PC within the calling function to identify a specific call site.
332 DirectCallEdge(const char *symbol_name, AddrType caller_address_type,
335
337 ExecutionContext &exe_ctx) override;
338
339private:
341
342 const char *m_symbol_name;
343};
344
345/// An indirect call site. Used to represent call sites where the address of
346/// the callee is not fixed, e.g. a call to a C++ virtual function (where the
347/// address is loaded out of a vtable), or a call to a function pointer in C.
349public:
350 /// Construct a call edge using a DWARFExpression to identify the callee, and
351 /// a return PC within the calling function to identify a specific call site.
355
357 ExecutionContext &exe_ctx) override;
358
359private:
360 // Used to describe an indirect call.
361 //
362 // Specifies the location of the callee address in the calling frame.
364};
365
366/// \class Function Function.h "lldb/Symbol/Function.h"
367/// A class that describes a function.
368///
369/// Functions belong to CompileUnit objects (Function::m_comp_unit), have
370/// unique user IDs (Function::UserID), know how to reconstruct their symbol
371/// context (Function::SymbolContextScope), have a specific function type
372/// (Function::m_type_uid), have a simple method name (FunctionInfo::m_name),
373/// be declared at a specific location (FunctionInfo::m_declaration), possibly
374/// have mangled names (Function::m_mangled), an optional return type
375/// (Function::m_type), and contains lexical blocks (Function::m_blocks).
376///
377/// The function information is split into a few pieces:
378/// \li The concrete instance information
379/// \li The abstract information
380///
381/// The abstract information is found in the function type (Type) that
382/// describes a function information, return type and parameter types.
383///
384/// The concrete information is the address range information and specific
385/// locations for an instance of this function.
386class Function : public UserID, public SymbolContextScope {
387public:
388 /// Construct with a compile unit, function UID, function type UID, optional
389 /// mangled name, function type, and a section offset based address range.
390 ///
391 /// \param[in] comp_unit
392 /// The compile unit to which this function belongs.
393 ///
394 /// \param[in] func_uid
395 /// The UID for this function. This value is provided by the
396 /// SymbolFile plug-in and can be any value that allows
397 /// the plug-in to quickly find and parse more detailed
398 /// information when and if more information is needed.
399 ///
400 /// \param[in] func_type_uid
401 /// The type UID for the function Type to allow for lazy type
402 /// parsing from the debug information.
403 ///
404 /// \param[in] mangled
405 /// The optional mangled name for this function. If empty, there
406 /// is no mangled information.
407 ///
408 /// \param[in] func_type
409 /// The optional function type. If NULL, the function type will
410 /// be parsed on demand when accessed using the
411 /// Function::GetType() function by asking the SymbolFile
412 /// plug-in to get the type for \a func_type_uid.
413 ///
414 /// \param[in] range
415 /// The section offset based address for this function.
416 Function(CompileUnit *comp_unit, lldb::user_id_t func_uid,
417 lldb::user_id_t func_type_uid, const Mangled &mangled,
418 Type *func_type, Address address, AddressRanges ranges);
419
420 /// Destructor.
421 ~Function() override;
422
423 /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
424 ///
425 /// \see SymbolContextScope
426 void CalculateSymbolContext(SymbolContext *sc) override;
427
429
431
433
434 AddressRanges GetAddressRanges() { return m_block.GetRanges(); }
435
436 /// Return the address of the function (its entry point). This address is also
437 /// used as a base address for relocation of function-scope entities (blocks
438 /// and variables).
439 const Address &GetAddress() const { return m_address; }
440
442 AddressRange &range) {
443 return m_block.GetRangeContainingLoadAddress(load_addr, target, range);
444 }
445
447
448 /// Find the source file and line number for the start of the function.
449 ///
450 /// This prefers the function's declaration and only falls back to
451 /// GetStartLineTableEntry when the function has none. The declaration line
452 /// need not correspond to any line table row, which is why this reports a
453 /// bare source file and line rather than a LineEntry.
454 ///
455 /// \param[out] source_file
456 /// The source file.
457 ///
458 /// \param[out] line_no
459 /// The line number.
460 void GetStartLineSourceInfo(SupportFileNSP &source_file_sp,
461 uint32_t &line_no);
462
463 /// Get the line table entry for the function's entry point.
464 ///
465 /// When the entry address is not covered by a line row, this returns the
466 /// first line entry that begins within the function's range instead.
467 ///
468 /// Unlike GetStartLineSourceInfo, this consults only the line table, never
469 /// the declaration, so the result is always a real line table entry and
470 /// carries its address range and index.
471 ///
472 /// \param[out] line_entry
473 /// The resulting line entry.
474 ///
475 /// \param[out] index
476 /// If non-null, set to the index of the line entry in the line table.
477 ///
478 /// \return
479 /// True if a line entry was found, false otherwise.
480 bool GetStartLineTableEntry(LineEntry &line_entry, uint32_t *index = nullptr);
481
483 /// Find the file and line number range of the function.
484 llvm::Expected<std::pair<SupportFileNSP, SourceRange>> GetSourceInfo();
485
486 /// Get the outgoing call edges from this function, sorted by their return
487 /// PC addresses (in increasing order).
488 llvm::ArrayRef<std::unique_ptr<CallEdge>> GetCallEdges();
489
490 /// Get the outgoing tail-calling edges from this function. If none exist,
491 /// return std::nullopt.
492 llvm::ArrayRef<std::unique_ptr<CallEdge>> GetTailCallingEdges();
493
494 /// Get the outgoing call edge from this function which has the given return
495 /// address \p return_pc, or return nullptr. Note that this will not return a
496 /// tail-calling edge.
498
499 /// Get accessor for the block list.
500 ///
501 /// \return
502 /// The block list object that describes all lexical blocks
503 /// in the function.
504 ///
505 /// \see BlockList
506 Block &GetBlock(bool can_create);
507
508 /// Get accessor for the compile unit that owns this function.
509 ///
510 /// \return
511 /// A compile unit object pointer.
513
514 /// Get const accessor for the compile unit that owns this function.
515 ///
516 /// \return
517 /// A const compile unit object pointer.
518 const CompileUnit *GetCompileUnit() const;
519
520 void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target);
521
522 /// Get accessor for the frame base location.
523 ///
524 /// \return
525 /// A location expression that describes the function frame
526 /// base.
528
529 /// Get const accessor for the frame base location.
530 ///
531 /// \return
532 /// A const compile unit object pointer.
534
535 ConstString GetName() const;
536
538
540
541 const Mangled &GetMangled() const { return m_mangled; }
542
543 /// Get the DeclContext for this function, if available.
544 ///
545 /// \return
546 /// The DeclContext, or NULL if none exists.
548
549 /// Get the CompilerContext for this function, if available.
550 ///
551 /// \return
552 /// The CompilerContext, or an empty vector if none is available.
553 std::vector<CompilerContext> GetCompilerContext();
554
555 /// Get accessor for the type that describes the function return value type,
556 /// and parameter types.
557 ///
558 /// \return
559 /// A type object pointer.
560 Type *GetType();
561
562 /// Get const accessor for the type that describes the function return value
563 /// type, and parameter types.
564 ///
565 /// \return
566 /// A const type object pointer.
567 const Type *GetType() const;
568
570
571 /// Get the size of the prologue instructions for this function. The
572 /// "prologue" instructions include any instructions given line number 0
573 /// immediately following the prologue end.
574 ///
575 /// \return
576 /// The size of the prologue.
577 uint32_t GetPrologueByteSize();
578
579 /// Dump a description of this object to a Stream.
580 ///
581 /// Dump a description of the contents of this object to the supplied stream
582 /// \a s.
583 ///
584 /// \param[in] s
585 /// The stream to which to dump the object description.
586 ///
587 /// \param[in] show_context
588 /// If \b true, variables will dump their symbol context
589 /// information.
590 void Dump(Stream *s, bool show_context) const;
591
592 /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*)
593 ///
594 /// \see SymbolContextScope
595 void DumpSymbolContext(Stream *s) override;
596
597 /// Get whether compiler optimizations were enabled for this function
598 ///
599 /// The debug information may provide information about whether this
600 /// function was compiled with optimization or not. In this case,
601 /// "optimized" means that the debug experience may be difficult for the
602 /// user to understand. Variables may not be available when the developer
603 /// would expect them, stepping through the source lines in the function may
604 /// appear strange, etc.
605 ///
606 /// \return
607 /// Returns 'true' if this function was compiled with
608 /// optimization. 'false' indicates that either the optimization
609 /// is unknown, or this function was built without optimization.
610 bool GetIsOptimized();
611
612 /// Get whether this function represents a 'top-level' function
613 ///
614 /// The concept of a top-level function is language-specific, mostly meant
615 /// to represent the notion of scripting-style code that has global
616 /// visibility of the variables/symbols/functions/... defined within the
617 /// containing file/module
618 ///
619 /// If stopped in a top-level function, LLDB will expose global variables
620 /// as-if locals in the 'frame variable' command
621 ///
622 /// \return
623 /// Returns 'true' if this function is a top-level function,
624 /// 'false' otherwise.
625 bool IsTopLevelFunction();
626
628 const char *flavor,
629 bool force_live_memory = false);
630
631 bool GetDisassembly(const ExecutionContext &exe_ctx, const char *flavor,
632 Stream &strm, bool force_live_memory = false);
633
634protected:
635 enum {
636 /// Whether we already tried to calculate the prologue size.
638 };
639
640 /// The compile unit that owns this function.
642
643 /// The user ID of for the prototype Type for this function.
645
646 /// The function prototype type for this function that includes the function
647 /// info (FunctionInfo), return type and parameters.
649
650 /// The mangled function name if any. If empty, there is no mangled
651 /// information.
653
654 /// All lexical blocks contained in this function.
656
657 /// The address (entry point) of the function.
659
660 /// The frame base expression for variables that are relative to the frame
661 /// pointer.
663
665
666 /// Compute the prologue size once and cache it.
668
669 /// Exclusive lock that controls read/write access to m_call_edges and
670 /// m_call_edges_resolved.
672
673 /// Whether call site info has been parsed.
675
676 /// Outgoing call edges.
677 std::vector<std::unique_ptr<CallEdge>> m_call_edges;
678
679private:
680 Function(const Function &) = delete;
681 const Function &operator=(const Function &) = delete;
682};
683
684} // namespace lldb_private
685
686#endif // LLDB_SYMBOL_FUNCTION_H
A section + offset based address range class.
A section + offset based address class.
Definition Address.h:62
A class that describes a single lexical block.
Definition Block.h:41
Represent a call made within a Function.
Definition Function.h:254
AddrType caller_address_type
Definition Function.h:319
bool IsTailCall() const
Definition Function.h:285
static SymbolContext ResolveCallee(const Address &addr)
Find the function containing addr.
Definition Function.cpp:153
std::pair< bool, lldb::addr_t > GetSortKey() const
Non-tail-calls go first, sorted by the return address.
Definition Function.h:294
virtual SymbolContext GetCallee(ModuleList &images, ExecutionContext &exe_ctx)=0
Get the callee's definition, resolved against images.
std::pair< AddrType, lldb::addr_t > GetCallerAddress(Function &caller, Target &target) const
Return an address in the caller.
Definition Function.h:279
CallSiteParameterArray parameters
Definition Function.h:322
llvm::ArrayRef< CallSiteParameter > GetCallSiteParameters() const
Get the call site parameters available at this call edge.
Definition Function.h:288
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
lldb::addr_t caller_address
Definition Function.h:318
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
CallEdge(AddrType caller_address_type, lldb::addr_t caller_address, bool is_tail_call, CallSiteParameterArray &&parameters)
Definition Function.cpp:120
lldb::addr_t GetUnresolvedReturnPCAddress() const
Like GetReturnPCAddress, but returns an unresolved file address.
Definition Function.h:311
A class that describes a compilation unit.
Definition CompileUnit.h:43
Represents a generic declaration context in a program.
Generic representation of a type in a programming language.
A uniqued constant string class.
Definition ConstString.h:40
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
A class that describes the declaration location of a lldb object.
Definition Declaration.h:24
SymbolContext GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override
Get the callee's definition, resolved against images.
Definition Function.cpp:199
Address ResolveCalleeAddress(ModuleList &images) const
Definition Function.cpp:164
DirectCallEdge(const char *symbol_name, AddrType caller_address_type, lldb::addr_t caller_address, bool is_tail_call, CallSiteParameterArray &&parameters)
Construct a call edge using a symbol name to identify the callee, and a return PC within the calling ...
Definition Function.cpp:191
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A class to manage flags.
Definition Flags.h:22
Declaration & GetDeclaration()
Get accessor for the declaration information.
Definition Function.cpp:54
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition Function.cpp:40
virtual ~FunctionInfo()
Destructor.
ConstString GetName() const
Get accessor for the method name.
Definition Function.cpp:60
FunctionInfo(const char *name, const Declaration *decl_ptr)
Construct with the function method name and optional declaration information.
Definition Function.cpp:32
ConstString m_name
Function method name (not a mangled name).
Definition Function.h:112
static int Compare(const FunctionInfo &lhs, const FunctionInfo &rhs)
Compare two function information objects.
Definition Function.cpp:46
Declaration m_declaration
Information describing where this function information was defined.
Definition Function.h:115
A class that describes a function.
Definition Function.h:386
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:526
lldb::user_id_t m_type_uid
The user ID of for the prototype Type for this function.
Definition Function.h:644
Function(const Function &)=delete
const Address & GetAddress() const
Return the address of the function (its entry point).
Definition Function.h:439
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target)
Definition Function.cpp:420
const Function & operator=(const Function &)=delete
CompilerType GetCompilerType()
Definition Function.cpp:585
bool GetRangeContainingLoadAddress(lldb::addr_t load_addr, Target &target, AddressRange &range)
Definition Function.h:441
DWARFExpressionList & GetFrameBaseExpression()
Get accessor for the frame base location.
Definition Function.h:527
bool IsTopLevelFunction()
Get whether this function represents a 'top-level' function.
Definition Function.cpp:537
lldb::ModuleSP CalculateSymbolContextModule() override
Definition Function.cpp:474
CompileUnit * m_comp_unit
The compile unit that owns this function.
Definition Function.h:641
ConstString GetName() const
Definition Function.cpp:724
const Mangled & GetMangled() const
Definition Function.h:541
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:386
void GetStartLineSourceInfo(SupportFileNSP &source_file_sp, uint32_t &line_no)
Find the source file and line number for the start of the function.
Definition Function.cpp:298
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:349
void Dump(Stream *s, bool show_context) const
Dump a description of this object to a Stream.
Definition Function.cpp:451
@ flagsCalculatedPrologueSize
Whether we already tried to calculate the prologue size.
Definition Function.h:637
Block m_block
All lexical blocks contained in this function.
Definition Function.h:655
DWARFExpressionList m_frame_base
The frame base expression for variables that are relative to the frame pointer.
Definition Function.h:662
Type * m_type
The function prototype type for this function that includes the function info (FunctionInfo),...
Definition Function.h:648
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
Definition Function.cpp:469
Address m_address
The address (entry point) of the function.
Definition Function.h:658
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
Definition Function.cpp:521
llvm::ArrayRef< std::unique_ptr< CallEdge > > GetTailCallingEdges()
Get the outgoing tail-calling edges from this function.
Definition Function.cpp:379
bool GetDisassembly(const ExecutionContext &exe_ctx, const char *flavor, Stream &strm, bool force_live_memory=false)
Definition Function.cpp:499
Type * GetType()
Get accessor for the type that describes the function return value type, and parameter types.
Definition Function.cpp:564
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:713
bool GetStartLineTableEntry(LineEntry &line_entry, uint32_t *index=nullptr)
Get the line table entry for the function's entry point.
Definition Function.cpp:270
Function(CompileUnit *comp_unit, lldb::user_id_t func_uid, lldb::user_id_t func_type_uid, const Mangled &mangled, Type *func_type, Address address, AddressRanges ranges)
Construct with a compile unit, function UID, function type UID, optional mangled name,...
Definition Function.cpp:253
uint32_t GetPrologueByteSize()
Get the size of the prologue instructions for this function.
Definition Function.cpp:592
CompilerDeclContext GetDeclContext()
Get the DeclContext for this function, if available.
Definition Function.cpp:550
AddressRanges GetAddressRanges()
Definition Function.h:434
CompileUnit * CalculateSymbolContextCompileUnit() override
Definition Function.cpp:481
llvm::Expected< std::pair< SupportFileNSP, SourceRange > > GetSourceInfo()
Find the file and line number range of the function.
Definition Function.cpp:323
CompileUnit * GetCompileUnit()
Get accessor for the compile unit that owns this function.
Definition Function.cpp:416
~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:546
ConstString GetNameNoArguments() const
Definition Function.cpp:728
lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx, const char *flavor, bool force_live_memory=false)
Definition Function.cpp:487
Function * CalculateSymbolContextFunction() override
Definition Function.cpp:485
const DWARFExpressionList & GetFrameBaseExpression() const
Get const accessor for the frame base location.
Definition Function.h:533
std::vector< CompilerContext > GetCompilerContext()
Get the CompilerContext for this function, if available.
Definition Function.cpp:557
Range< uint32_t, uint32_t > SourceRange
Definition Function.h:482
Mangled m_mangled
The mangled function name if any.
Definition Function.h:652
Block & GetBlock(bool can_create)
Get accessor for the block list.
Definition Function.cpp:401
IndirectCallEdge(DWARFExpressionList call_target, AddrType caller_address_type, lldb::addr_t caller_address, bool is_tail_call, CallSiteParameterArray &&parameters)
Construct a call edge using a DWARFExpression to identify the callee, and a return PC within the call...
Definition Function.cpp:204
SymbolContext GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override
Get the callee's definition, resolved against images.
Definition Function.cpp:213
DWARFExpressionList call_target
Definition Function.h:363
void DumpStopContext(Stream *s) const
Definition Function.cpp:84
ConstString GetDisplayName() const
Definition Function.cpp:99
Declaration & GetCallSite()
Get accessor for the call site declaration information.
Definition Function.cpp:105
ConstString GetName() const
Definition Function.cpp:93
~InlineFunctionInfo() override
Destructor.
Mangled m_mangled
Mangled inlined function name (can be empty if there is no mangled information).
Definition Function.h:231
int Compare(const InlineFunctionInfo &lhs, const InlineFunctionInfo &rhs)
Compare two inlined function information objects.
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:62
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition Function.cpp:78
Mangled & GetMangled()
Get accessor for the mangled name object.
Definition Function.cpp:111
A class that handles mangled names.
Definition Mangled.h:34
A collection class for Module objects.
Definition ModuleList.h:125
A stream class that can stream formatted output to a file.
Definition Stream.h:28
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
Defines a symbol context baton that can be handed other debug core functions.
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
NonNullSharedPtr< lldb_private::SupportFile > SupportFileNSP
Definition SupportFile.h:80
llvm::SmallVector< CallSiteParameter, 0 > CallSiteParameterArray
A vector of CallSiteParameter.
Definition Function.h:248
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
LanguageType
Programming language type.
std::shared_ptr< lldb_private::Disassembler > DisassemblerSP
uint64_t user_id_t
Definition lldb-types.h:83
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Module > ModuleSP
Represent the locations of a parameter at a call site, both in the caller and in the callee.
Definition Function.h:242
DWARFExpressionList LocationInCaller
Definition Function.h:244
DWARFExpressionList LocationInCallee
Definition Function.h:243
A line table entry class.
Definition LineEntry.h:21
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
Definition UserID.h:33