aboutsummaryrefslogtreecommitdiff
path: root/gdb/expression.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-03-23 10:11:51 -0600
committerTom Tromey <tom@tromey.com>2019-03-23 10:59:10 -0600
commit7ad417dd217849c164e3c8a250c62a98eb0b8cd4 (patch)
tree7c5a868ea6aa91f34146092c15dd550986086218 /gdb/expression.h
parentb366c208ee07924cc3cafc1bd4d70548bc91075b (diff)
downloadfsf-binutils-gdb-7ad417dd217849c164e3c8a250c62a98eb0b8cd4.zip
fsf-binutils-gdb-7ad417dd217849c164e3c8a250c62a98eb0b8cd4.tar.gz
fsf-binutils-gdb-7ad417dd217849c164e3c8a250c62a98eb0b8cd4.tar.bz2
Have parser reset the innermost block tracker
I ran across a comment in symfile.c today: /* Clear globals which might have pointed into a removed objfile. FIXME: It's not clear which of these are supposed to persist between expressions and which ought to be reset each time. */ It seems to me that this can be clarified: the parser entry points ought to reset the innermost block tracker (and the expression context block), and these should not be considered valid for code to use at arbitrary times -- only immediately after an expression has been parsed. This patch implements this idea. This could be further improved by removing the parser globals and changing the parser functions to return this information, but I have not done this. Tested by the buildbot. gdb/ChangeLog 2019-03-23 Tom Tromey <tom@tromey.com> * varobj.c (varobj_create): Update. * symfile.c (clear_symtab_users): Don't reset innermost_block. * printcmd.c (display_command, do_one_display): Don't reset innermost_block. * parser-defs.h (enum innermost_block_tracker_type): Move to expression.h. (innermost_block): Update comment. * parse.c (parse_exp_1): Add tracker_types parameter. (parse_exp_in_context): Rename from parse_exp_in_context_1. Add tracker_types parameter. Reset innermost_block. (parse_exp_in_context): Remove. (parse_expression_for_completion): Update. * objfiles.c (~objfile): Don't reset expression_context_block or innermost_block. * expression.h (enum innermost_block_tracker_type): Move from parser-defs.h. (parse_exp_1): Add tracker_types parameter. * breakpoint.c (set_breakpoint_condition, watch_command_1): Don't reset innermost_block.
Diffstat (limited to 'gdb/expression.h')
-rw-r--r--gdb/expression.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/gdb/expression.h b/gdb/expression.h
index 9104ce6..36f18be 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -23,6 +23,23 @@
#include "symtab.h" /* Needed for "struct block" type. */
+/* While parsing expressions we need to track the innermost lexical block
+ that we encounter. In some situations we need to track the innermost
+ block just for symbols, and in other situations we want to track the
+ innermost block for symbols and registers. These flags are used by the
+ innermost block tracker to control which blocks we consider for the
+ innermost block. These flags can be combined together as needed. */
+
+enum innermost_block_tracker_type
+{
+ /* Track the innermost block for symbols within an expression. */
+ INNERMOST_BLOCK_FOR_SYMBOLS = (1 << 0),
+
+ /* Track the innermost block for registers within an expression. */
+ INNERMOST_BLOCK_FOR_REGISTERS = (1 << 1)
+};
+DEF_ENUM_FLAGS_TYPE (enum innermost_block_tracker_type,
+ innermost_block_tracker_types);
/* Definitions for saved C expressions. */
@@ -105,7 +122,9 @@ extern struct type *parse_expression_for_completion
(const char *, gdb::unique_xmalloc_ptr<char> *, enum type_code *);
extern expression_up parse_exp_1 (const char **, CORE_ADDR pc,
- const struct block *, int);
+ const struct block *, int,
+ innermost_block_tracker_types
+ = INNERMOST_BLOCK_FOR_SYMBOLS);
/* For use by parsers; set if we want to parse an expression and
attempt completion. */