Add block::function_block
This adds the method block::function_block, to easily access a block's enclosing function block.
This commit is contained in:
parent
edf1b9640b
commit
ba707cadae
2 changed files with 19 additions and 0 deletions
13
gdb/block.c
13
gdb/block.c
|
@ -378,6 +378,19 @@ block::global_block () const
|
|||
|
||||
/* See block.h. */
|
||||
|
||||
const struct block *
|
||||
block::function_block () const
|
||||
{
|
||||
const block *block = this;
|
||||
|
||||
while (block != nullptr && block->function () == nullptr)
|
||||
block = block->superblock ();
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
/* See block.h. */
|
||||
|
||||
void
|
||||
block::set_compunit_symtab (struct compunit_symtab *cu)
|
||||
{
|
||||
|
|
|
@ -273,6 +273,12 @@ struct block : public allocate_on_obstack
|
|||
bool is_global_block () const
|
||||
{ return superblock () == nullptr; }
|
||||
|
||||
/* Return the function block for this block. Returns nullptr if
|
||||
there is no enclosing function, i.e., if this block is a static
|
||||
or global block. */
|
||||
|
||||
const struct block *function_block () const;
|
||||
|
||||
/* Set the compunit of this block, which must be a global block. */
|
||||
|
||||
void set_compunit_symtab (struct compunit_symtab *);
|
||||
|
|
Loading…
Add table
Reference in a new issue