public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/7] Add two convenience methods to block
Date: Wed, 01 Nov 2023 11:09:33 -0600	[thread overview]
Message-ID: <20231101-dap-nested-function-v1-1-0b0c3b228ac7@adacore.com> (raw)
In-Reply-To: <20231101-dap-nested-function-v1-0-0b0c3b228ac7@adacore.com>

This adds a couple of convenience methods, block::is_static_block and
block::is_global_block.
---
 gdb/block.h   | 15 +++++++++++++++
 gdb/findvar.c |  5 ++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/gdb/block.h b/gdb/block.h
index 3a197e63754..9fccbe02b99 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 4e992ecdcc7..1079b85df82 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;

-- 
2.40.1


  reply	other threads:[~2023-11-01 17:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-01 17:09 [PATCH 0/7] Handle nested functions in DAP Tom Tromey
2023-11-01 17:09 ` Tom Tromey [this message]
2023-11-01 17:09 ` [PATCH 2/7] Add block::function_block Tom Tromey
2023-11-01 17:09 ` [PATCH 3/7] Move follow_static_link to frame.c Tom Tromey
2023-11-01 17:09 ` [PATCH 4/7] Add gdb.Frame.static_link method Tom Tromey
2023-11-01 17:17   ` Eli Zaretskii
2023-11-01 17:09 ` [PATCH 5/7] Fix a bug in DAP scopes code Tom Tromey
2023-11-01 17:09 ` [PATCH 6/7] Handle the static link in FrameDecorator Tom Tromey
2023-11-15 12:31   ` Tom de Vries
2023-11-15 13:58     ` Tom Tromey
2023-11-15 14:07       ` Tom de Vries
2023-11-15 14:58         ` Tom Tromey
2023-11-01 17:09 ` [PATCH 7/7] Update gdb.Symbol.is_variable documentation Tom Tromey
2023-11-01 17:15   ` Eli Zaretskii
2023-11-14 15:39 ` [PATCH 0/7] Handle nested functions in DAP Tom Tromey
2023-11-14 16:11   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231101-dap-nested-function-v1-1-0b0c3b228ac7@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).