From ba707cadae18a7cc8bb47a736d3d0438d44262a9 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 24 Oct 2023 07:53:29 -0600 Subject: Add block::function_block This adds the method block::function_block, to easily access a block's enclosing function block. --- gdb/block.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gdb/block.h') diff --git a/gdb/block.h b/gdb/block.h index 9fccbe0..a292985 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -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 *); -- cgit v1.1