aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-10-24 07:27:01 -0600
committerTom Tromey <tromey@adacore.com>2023-11-14 08:49:55 -0700
commit18a2a7470f7e944957c4c5b8ae7cf2fd6544ac8b (patch)
tree9d059fe3a14c7a3bc10052d57f45a747b58ce7f5
parent80159444640eb8f62c74bb3be95d369b2c9609a0 (diff)
downloadfsf-binutils-gdb-18a2a7470f7e944957c4c5b8ae7cf2fd6544ac8b.zip
fsf-binutils-gdb-18a2a7470f7e944957c4c5b8ae7cf2fd6544ac8b.tar.gz
fsf-binutils-gdb-18a2a7470f7e944957c4c5b8ae7cf2fd6544ac8b.tar.bz2
Add two convenience methods to block
This adds a couple of convenience methods, block::is_static_block and block::is_global_block. (cherry picked from commit edf1b9640bbc981c8a094d6ca29d444b1ed50a2c)
-rw-r--r--gdb/block.h15
-rw-r--r--gdb/findvar.c5
2 files changed, 17 insertions, 3 deletions
diff --git a/gdb/block.h b/gdb/block.h
index 3a197e6..9fccbe0 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -254,10 +254,25 @@ struct block : public allocate_on_obstack
const struct block *static_block () const;
+ /* Return true if this block is a static block. */
+
+ bool is_static_block () const
+ {
+ const block *sup = superblock ();
+ if (sup == nullptr)
+ return false;
+ return sup->is_global_block ();
+ }
+
/* Return the static block associated with block. */
const struct block *global_block () const;
+ /* Return true if this block is a global block. */
+
+ bool is_global_block () const
+ { return superblock () == nullptr; }
+
/* Set the compunit of this block, which must be a global block. */
void set_compunit_symtab (struct compunit_symtab *);
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 4e992ec..1079b85 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -460,8 +460,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
tests that embed global/static symbols with null location lists.
We want to get <optimized out> instead of <frame required> when evaluating
them so return a frame instead of raising an error. */
- else if (var_block == var_block->global_block ()
- || var_block == var_block->static_block ())
+ else if (var_block->is_global_block () || var_block->is_static_block ())
return frame;
/* We have to handle the "my_func::my_local_var" notation. This requires us
@@ -486,7 +485,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block,
/* If we failed to find the proper frame, fallback to the heuristic
method below. */
- else if (frame_block == frame_block->global_block ())
+ else if (frame_block->is_global_block ())
{
frame = NULL;
break;