LLDB  mainline
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
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:
Inheritance graph
[legend]
Collaboration diagram for lldb_private::Block:
Collaboration graph
[legend]

Public Types

typedef RangeArray< uint32_t, uint32_t, 1 > RangeList
 
typedef RangeList::Entry Range
 

Public Member Functions

 Block (lldb::user_id_t uid)
 Construct with a User ID uid, depth. More...
 
 ~Block () override
 Destructor. More...
 
void AddChild (const lldb::BlockSP &child_block_sp)
 Add a child to this object. More...
 
void AddRange (const Range &range)
 Add a new offset range to this block. More...
 
void FinalizeRanges ()
 
void CalculateSymbolContext (SymbolContext *sc) override
 Reconstruct the object's symbol context into sc. More...
 
lldb::ModuleSP CalculateSymbolContextModule () override
 
CompileUnitCalculateSymbolContextCompileUnit () override
 
FunctionCalculateSymbolContextFunction () override
 
BlockCalculateSymbolContextBlock () override
 
bool Contains (lldb::addr_t range_offset) const
 Check if an offset is in one of the block offset ranges. More...
 
bool Contains (const Range &range) const
 Check if a offset range is in one of the block offset ranges. More...
 
bool Contains (const Block *block) const
 Check if this object contains "block" as a child block at any depth. More...
 
void Dump (Stream *s, lldb::addr_t base_addr, int32_t depth, bool show_context) const
 Dump the block contents. More...
 
void DumpSymbolContext (Stream *s) override
 Dump the object's symbol context to the stream s. More...
 
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. More...
 
BlockGetContainingInlinedBlock ()
 Get the inlined block that contains this block. More...
 
BlockGetInlinedParent ()
 Get the inlined parent block for this block. More...
 
BlockGetContainingInlinedBlockWithCallSite (const Declaration &find_call_site)
 Get the inlined block at the given call site that contains this block. More...
 
BlockGetSibling () const
 Get the sibling block for this block. More...
 
BlockGetFirstChild () const
 Get the first child block. More...
 
lldb::VariableListSP GetBlockVariableList (bool can_create)
 Get the variable list for this block only. More...
 
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. More...
 
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. More...
 
const InlineFunctionInfoGetInlinedFunctionInfo () const
 Get const accessor for any inlined function information. More...
 
SymbolFileGetSymbolFile ()
 Get the symbol file which contains debug info for this block's symbol context module. More...
 
CompilerDeclContext GetDeclContext ()
 
size_t MemorySize () const
 Get the memory cost of this object. More...
 
void SetInlinedFunctionInfo (const char *name, const char *mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr)
 Set accessor for any inlined function information. More...
 
void SetParentScope (SymbolContextScope *parent_scope)
 
void SetVariableList (lldb::VariableListSP &variable_list_sp)
 Set accessor for the variable list. More...
 
bool BlockInfoHasBeenParsed () const
 
void SetBlockInfoHasBeenParsed (bool b, bool set_children)
 
BlockFindBlockByID (lldb::user_id_t block_id)
 
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)
 
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. 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 SymbolCalculateSymbolContextSymbol ()
 

Protected Types

typedef std::vector< lldb::BlockSP > collection
 

Protected Member Functions

BlockGetSiblingForChild (const Block *child_block) const
 

Protected Attributes

SymbolContextScopem_parent_scope
 
collection m_children
 
RangeList m_ranges
 
lldb::InlineFunctionInfoSP m_inlineInfoSP
 Inlined function information. More...
 
lldb::VariableListSP m_variable_list_sp
 The variable list for all local, static and parameter variables scoped to this block. More...
 
bool m_parsed_block_info: 1
 Set to true if this block and it's children have all been parsed. More...
 
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. More...
 

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 381 of file Block.h.

◆ Range

Definition at line 44 of file Block.h.

◆ RangeList

Definition at line 43 of file Block.h.

Constructor & Destructor Documentation

◆ Block()

Block::Block ( lldb::user_id_t  uid)

Construct with a User ID uid, depth.

Initialize this block with the specified UID uid. The depth in the block_list is used to represent the parent, sibling, and child block information and also allows for partial parsing at the block level.

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.
[in]depthThe integer depth of this block in the block list hierarchy.
[in]block_listThe block list that this object belongs to.
See also
BlockList

Definition at line 24 of file Block.cpp.

Referenced by MemorySize().

◆ ~Block()

Block::~Block ( )
override

Destructor.

Definition at line 29 of file Block.cpp.

Member Function Documentation

◆ AddChild()

void Block::AddChild ( const lldb::BlockSP &  child_block_sp)

Add a child to this object.

Parameters
[in]child_block_spA shared pointer to a child block that will get added to this block.

Definition at line 373 of file Block.cpp.

References m_children.

Referenced by lldb_private::npdb::SymbolFileNativePDB::GetNumCompileUnits(), SymbolFileDWARF::ParseBlocksRecursive(), and ParseFunctionBlocksForPDBSymbol().

◆ AddRange()

void Block::AddRange ( const Range range)

◆ 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]get_child_variablesIf true, all variables from all child blocks will be added to the variable list.
[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]add_inline_child_block_variablesIf this is false, no child variables of child blocks that are inlined functions will be gotten. If true then all child variables will be added regardless of whether they come from inlined functions or not.
Returns
A variable list shared pointer that contains all variables for this block.

Definition at line 401 of file Block.cpp.

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

Referenced by AppendBlockVariables(), GetFirstChild(), 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 432 of file Block.cpp.

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

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

◆ BlockInfoHasBeenParsed()

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

◆ 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 126 of file Block.cpp.

References lldb_private::SymbolContext::block, lldb_private::SymbolContextScope::CalculateSymbolContext(), and m_parent_scope.

Referenced by GetBlockVariableList(), lldb::SBBlock::GetDescription(), lldb_private::SymbolContext::GetParentOfInlinedScope(), lldb_private::ThreadPlanStepOut::QueueInlinedStepPlan(), and SupportsCxxModuleImport().

◆ CalculateSymbolContextBlock()

Block * Block::CalculateSymbolContextBlock ( )
overridevirtual

Reimplemented from lldb_private::SymbolContextScope.

Definition at line 150 of file Block.cpp.

◆ CalculateSymbolContextCompileUnit()

CompileUnit * Block::CalculateSymbolContextCompileUnit ( )
overridevirtual

◆ CalculateSymbolContextFunction()

Function * Block::CalculateSymbolContextFunction ( )
overridevirtual

◆ CalculateSymbolContextModule()

lldb::ModuleSP Block::CalculateSymbolContextModule ( )
overridevirtual

◆ Contains() [1/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 170 of file Block.cpp.

References lldb_private::RangeArray< B, S, N >::FindEntryThatContains(), and m_ranges.

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

◆ 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 188 of file Block.cpp.

References lldb_private::RangeArray< B, S, N >::FindEntryThatContains(), and m_ranges.

◆ Contains() [3/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 174 of file Block.cpp.

References GetParent().

◆ 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 59 of file Block.cpp.

References lldb_private::Stream::AddressRange(), Contains(), Dump(), lldb_private::Stream::EOL(), lldb_private::RangeArray< B, S, N >::GetEntryRef(), lldb_private::UserID::GetID(), GetParent(), lldb_private::RangeArray< B, S, N >::GetSize(), lldb_private::Stream::Indent(), lldb_private::Stream::IndentLess(), lldb_private::Stream::IndentMore(), lldb_private::RangeArray< B, S, N >::IsEmpty(), m_children, m_inlineInfoSP, m_ranges, m_variable_list_sp, and lldb_private::Stream::Printf().

Referenced by Dump(), and lldb_private::Function::Dump().

◆ DumpAddressRanges()

void Block::DumpAddressRanges ( Stream s,
lldb::addr_t  base_addr 
)

◆ 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 152 of file Block.cpp.

References CalculateSymbolContextFunction(), lldb_private::UserID::GetID(), and lldb_private::Stream::Printf().

◆ FinalizeRanges()

void Block::FinalizeRanges ( )

◆ FindBlockByID()

Block * Block::FindBlockByID ( lldb::user_id_t  block_id)

◆ GetBlockVariableList()

VariableListSP Block::GetBlockVariableList ( bool  can_create)

Get the variable list for this block only.

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.
Returns
A variable list shared pointer that contains all variables for this block.

Definition at line 387 of file Block.cpp.

References CalculateSymbolContext(), m_parsed_block_variables, m_variable_list_sp, and lldb_private::SymbolContext::module_sp.

Referenced by AppendBlockVariables(), AppendVariables(), lldb_private::FormatEntity::Format(), lldb::SBFunction::GetArgumentName(), GetFirstChild(), lldb::SBBlock::GetVariables(), SymbolFilePDB::ParseDeclsForContext(), lldb_private::npdb::SymbolFileNativePDB::ParseTypes(), SymbolFileDWARF::ParseVariables(), and lldb_private::ClangUserExpression::~ClangUserExpression().

◆ GetContainingInlinedBlock()

Block * Block::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 215 of file Block.cpp.

References GetContainingInlinedBlock().

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

◆ GetDeclContext()

CompilerDeclContext Block::GetDeclContext ( )

◆ GetDescription()

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

◆ 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 216 of file Block.h.

References AppendBlockVariables(), AppendVariables(), GetBlockVariableList(), and m_children.

Referenced by lldb::SBBlock::GetFirstChild().

◆ GetInlinedFunctionInfo()

const InlineFunctionInfo* lldb_private::Block::GetInlinedFunctionInfo ( ) const
inline

◆ GetInlinedParent()

Block * Block::GetInlinedParent ( )

Get the inlined parent block for this block.

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

Definition at line 204 of file Block.cpp.

References GetInlinedFunctionInfo(), GetInlinedParent(), and GetParent().

Referenced by GetContainingInlinedBlock(), GetInlinedParent(), and lldb_private::StackFrameList::ResetCurrentInlinedDepth().

◆ GetNumRanges()

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

◆ GetParent()

Block * Block::GetParent ( ) const

◆ GetRangeAtIndex()

bool Block::GetRangeAtIndex ( uint32_t  range_idx,
AddressRange range 
)

◆ GetRangeContainingAddress()

bool Block::GetRangeContainingAddress ( const Address addr,
AddressRange range 
)

◆ GetRangeContainingLoadAddress()

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

◆ GetRangeContainingOffset()

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

◆ GetRangeIndexContainingAddress()

uint32_t Block::GetRangeIndexContainingAddress ( const Address addr)

◆ 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 495 of file Block.cpp.

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

Referenced by lldb::SBBlock::GetSibling().

◆ GetSiblingForChild()

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

Definition at line 505 of file Block.cpp.

References m_children.

Referenced by GetSibling().

◆ GetStartAddress()

bool Block::GetStartAddress ( Address addr)

◆ 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 463 of file Block.cpp.

References CalculateSymbolContextModule().

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

◆ 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 364 of file Block.cpp.

References Block(), lldb_private::RangeArray< B, S, N >::GetSize(), m_inlineInfoSP, m_ranges, and m_variable_list_sp.

Referenced by GetInlinedFunctionInfo(), and lldb_private::Function::MemorySize().

◆ SetBlockInfoHasBeenParsed()

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

◆ SetDidParseVariables()

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

◆ 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 380 of file Block.cpp.

References m_inlineInfoSP.

Referenced by GetInlinedFunctionInfo(), and SymbolFileDWARF::ParseBlocksRecursive().

◆ SetParentScope()

void lldb_private::Block::SetParentScope ( SymbolContextScope parent_scope)
inline

Definition at line 340 of file Block.h.

References m_parent_scope.

Referenced by lldb_private::Function::Function().

◆ 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 351 of file Block.h.

References m_variable_list_sp.

Referenced by SymbolFilePDB::ParseDeclsForContext(), lldb_private::npdb::SymbolFileNativePDB::ParseTypes(), and SymbolFileDWARF::ParseVariables().

Member Data Documentation

◆ m_children

collection lldb_private::Block::m_children
protected

◆ m_inlineInfoSP

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

Inlined function information.

Definition at line 386 of file Block.h.

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

◆ m_parent_scope

SymbolContextScope* lldb_private::Block::m_parent_scope
protected

◆ 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 391 of file Block.h.

Referenced by BlockInfoHasBeenParsed(), and SetBlockInfoHasBeenParsed().

◆ m_parsed_block_variables

bool lldb_private::Block::m_parsed_block_variables
protected

Definition at line 391 of file Block.h.

Referenced by GetBlockVariableList(), and SetDidParseVariables().

◆ m_parsed_child_blocks

bool lldb_private::Block::m_parsed_child_blocks
protected

Definition at line 391 of file Block.h.

Referenced by SetBlockInfoHasBeenParsed().

◆ m_ranges

RangeList lldb_private::Block::m_ranges
protected

◆ 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 387 of file Block.h.

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


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