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 02/11] Move innermost_block_tracker to expression.h
Date: Thu, 04 May 2023 08:21:23 -0600	[thread overview]
Message-ID: <20230504-frameless-v1-2-4191201740b0@adacore.com> (raw)
In-Reply-To: <20230504-frameless-v1-0-4191201740b0@adacore.com>

I think parser-defs.h should hold declarations that can be used by
parser implementations, whereas expression.h should hold declarations
that are used by code that wants to call a parser.  Following this
logic, this patch moves innermost_block_tracker to expression.h.
---
 gdb/expression.h  | 46 ++++++++++++++++++++++++++++++++++++++++++++--
 gdb/parser-defs.h | 43 -------------------------------------------
 2 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/gdb/expression.h b/gdb/expression.h
index e6e4bec2e80..8d351b30a3a 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -21,6 +21,7 @@
 #define EXPRESSION_H 1
 
 #include "gdbtypes.h"
+#include "symtab.h"
 
 /* While parsing expressions we need to track the innermost lexical block
    that we encounter.  In some situations we need to track the innermost
@@ -239,9 +240,51 @@ struct expression
 
 typedef std::unique_ptr<expression> expression_up;
 
+/* When parsing expressions we track the innermost block that was
+   referenced.  */
+
+class innermost_block_tracker
+{
+public:
+  innermost_block_tracker (innermost_block_tracker_types types
+			   = INNERMOST_BLOCK_FOR_SYMBOLS)
+    : m_types (types),
+      m_innermost_block (NULL)
+  { /* Nothing.  */ }
+
+  /* Update the stored innermost block if the new block B is more inner
+     than the currently stored block, or if no block is stored yet.  The
+     type T tells us whether the block B was for a symbol or for a
+     register.  The stored innermost block is only updated if the type T is
+     a type we are interested in, the types we are interested in are held
+     in M_TYPES and set during RESET.  */
+  void update (const struct block *b, innermost_block_tracker_types t);
+
+  /* Overload of main UPDATE method which extracts the block from BS.  */
+  void update (const struct block_symbol &bs)
+  {
+    update (bs.block, INNERMOST_BLOCK_FOR_SYMBOLS);
+  }
+
+  /* Return the stored innermost block.  Can be nullptr if no symbols or
+     registers were found during an expression parse, and so no innermost
+     block was defined.  */
+  const struct block *block () const
+  {
+    return m_innermost_block;
+  }
+
+private:
+  /* The type of innermost block being looked for.  */
+  innermost_block_tracker_types m_types;
+
+  /* The currently stored innermost block found while parsing an
+     expression.  */
+  const struct block *m_innermost_block;
+};
+
 /* From parse.c */
 
-class innermost_block_tracker;
 extern expression_up parse_expression (const char *,
 				       innermost_block_tracker * = nullptr,
 				       bool void_context_p = false);
@@ -270,7 +313,6 @@ struct expr_completion_base
 extern expression_up parse_expression_for_completion
      (const char *, std::unique_ptr<expr_completion_base> *completer);
 
-class innermost_block_tracker;
 extern expression_up parse_exp_1 (const char **, CORE_ADDR pc,
 				  const struct block *, int,
 				  innermost_block_tracker * = nullptr);
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 62829a86f9a..5c6bc222b6b 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -316,49 +316,6 @@ struct parser_state : public expr_builder
   std::vector<expr::operation_up> m_operations;
 };
 
-/* When parsing expressions we track the innermost block that was
-   referenced.  */
-
-class innermost_block_tracker
-{
-public:
-  innermost_block_tracker (innermost_block_tracker_types types
-			   = INNERMOST_BLOCK_FOR_SYMBOLS)
-    : m_types (types),
-      m_innermost_block (NULL)
-  { /* Nothing.  */ }
-
-  /* Update the stored innermost block if the new block B is more inner
-     than the currently stored block, or if no block is stored yet.  The
-     type T tells us whether the block B was for a symbol or for a
-     register.  The stored innermost block is only updated if the type T is
-     a type we are interested in, the types we are interested in are held
-     in M_TYPES and set during RESET.  */
-  void update (const struct block *b, innermost_block_tracker_types t);
-
-  /* Overload of main UPDATE method which extracts the block from BS.  */
-  void update (const struct block_symbol &bs)
-  {
-    update (bs.block, INNERMOST_BLOCK_FOR_SYMBOLS);
-  }
-
-  /* Return the stored innermost block.  Can be nullptr if no symbols or
-     registers were found during an expression parse, and so no innermost
-     block was defined.  */
-  const struct block *block () const
-  {
-    return m_innermost_block;
-  }
-
-private:
-  /* The type of innermost block being looked for.  */
-  innermost_block_tracker_types m_types;
-
-  /* The currently stored innermost block found while parsing an
-     expression.  */
-  const struct block *m_innermost_block;
-};
-
 /* A string token, either a char-string or bit-string.  Char-strings are
    used, for example, for the names of symbols.  */
 

-- 
2.39.1


  parent reply	other threads:[~2023-05-04 14:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-04 14:21 [PATCH 00/11] Fix frame-less expression evaluation in DAP Tom Tromey
2023-05-04 14:21 ` [PATCH 01/11] Avoid forward declaration in parse.c Tom Tromey
2023-05-04 14:21 ` Tom Tromey [this message]
2023-05-04 14:21 ` [PATCH 03/11] Introduce and use parser flags Tom Tromey
2023-05-04 14:21 ` [PATCH 04/11] Simplify parser_state constructor Tom Tromey
2023-05-04 14:21 ` [PATCH 05/11] Boolify parser_state::comma_terminates Tom Tromey
2023-05-04 14:21 ` [PATCH 06/11] Rearrange parser_state Tom Tromey
2023-05-04 14:21 ` [PATCH 07/11] Add PARSER_DEBUG flag Tom Tromey
2023-05-04 14:21 ` [PATCH 08/11] Add PARSER_LEAVE_BLOCK_ALONE flag Tom Tromey
2023-05-04 14:21 ` [PATCH 09/11] Add flags to parse_and_eval Tom Tromey
2023-05-04 14:21 ` [PATCH 10/11] Add global_context parameter to gdb.parse_and_eval Tom Tromey
2023-05-04 14:54   ` Eli Zaretskii
2023-05-23 20:17     ` Tom Tromey
2023-05-04 14:21 ` [PATCH 11/11] Handle DAP evaluate request without a frame ID Tom Tromey
2023-05-23 20:17 ` [PATCH 00/11] Fix frame-less expression evaluation in DAP 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=20230504-frameless-v1-2-4191201740b0@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).