LLDB mainline
lldb_private::Block Class Reference

A class that describes a single lexical block. More...

#include "lldb/Symbol/Block.h"

Inheritance diagram for lldb_private::Block:
[legend]

Public Types

typedef RangeVector< int32_t, uint32_t, 1 > RangeList
typedef RangeList::Entry Range

Public Member Functions

 Block (Function &function, lldb::user_id_t function_uid)
 ~Block () override
lldb::BlockSP CreateChild (lldb::user_id_t uid)
 Creates a block with the specified UID uid.
void AddRange (const Range &range)
 Add a new offset range to this block.
void FinalizeRanges ()
void CalculateSymbolContext (SymbolContext *sc) override
 Reconstruct the object's symbol context into sc.
lldb::ModuleSP CalculateSymbolContextModule () override
CompileUnitCalculateSymbolContextCompileUnit () override
FunctionCalculateSymbolContextFunction () override
BlockCalculateSymbolContextBlock () override
FunctionGetFunction ()
bool Contains (lldb::addr_t range_offset) const
 Check if an offset is in one of the block offset ranges.
bool Contains (const Range &range) const
 Check if a offset range is in one of the block offset ranges.
bool Contains (const Block *block) const
 Check if this object contains "block" as a child block at any depth.
void Dump (Stream *s, lldb::addr_t base_addr, int32_t depth, bool show_context) const
 Dump the block contents.
void DumpSymbolContext (Stream *s) override
 Dump the object's symbol context to the stream s.
void DumpAddressRanges (Stream *s, lldb::addr_t base_addr)
void GetDescription (Stream *s, Function *function, lldb::DescriptionLevel level, Target *target) const
BlockGetParent () const
 Get the parent block.
BlockGetContainingInlinedBlock ()
 Get the inlined block that contains this block.
BlockGetInlinedParent ()
 Get the inlined parent block for this block.
BlockGetContainingInlinedBlockWithCallSite (const Declaration &find_call_site)
 Get the inlined block at the given call site that contains this block.
BlockGetSibling () const
 Get the sibling block for this block.
BlockGetFirstChild () const
 Get the first child block.
lldb::VariableListSP GetBlockVariableList (bool can_create)
 Get the variable list for this block only.
uint32_t AppendBlockVariables (bool can_create, bool get_child_block_variables, bool stop_if_child_block_is_inlined_function, const std::function< bool(Variable *)> &filter, VariableList *variable_list)
 Get the variable list for this block and optionally all child blocks if get_child_variables is true.
uint32_t AppendVariables (bool can_create, bool get_parent_variables, bool stop_if_block_is_inlined_function, const std::function< bool(Variable *)> &filter, VariableList *variable_list)
 Appends the variables from this block, and optionally from all parent blocks, to variable_list.
const InlineFunctionInfoGetInlinedFunctionInfo () const
 Get const accessor for any inlined function information.
SymbolFileGetSymbolFile ()
 Get the symbol file which contains debug info for this block's symbol context module.
CompilerDeclContext GetDeclContext ()
size_t MemorySize () const
 Get the memory cost of this object.
void SetInlinedFunctionInfo (const char *name, const char *mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr)
 Set accessor for any inlined function information.
void SetVariableList (lldb::VariableListSP &variable_list_sp)
 Set accessor for the variable list.
bool BlockInfoHasBeenParsed () const
void SetBlockInfoHasBeenParsed (bool b, bool set_children)
BlockFindBlockByID (lldb::user_id_t block_id)
BlockFindInnermostBlockByOffset (const lldb::addr_t offset)
size_t GetNumRanges () const
bool GetRangeContainingOffset (const lldb::addr_t offset, Range &range)
bool GetRangeContainingAddress (const Address &addr, AddressRange &range)
bool GetRangeContainingLoadAddress (lldb::addr_t load_addr, Target &target, AddressRange &range)
uint32_t GetRangeIndexContainingAddress (const Address &addr)
bool GetRangeAtIndex (uint32_t range_idx, AddressRange &range)
AddressRanges GetRanges ()
bool GetStartAddress (Address &addr)
void SetDidParseVariables (bool b, bool set_children)
Public Member Functions inherited from lldb_private::UserID
 UserID (lldb::user_id_t uid=LLDB_INVALID_UID)
 Construct with optional user ID.
 ~UserID ()=default
 Destructor.
void Clear ()
 Clears the object state.
lldb::user_id_t GetID () const
 Get accessor for the user ID.
void SetID (lldb::user_id_t uid)
 Set accessor for the user ID.
Public Member Functions inherited from lldb_private::SymbolContextScope
virtual ~SymbolContextScope ()=default
virtual SymbolCalculateSymbolContextSymbol ()

Protected Types

typedef std::vector< lldb::BlockSPcollection

Protected Member Functions

BlockGetSiblingForChild (const Block *child_block) const

Protected Attributes

SymbolContextScopem_parent_scope
collection m_children
RangeList m_ranges
 Address ranges of this block.
lldb::InlineFunctionInfoSP m_inlineInfoSP
 Inlined function information.
lldb::VariableListSP m_variable_list_sp
 The variable list for all local, static and parameter variables scoped to this block.
bool m_parsed_block_info: 1
 Set to true if this block and it's children have all been parsed.
bool m_parsed_block_variables: 1
bool m_parsed_child_blocks: 1
Protected Attributes inherited from lldb_private::UserID
lldb::user_id_t m_uid
 The user ID that uniquely identifies an object.

Private Member Functions

 Block (const Block &)=delete
const Blockoperator= (const Block &)=delete
 Block (lldb::user_id_t uid, SymbolContextScope &parent_scope)

Detailed Description

A class that describes a single lexical block.

A Function object owns a BlockList object which owns one or more Block objects. The BlockList object contains a section offset address range, and Block objects contain one or more ranges which are offsets into that range. Blocks are can have discontiguous ranges within the BlockList address range, and each block can contain child blocks each with their own sets of ranges.

Each block has a variable list that represents local, argument, and static variables that are scoped to the block.

Inlined functions are represented by attaching a InlineFunctionInfo shared pointer object to a block. Inlined functions are represented as named blocks.

Definition at line 41 of file Block.h.

Member Typedef Documentation

◆ collection

typedef std::vector<lldb::BlockSP> lldb_private::Block::collection
protected

Definition at line 353 of file Block.h.

◆ Range

Definition at line 44 of file Block.h.

◆ RangeList

typedef RangeVector<int32_t, uint32_t, 1> lldb_private::Block::RangeList

Definition at line 43 of file Block.h.

Constructor & Destructor Documentation

◆ Block() [1/3]

◆ ~Block()

Block::~Block ( )
overridedefault

References Block().

◆ Block() [2/3]

lldb_private::Block::Block ( const Block & )
privatedelete

References Block().

◆ Block() [3/3]

Block::Block ( lldb::user_id_t uid,
SymbolContextScope & parent_scope )
private

Member Function Documentation

◆ AddRange()

◆ AppendBlockVariables()

uint32_t Block::AppendBlockVariables ( bool can_create,
bool get_child_block_variables,
bool stop_if_child_block_is_inlined_function,
const std::function< bool(Variable *)> & filter,
VariableList * variable_list )

Get the variable list for this block and optionally all child blocks if get_child_variables is true.

Parameters
[in]can_createIf true, the variables can be parsed if they already haven't been, else the current state of the block will be returned. Passing true for this parameter can be used to see the current state of what has been parsed up to this point.
[in]get_child_block_variablesIf true, all variables from all child blocks will be added to the variable list.
Returns
A variable list shared pointer that contains all variables for this block.

Definition at line 406 of file Block.cpp.

References lldb_private::VariableList::AddVariable(), AppendBlockVariables(), Block(), GetBlockVariableList(), GetInlinedFunctionInfo(), and m_children.

Referenced by AppendBlockVariables(), and lldb_private::StackFrame::GetVariableList().

◆ AppendVariables()

uint32_t Block::AppendVariables ( bool can_create,
bool get_parent_variables,
bool stop_if_block_is_inlined_function,
const std::function< bool(Variable *)> & filter,
VariableList * variable_list )

Appends the variables from this block, and optionally from all parent blocks, to variable_list.

Parameters
[in]can_createIf true, the variables can be parsed if they already haven't been, else the current state of the block will be returned. Passing true for this parameter can be used to see the current state of what has been parsed up to this point.
[in]get_parent_variablesIf true, all variables from all parent blocks will be added to the variable list.
[in]stop_if_block_is_inlined_functionIf true, all variables from all parent blocks will be added to the variable list until there are no parent blocks or the parent block has inlined function info.
[in,out]variable_listAll variables in this block, and optionally all parent blocks will be added to this list.
Returns
The number of variable that were appended to variable_list.

Definition at line 436 of file Block.cpp.

References lldb_private::VariableList::AddVariable(), AppendVariables(), Block(), GetBlockVariableList(), GetInlinedFunctionInfo(), and GetParent().

Referenced by AppendVariables(), lldb_private::Address::Dump(), lldb::SBFrame::FindValue(), and lldb_private::StackFrame::FindVariable().

◆ BlockInfoHasBeenParsed()

bool lldb_private::Block::BlockInfoHasBeenParsed ( ) const
inline

Definition at line 323 of file Block.h.

References m_parsed_block_info.

◆ CalculateSymbolContext()

void Block::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 137 of file Block.cpp.

References lldb_private::SymbolContext::block, and m_parent_scope.

Referenced by GetBlockVariableList(), GetModuleConfig(), lldb_private::SymbolContext::GetParentOfInlinedScope(), lldb_private::ThreadPlanStepOut::QueueInlinedStepPlan(), and SetupDeclVendor().

◆ CalculateSymbolContextBlock()

Block * Block::CalculateSymbolContextBlock ( )
overridevirtual

Reimplemented from lldb_private::SymbolContextScope.

Definition at line 154 of file Block.cpp.

References Block().

◆ CalculateSymbolContextCompileUnit()

CompileUnit * Block::CalculateSymbolContextCompileUnit ( )
overridevirtual

Reimplemented from lldb_private::SymbolContextScope.

Definition at line 146 of file Block.cpp.

References m_parent_scope.

◆ CalculateSymbolContextFunction()

◆ CalculateSymbolContextModule()

lldb::ModuleSP Block::CalculateSymbolContextModule ( )
overridevirtual

Reimplemented from lldb_private::SymbolContextScope.

Definition at line 142 of file Block.cpp.

References m_parent_scope.

Referenced by GetSymbolFile().

◆ Contains() [1/3]

bool Block::Contains ( const Block * block) const

Check if this object contains "block" as a child block at any depth.

Parameters
[in]blockA potential child block.
Returns
Returns true if block is a child of this block, false otherwise.

Definition at line 184 of file Block.cpp.

References Block(), and GetParent().

◆ Contains() [2/3]

bool Block::Contains ( const Range & range) const

Check if a offset range is in one of the block offset ranges.

Parameters
[in]rangeAn offset range into the Function's address range.
Returns
Returns true if range falls in one of this block's ranges, false otherwise.

Definition at line 198 of file Block.cpp.

References m_ranges.

◆ Contains() [3/3]

bool Block::Contains ( lldb::addr_t range_offset) const

Check if an offset is in one of the block offset ranges.

Parameters
[in]range_offsetAn offset into the Function's address range.
Returns
Returns true if range_offset falls in one of this block's ranges, false otherwise.

Definition at line 180 of file Block.cpp.

References m_ranges.

Referenced by AddRange(), Dump(), lldb_private::Variable::IsInScope(), and lldb_private::operator<().

◆ CreateChild()

BlockSP Block::CreateChild ( lldb::user_id_t uid)

Creates a block with the specified UID uid.

Parameters
[in]uidThe UID for a given block. This value is given by the SymbolFile plug-in and can be any value that helps the SymbolFile plug-in to match this block back to the debug information data that it parses for further or more in depth parsing. Common values would be the index into a table, or an offset into the debug information.

Definition at line 380 of file Block.cpp.

References Block(), and m_children.

Referenced by lldb_private::npdb::SymbolFileNativePDB::CreateBlock(), lldb_private::plugin::dwarf::SymbolFileDWARF::ParseBlocksRecursive(), and ParseFunctionBlocksForPDBSymbol().

◆ Dump()

void Block::Dump ( Stream * s,
lldb::addr_t base_addr,
int32_t depth,
bool show_context ) const

Dump the block contents.

Parameters
[in]sThe stream to which to dump the object description.
[in]base_addrThe resolved start address of the Function's address range. This should be resolved as the file or load address prior to passing the value into this function for dumping.
[in]depthLimit the number of levels deep that this function should print as this block can contain child blocks. Specify INT_MAX to dump all child blocks.
[in]show_contextIf true, variables will dump their context information.

Definition at line 60 of file Block.cpp.

References lldb_private::Stream::AsRawOstream(), Block(), Contains(), Dump(), lldb_private::DumpAddressRange(), lldb_private::Stream::EOL(), lldb_private::UserID::GetID(), GetParent(), lldb_private::Range< B, S >::GetRangeBase(), lldb_private::Range< B, S >::GetRangeEnd(), lldb_private::Stream::Indent(), lldb_private::Stream::IndentLess(), lldb_private::Stream::IndentMore(), m_children, m_inlineInfoSP, m_ranges, m_variable_list_sp, lldb_private::Stream::Printf(), and lldb_private::UserID::UserID().

Referenced by Dump().

◆ DumpAddressRanges()

◆ DumpSymbolContext()

void Block::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 164 of file Block.cpp.

References lldb_private::Function::DumpSymbolContext(), GetFunction(), lldb_private::UserID::GetID(), and lldb_private::Stream::Printf().

◆ FinalizeRanges()

void Block::FinalizeRanges ( )

◆ FindBlockByID()

◆ FindInnermostBlockByOffset()

Block * Block::FindInnermostBlockByOffset ( const lldb::addr_t offset)

Definition at line 127 of file Block.cpp.

References Block(), lldb_private::Contains, and m_children.

◆ GetBlockVariableList()

VariableListSP Block::GetBlockVariableList ( bool can_create)

◆ GetContainingInlinedBlock()

◆ GetContainingInlinedBlockWithCallSite()

Block * Block::GetContainingInlinedBlockWithCallSite ( const Declaration & find_call_site)

Get the inlined block at the given call site that contains this block.

Parameters
[in]find_call_sitea declaration with the file and line of the call site to find.
Returns
If this block contains inlined function info and is at the call site given by the file and line at the given declaration, then it will return this block, otherwise the parent blocks will be searched to see if any is at the call site. nullptr will be returned if no block is found at the call site.

Definition at line 223 of file Block.cpp.

References Block(), GetContainingInlinedBlock(), GetInlinedFunctionInfo(), and GetInlinedParent().

Referenced by lldb_private::LineEntry::GetSameLineContiguousAddressRange().

◆ GetDeclContext()

◆ GetDescription()

◆ GetFirstChild()

Block * lldb_private::Block::GetFirstChild ( ) const
inline

Get the first child block.

Returns
The first child block pointer, or nullptr if this block has no children.

Definition at line 194 of file Block.h.

References Block(), and m_children.

Referenced by lldb_private::CompileUnit::ResolveSymbolContext().

◆ GetFunction()

◆ GetInlinedFunctionInfo()

◆ GetInlinedParent()

Block * Block::GetInlinedParent ( )

◆ GetNumRanges()

size_t lldb_private::Block::GetNumRanges ( ) const
inline

◆ GetParent()

◆ GetRangeAtIndex()

◆ GetRangeContainingAddress()

◆ GetRangeContainingLoadAddress()

bool Block::GetRangeContainingLoadAddress ( lldb::addr_t load_addr,
Target & target,
AddressRange & range )

◆ GetRangeContainingOffset()

bool Block::GetRangeContainingOffset ( const lldb::addr_t offset,
Range & range )

Definition at line 238 of file Block.cpp.

References lldb_private::Range< B, S >::Clear(), and m_ranges.

◆ GetRangeIndexContainingAddress()

◆ GetRanges()

◆ GetSibling()

Block * Block::GetSibling ( ) const

Get the sibling block for this block.

Returns
The sibling block pointer, or nullptr if this block has no sibling.

Definition at line 498 of file Block.cpp.

References Block(), GetParent(), and GetSiblingForChild().

Referenced by lldb_private::CompileUnit::ResolveSymbolContext().

◆ GetSiblingForChild()

Block * Block::GetSiblingForChild ( const Block * child_block) const
protected

Definition at line 506 of file Block.cpp.

References Block(), and m_children.

Referenced by GetSibling().

◆ GetStartAddress()

◆ GetSymbolFile()

SymbolFile * Block::GetSymbolFile ( )

Get the symbol file which contains debug info for this block's symbol context module.

Returns
A pointer to the symbol file or nullptr.

Definition at line 467 of file Block.cpp.

References CalculateSymbolContextModule().

Referenced by lldb_private::Function::GetCallEdges(), and GetDeclContext().

◆ MemorySize()

size_t Block::MemorySize ( ) const

Get the memory cost of this object.

Returns the cost of this object plus any owned objects from the ranges, variables, and inline function information.

Returns
The number of bytes that this object occupies in memory.

Definition at line 371 of file Block.cpp.

References Block(), m_inlineInfoSP, m_ranges, and m_variable_list_sp.

◆ operator=()

const Block & lldb_private::Block::operator= ( const Block & )
privatedelete

References Block().

◆ SetBlockInfoHasBeenParsed()

void Block::SetBlockInfoHasBeenParsed ( bool b,
bool set_children )

◆ SetDidParseVariables()

◆ SetInlinedFunctionInfo()

void Block::SetInlinedFunctionInfo ( const char * name,
const char * mangled,
const Declaration * decl_ptr,
const Declaration * call_decl_ptr )

Set accessor for any inlined function information.

Parameters
[in]nameThe method name for the inlined function. This value should not be nullptr.
[in]mangledThe mangled method name for the inlined function. This can be nullptr if there is no mangled name for an inlined function or if the name is the same as name.
[in]decl_ptrA optional pointer to declaration information for the inlined function information. This value can be nullptr to indicate that no declaration information is available.
[in]call_decl_ptrOptional calling location declaration information that describes from where this inlined function was called.

Definition at line 385 of file Block.cpp.

References m_inlineInfoSP.

Referenced by lldb_private::plugin::dwarf::SymbolFileDWARF::ParseBlocksRecursive().

◆ SetVariableList()

void lldb_private::Block::SetVariableList ( lldb::VariableListSP & variable_list_sp)
inline

Set accessor for the variable list.

Called by the SymbolFile plug-ins after they have parsed the variable lists and are ready to hand ownership of the list over to this object.

Parameters
[in]variable_list_spA shared pointer to a VariableList.

Definition at line 319 of file Block.h.

References m_variable_list_sp.

Referenced by SymbolFilePDB::ParseVariables(), lldb_private::npdb::SymbolFileNativePDB::ParseVariablesForBlock(), and lldb_private::plugin::dwarf::SymbolFileDWARF::ParseVariablesInFunctionContextRecursive().

Member Data Documentation

◆ m_children

◆ m_inlineInfoSP

lldb::InlineFunctionInfoSP lldb_private::Block::m_inlineInfoSP
protected

Inlined function information.

Definition at line 363 of file Block.h.

Referenced by Dump(), GetDescription(), GetInlinedFunctionInfo(), MemorySize(), and SetInlinedFunctionInfo().

◆ m_parent_scope

◆ m_parsed_block_info

bool lldb_private::Block::m_parsed_block_info
protected

Set to true if this block and it's children have all been parsed.

Definition at line 367 of file Block.h.

Referenced by Block(), BlockInfoHasBeenParsed(), and SetBlockInfoHasBeenParsed().

◆ m_parsed_block_variables

bool lldb_private::Block::m_parsed_block_variables
protected

Definition at line 369 of file Block.h.

Referenced by Block(), GetBlockVariableList(), and SetDidParseVariables().

◆ m_parsed_child_blocks

bool lldb_private::Block::m_parsed_child_blocks
protected

Definition at line 369 of file Block.h.

Referenced by Block(), and SetBlockInfoHasBeenParsed().

◆ m_ranges

RangeList lldb_private::Block::m_ranges
protected

Address ranges of this block.

They are relative to the function entry point so one must add/subtract GetFunction().GetAddress().GetFileAddress() when converting from/to to the AddressRange representation.

Definition at line 361 of file Block.h.

Referenced by AddRange(), Contains(), Contains(), Dump(), DumpAddressRanges(), FinalizeRanges(), GetDescription(), GetNumRanges(), GetRangeAtIndex(), GetRangeContainingAddress(), GetRangeContainingOffset(), GetRangeIndexContainingAddress(), GetRanges(), GetStartAddress(), and MemorySize().

◆ m_variable_list_sp

lldb::VariableListSP lldb_private::Block::m_variable_list_sp
protected

The variable list for all local, static and parameter variables scoped to this block.

Definition at line 364 of file Block.h.

Referenced by Dump(), GetBlockVariableList(), MemorySize(), and SetVariableList().


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