LLDB mainline
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | 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]

Public Types

typedef RangeVector< 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.
 
 ~Block () override
 Destructor.
 
void AddChild (const lldb::BlockSP &child_block_sp)
 Add a child to this object.
 
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
 
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 SetParentScope (SymbolContextScope *parent_scope)
 
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)
 
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 void CalculateSymbolContext (SymbolContext *sc)=0
 Reconstruct the object's symbol context into sc.
 
virtual lldb::ModuleSP CalculateSymbolContextModule ()
 
virtual CompileUnitCalculateSymbolContextCompileUnit ()
 
virtual FunctionCalculateSymbolContextFunction ()
 
virtual BlockCalculateSymbolContextBlock ()
 
virtual SymbolCalculateSymbolContextSymbol ()
 
virtual void DumpSymbolContext (Stream *s)=0
 Dump the object's symbol context to the stream s.
 

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
 
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
 

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

◆ Range

Definition at line 44 of file Block.h.

◆ RangeList

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

Definition at line 43 of file Block.h.

Constructor & Destructor Documentation

◆ Block() [1/2]

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.
See also
BlockList

Definition at line 24 of file Block.cpp.

◆ ~Block()

Block::~Block ( )
overridedefault

Destructor.

◆ Block() [2/2]

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

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

References m_children.

Referenced by lldb_private::npdb::SymbolFileNativePDB::CreateBlock(), lldb_private::plugin::dwarf::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]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 413 of file Block.cpp.

References lldb_private::VariableList::AddVariable(), AppendBlockVariables(), 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 443 of file Block.cpp.

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

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

◆ BlockInfoHasBeenParsed()

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

Definition at line 335 of file Block.h.

References m_parsed_block_info.

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

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

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

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

◆ CalculateSymbolContextBlock()

Block * Block::CalculateSymbolContextBlock ( )
overridevirtual

Reimplemented from lldb_private::SymbolContextScope.

Definition at line 160 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 ( 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 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 lldb_private::RangeVector< B, S, N >::FindEntryThatContains(), and 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 lldb_private::RangeVector< B, S, N >::FindEntryThatContains(), and m_ranges.

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

◆ 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::AsRawOstream(), Contains(), Dump(), lldb_private::DumpAddressRange(), lldb_private::Stream::EOL(), lldb_private::RangeVector< B, S, N >::GetEntryRef(), lldb_private::UserID::GetID(), GetParent(), lldb_private::Range< B, S >::GetRangeBase(), lldb_private::Range< B, S >::GetRangeEnd(), lldb_private::RangeVector< B, S, N >::GetSize(), lldb_private::Stream::Indent(), lldb_private::Stream::IndentLess(), lldb_private::Stream::IndentMore(), lldb_private::RangeVector< B, S, N >::IsEmpty(), m_children, m_inlineInfoSP, m_ranges, m_variable_list_sp, and lldb_private::Stream::Printf().

Referenced by lldb_private::Function::Dump(), and 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 162 of file Block.cpp.

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

◆ FinalizeRanges()

void Block::FinalizeRanges ( )

◆ FindBlockByID()

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

◆ FindInnermostBlockByOffset()

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

Definition at line 126 of file Block.cpp.

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

Referenced by FindInnermostBlockByOffset().

◆ GetBlockVariableList()

VariableListSP Block::GetBlockVariableList ( bool  can_create)

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

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

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

References 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 214 of file Block.cpp.

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

Referenced by GetContainingInlinedBlock(), GetContainingInlinedBlockWithCallSite(), 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 505 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 515 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 474 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 376 of file Block.cpp.

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

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

◆ operator=()

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

◆ SetBlockInfoHasBeenParsed()

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

Definition at line 486 of file Block.cpp.

References m_children, m_parsed_block_info, and m_parsed_child_blocks.

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

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

References m_inlineInfoSP.

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

◆ SetParentScope()

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

Definition at line 320 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 331 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

collection lldb_private::Block::m_children
protected

◆ m_inlineInfoSP

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

Inlined function information.

Definition at line 368 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 372 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 374 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 374 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 369 of file Block.h.

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


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