LLDB  mainline
Public Member Functions | Protected Types | Protected Attributes | List of all members
lldb_private::Function Class Reference

A class that describes a function. More...

#include "lldb/Symbol/Function.h"

Inheritance diagram for lldb_private::Function:
Inheritance graph
[legend]
Collaboration diagram for lldb_private::Function:
Collaboration graph
[legend]

Public Member Functions

 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. More...
 
 ~Function () override
 Destructor. More...
 
void CalculateSymbolContext (SymbolContext *sc) override
 Reconstruct the object's symbol context into sc. More...
 
lldb::ModuleSP CalculateSymbolContextModule () override
 
CompileUnitCalculateSymbolContextCompileUnit () override
 
FunctionCalculateSymbolContextFunction () override
 
const AddressRangeGetAddressRange ()
 
lldb::LanguageType GetLanguage () const
 
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. More...
 
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. More...
 
llvm::MutableArrayRef< CallEdgeGetCallEdges ()
 Get the outgoing call edges from this function, sorted by their return PC addresses (in increasing order). More...
 
llvm::MutableArrayRef< CallEdgeGetTailCallingEdges ()
 Get the outgoing tail-calling edges from this function. More...
 
BlockGetBlock (bool can_create)
 Get accessor for the block list. More...
 
CompileUnitGetCompileUnit ()
 Get accessor for the compile unit that owns this function. More...
 
const CompileUnitGetCompileUnit () const
 Get const accessor for the compile unit that owns this function. More...
 
void GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target)
 
DWARFExpressionGetFrameBaseExpression ()
 Get accessor for the frame base location. More...
 
const DWARFExpressionGetFrameBaseExpression () const
 Get const accessor for the frame base location. More...
 
ConstString GetName () const
 
ConstString GetNameNoArguments () const
 
ConstString GetDisplayName () const
 
const Mangled & GetMangled () const
 
CompilerDeclContext GetDeclContext ()
 Get the DeclContext for this function, if available. More...
 
TypeGetType ()
 Get accessor for the type that describes the function return value type, and parameter types. More...
 
const TypeGetType () const
 Get const accessor for the type that describes the function return value type, and parameter types. More...
 
CompilerType GetCompilerType ()
 
uint32_t GetPrologueByteSize ()
 Get the size of the prologue instructions for this function. More...
 
void Dump (Stream *s, bool show_context) const
 Dump a description of this object to a Stream. More...
 
void DumpSymbolContext (Stream *s) override
 Dump the object's symbol context to the stream s. More...
 
size_t MemorySize () const
 Get the memory cost of this object. More...
 
bool GetIsOptimized ()
 Get whether compiler optimizations were enabled for this function. More...
 
bool IsTopLevelFunction ()
 Get whether this function represents a 'top-level' function. More...
 
lldb::DisassemblerSP GetInstructions (const ExecutionContext &exe_ctx, const char *flavor, bool prefer_file_cache)
 
bool GetDisassembly (const ExecutionContext &exe_ctx, const char *flavor, bool prefer_file_cache, Stream &strm)
 
- Public Member Functions inherited from lldb_private::UserID
 UserID (lldb::user_id_t uid=LLDB_INVALID_UID)
 Construct with optional user ID. More...
 
 ~UserID ()
 Destructor. More...
 
void Clear ()
 Clears the object state. More...
 
lldb::user_id_t GetID () const
 Get accessor for the user ID. More...
 
void SetID (lldb::user_id_t uid)
 Set accessor for the user ID. More...
 
- Public Member Functions inherited from lldb_private::SymbolContextScope
virtual ~SymbolContextScope ()=default
 
virtual BlockCalculateSymbolContextBlock ()
 
virtual SymbolCalculateSymbolContextSymbol ()
 

Protected Types

enum  { flagsCalculatedPrologueSize }
 

Protected Attributes

CompileUnitm_comp_unit
 The compile unit that owns this function. More...
 
lldb::user_id_t m_type_uid
 The user ID of for the prototype Type for this function. More...
 
Typem_type
 The function prototype type for this function that include the function info (FunctionInfo), return type and parameters. More...
 
Mangled m_mangled
 The mangled function name if any, if empty, there is no mangled information. More...
 
Block m_block
 All lexical blocks contained in this function. More...
 
AddressRange m_range
 The function address range that covers the widest range needed to contain all blocks. More...
 
DWARFExpression m_frame_base
 The frame base expression for variables that are relative to the frame pointer. More...
 
Flags m_flags
 
uint32_t m_prologue_byte_size
 Compute the prologue size once and cache it. More...
 
bool m_call_edges_resolved = false
 Whether call site info has been parsed. More...
 
std::vector< CallEdgem_call_edges
 Outgoing call edges. More...
 
- Protected Attributes inherited from lldb_private::UserID
lldb::user_id_t m_uid
 The user ID that uniquely identifies an object. More...
 

Detailed Description

A class that describes a function.

Functions belong to CompileUnit objects (Function::m_comp_unit), have unique user IDs (Function::UserID), know how to reconstruct their symbol context (Function::SymbolContextScope), have a specific function type (Function::m_type_uid), have a simple method name (FunctionInfo::m_name), be declared at a specific location (FunctionInfo::m_declaration), possibly have mangled names (Function::m_mangled), an optional return type (Function::m_type), and contains lexical blocks (Function::m_blocks).

The function information is split into a few pieces:

The abstract information is found in the function type (Type) that describes a function information, return type and parameter types.

The concrete information is the address range information and specific locations for an instance of this function.

Definition at line 323 of file Function.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
flagsCalculatedPrologueSize 

Have we already tried to calculate the prologue size?

Definition at line 545 of file Function.h.

Constructor & Destructor Documentation

◆ 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, function type, and a section offset based address range.

Parameters
[in]comp_unitThe compile unit to which this function belongs.
[in]func_uidThe UID for this function. This value is provided by the SymbolFile plug-in and can be any value that allows the plug-in to quickly find and parse more detailed information when and if more information is needed.
[in]func_type_uidThe type UID for the function Type to allow for lazy type parsing from the debug information.
[in]mangledThe optional mangled name for this function. If empty, there is no mangled information.
[in]func_typeThe optional function type. If NULL, the function type will be parsed on demand when accessed using the Function::GetType() function by asking the SymbolFile plug-in to get the type for func_type_uid.
[in]rangeThe section offset based address for this function.

Definition at line 182 of file Function.cpp.

References m_block, and lldb_private::Block::SetParentScope().

Referenced by MemorySize().

◆ ~Function()

Function::~Function ( )
override

Destructor.

Definition at line 192 of file Function.cpp.

Member Function Documentation

◆ CalculateSymbolContext()

void Function::CalculateSymbolContext ( SymbolContext sc)
overridevirtual

Reconstruct the object's symbol context into sc.

The object should fill in as much of the SymbolContext as it can so function calls that require a symbol context can be made for the given object.

Parameters
[out]scA symbol context object pointer that gets filled in.
See also
SymbolContextScope

Implements lldb_private::SymbolContextScope.

Definition at line 340 of file Function.cpp.

References lldb_private::CompileUnit::CalculateSymbolContext(), lldb_private::SymbolContext::function, and m_comp_unit.

Referenced by GetType().

◆ CalculateSymbolContextCompileUnit()

CompileUnit * Function::CalculateSymbolContextCompileUnit ( )
overridevirtual

Reimplemented from lldb_private::SymbolContextScope.

Definition at line 353 of file Function.cpp.

References GetCompileUnit().

◆ CalculateSymbolContextFunction()

Function * Function::CalculateSymbolContextFunction ( )
overridevirtual

Reimplemented from lldb_private::SymbolContextScope.

Definition at line 357 of file Function.cpp.

◆ CalculateSymbolContextModule()

ModuleSP Function::CalculateSymbolContextModule ( )
overridevirtual

◆ Dump()

void Function::Dump ( Stream s,
bool  show_context 
) const

Dump a description of this object to a Stream.

Dump a description of the contents of this object to the supplied stream s.

Parameters
[in]sThe stream to which to dump the object description.
[in]show_contextIf true, variables will dump their symbol context information.

Definition at line 321 of file Function.cpp.

References lldb_private::Block::BlockInfoHasBeenParsed(), lldb_private::Block::Dump(), lldb_private::Stream::EOL(), lldb_private::AddressRange::GetBaseAddress(), lldb_private::Address::GetFileAddress(), lldb_private::Stream::Indent(), LLDB_INVALID_UID, m_block, m_mangled, m_range, m_type, m_type_uid, and lldb_private::Stream::Printf().

◆ DumpSymbolContext()

void Function::DumpSymbolContext ( Stream s)
overridevirtual

Dump the object's symbol context to the stream s.

The object should dump its symbol context to the stream s. This function is widely used in the DumpDebug and verbose output for lldb objects.

Parameters
[in]sThe stream to which to dump the object's symbol context.
See also
SymbolContextScope

Implements lldb_private::SymbolContextScope.

Definition at line 393 of file Function.cpp.

References lldb_private::CompileUnit::DumpSymbolContext(), lldb_private::UserID::GetID(), m_comp_unit, and lldb_private::Stream::Printf().

◆ GetAddressRange()

const AddressRange& lldb_private::Function::GetAddressRange ( )
inline

◆ GetBlock()

Block & Function::GetBlock ( bool  can_create)

◆ GetCallEdges()

llvm::MutableArrayRef< CallEdge > Function::GetCallEdges ( )

◆ GetCompilerType()

CompilerType Function::GetCompilerType ( )

◆ GetCompileUnit() [1/2]

CompileUnit * Function::GetCompileUnit ( )

Get accessor for the compile unit that owns this function.

Returns
A compile unit object pointer.

Definition at line 297 of file Function.cpp.

References m_comp_unit.

Referenced by CalculateSymbolContextCompileUnit(), CalculateSymbolContextModule(), lldb::SBFunction::GetIsOptimized(), lldb::SBFunction::GetLanguage(), SymbolFileDWARFDebugMap::ParseBlocksRecursive(), and SymbolFileDWARF::ParseBlocksRecursive().

◆ GetCompileUnit() [2/2]

const CompileUnit * Function::GetCompileUnit ( ) const

Get const accessor for the compile unit that owns this function.

Returns
A const compile unit object pointer.

Definition at line 299 of file Function.cpp.

References m_comp_unit.

◆ GetDeclContext()

CompilerDeclContext Function::GetDeclContext ( )

◆ GetDescription()

void Function::GetDescription ( Stream s,
lldb::DescriptionLevel  level,
Target target 
)

◆ GetDisassembly()

bool Function::GetDisassembly ( const ExecutionContext exe_ctx,
const char *  flavor,
bool  prefer_file_cache,
Stream strm 
)

Definition at line 372 of file Function.cpp.

References GetInstructions().

◆ GetDisplayName()

ConstString Function::GetDisplayName ( ) const

Definition at line 423 of file Function.cpp.

References GetLanguage(), and m_mangled.

Referenced by FindInterveningFrames(), and GetCallEdges().

◆ GetEndLineSourceInfo()

void Function::GetEndLineSourceInfo ( FileSpec source_file,
uint32_t line_no 
)

◆ GetFrameBaseExpression() [1/2]

DWARFExpression& lldb_private::Function::GetFrameBaseExpression ( )
inline

Get accessor for the frame base location.

Returns
A location expression that describes the function frame base.

Definition at line 433 of file Function.h.

Referenced by lldb_private::StackFrame::GetFrameBaseExpression(), and lldb_private::StackFrame::GetFrameBaseValue().

◆ GetFrameBaseExpression() [2/2]

const DWARFExpression& lldb_private::Function::GetFrameBaseExpression ( ) const
inline

Get const accessor for the frame base location.

Returns
A const compile unit object pointer.

Definition at line 439 of file Function.h.

References lldb_private::FunctionInfo::GetName().

◆ GetInstructions()

lldb::DisassemblerSP Function::GetInstructions ( const ExecutionContext exe_ctx,
const char *  flavor,
bool  prefer_file_cache 
)

Definition at line 359 of file Function.cpp.

References lldb_private::Disassembler::DisassembleRange(), and GetAddressRange().

Referenced by GetDisassembly().

◆ GetIsOptimized()

bool Function::GetIsOptimized ( )

Get whether compiler optimizations were enabled for this function.

The debug information may provide information about whether this function was compiled with optimization or not. In this case, "optimized" means that the debug experience may be difficult for the user to understand. Variables may not be available when the developer would expect them, stepping through the source lines in the function may appear strange, etc.

Returns
Returns 'true' if this function was compiled with optimization. 'false' indicates that either the optimization is unknown, or this function was built without optimization.

Definition at line 403 of file Function.cpp.

References lldb_private::CompileUnit::GetIsOptimized(), and m_comp_unit.

Referenced by lldb_private::FormatEntity::Format(), and lldb_private::Process::PrintWarningOptimization().

◆ GetLanguage()

lldb::LanguageType Function::GetLanguage ( ) const

◆ GetMangled()

const Mangled& lldb_private::Function::GetMangled ( ) const
inline

◆ GetName()

ConstString Function::GetName ( ) const

◆ GetNameNoArguments()

ConstString Function::GetNameNoArguments ( ) const

◆ GetPrologueByteSize()

uint32_t Function::GetPrologueByteSize ( )

◆ GetStartLineSourceInfo()

void Function::GetStartLineSourceInfo ( FileSpec source_file,
uint32_t line_no 
)

Find the file and line number of the source location of the start of the function.

This will use the declaration if present and fall back on the line table if that fails. So there may NOT be a line table entry for this source file/line combo.

Parameters
[out]source_fileThe source file.
[out]line_noThe line number.

Definition at line 194 of file Function.cpp.

References lldb_private::FileSpec::Clear(), lldb_private::LineEntry::file, lldb_private::LineTable::FindLineEntryByAddress(), GetAddressRange(), lldb_private::Type::GetDeclaration(), lldb_private::Declaration::GetFile(), lldb_private::Declaration::GetLine(), lldb_private::CompileUnit::GetLineTable(), GetType(), lldb_private::LineEntry::line, m_comp_unit, and m_type.

Referenced by CommandObjectSourceList::DisplayFunctionSource(), lldb_private::BreakpointResolverFileLine::FilterContexts(), lldb_private::Disassembler::GetFunctionDeclLineEntry(), and lldb_private::Disassembler::PrintInstructions().

◆ GetTailCallingEdges()

llvm::MutableArrayRef< CallEdge > Function::GetTailCallingEdges ( )

Get the outgoing tail-calling edges from this function.

If none exist, return None.

Definition at line 272 of file Function.cpp.

References GetCallEdges(), lldb_private::CallEdge::GetUnresolvedReturnPCAddress(), and LLDB_INVALID_ADDRESS.

Referenced by FindInterveningFrames().

◆ GetType() [1/2]

Type * Function::GetType ( )

◆ GetType() [2/2]

const Type * Function::GetType ( ) const

Get const accessor for the type that describes the function return value type, and parameter types.

Returns
A const type object pointer.

Definition at line 467 of file Function.cpp.

References m_type.

◆ IsTopLevelFunction()

bool Function::IsTopLevelFunction ( )

Get whether this function represents a 'top-level' function.

The concept of a top-level function is language-specific, mostly meant to represent the notion of scripting-style code that has global visibility of the variables/symbols/functions/... defined within the containing file/module

If stopped in a top-level function, LLDB will expose global variables as-if locals in the 'frame variable' command

Returns
Returns 'true' if this function is a top-level function, 'false' otherwise.

Definition at line 414 of file Function.cpp.

References lldb_private::Language::FindPlugin(), and GetLanguage().

◆ MemorySize()

size_t Function::MemorySize ( ) const

Get the memory cost of this object.

Returns
The number of bytes that this object occupies in memory. The returned value does not include the bytes for any shared string values.
See also
ConstString::StaticMemorySize ()

Definition at line 398 of file Function.cpp.

References Function(), m_block, and lldb_private::Block::MemorySize().

Member Data Documentation

◆ m_block

Block lldb_private::Function::m_block
protected

All lexical blocks contained in this function.

Definition at line 558 of file Function.h.

Referenced by Dump(), Function(), GetBlock(), and MemorySize().

◆ m_call_edges

std::vector<CallEdge> lldb_private::Function::m_call_edges
protected

Outgoing call edges.

Definition at line 569 of file Function.h.

Referenced by GetCallEdges().

◆ m_call_edges_resolved

bool lldb_private::Function::m_call_edges_resolved = false
protected

Whether call site info has been parsed.

Definition at line 567 of file Function.h.

Referenced by GetCallEdges().

◆ m_comp_unit

CompileUnit* lldb_private::Function::m_comp_unit
protected

◆ m_flags

Flags lldb_private::Function::m_flags
protected

Definition at line 563 of file Function.h.

Referenced by GetPrologueByteSize().

◆ m_frame_base

DWARFExpression lldb_private::Function::m_frame_base
protected

The frame base expression for variables that are relative to the frame pointer.

Definition at line 561 of file Function.h.

◆ m_mangled

Mangled lldb_private::Function::m_mangled
protected

The mangled function name if any, if empty, there is no mangled information.

Definition at line 556 of file Function.h.

Referenced by Dump(), GetDescription(), GetDisplayName(), GetName(), and GetNameNoArguments().

◆ m_prologue_byte_size

uint32_t lldb_private::Function::m_prologue_byte_size
protected

Compute the prologue size once and cache it.

Definition at line 565 of file Function.h.

Referenced by GetPrologueByteSize().

◆ m_range

AddressRange lldb_private::Function::m_range
protected

The function address range that covers the widest range needed to contain all blocks.

Definition at line 559 of file Function.h.

Referenced by CalculateSymbolContextModule(), Dump(), and GetPrologueByteSize().

◆ m_type

Type* lldb_private::Function::m_type
protected

The function prototype type for this function that include the function info (FunctionInfo), return type and parameters.

Definition at line 554 of file Function.h.

Referenced by Dump(), GetStartLineSourceInfo(), and GetType().

◆ m_type_uid

lldb::user_id_t lldb_private::Function::m_type_uid
protected

The user ID of for the prototype Type for this function.

Definition at line 553 of file Function.h.

Referenced by Dump(), and GetType().


The documentation for this class was generated from the following files: