diff options
author | Tom Tromey <tom@tromey.com> | 2019-03-23 10:11:51 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-03-23 10:59:10 -0600 |
commit | 7ad417dd217849c164e3c8a250c62a98eb0b8cd4 (patch) | |
tree | 7c5a868ea6aa91f34146092c15dd550986086218 /gdb/parse.c | |
parent | b366c208ee07924cc3cafc1bd4d70548bc91075b (diff) | |
download | gdb-7ad417dd217849c164e3c8a250c62a98eb0b8cd4.zip gdb-7ad417dd217849c164e3c8a250c62a98eb0b8cd4.tar.gz 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/parse.c')
-rw-r--r-- | gdb/parse.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/gdb/parse.c b/gdb/parse.c index 661574e..c76e0d5 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -116,10 +116,8 @@ static int prefixify_subexp (struct expression *, struct expression *, int, static expression_up parse_exp_in_context (const char **, CORE_ADDR, const struct block *, int, - int, int *); -static expression_up parse_exp_in_context_1 (const char **, CORE_ADDR, - const struct block *, int, - int, int *); + int, int *, + innermost_block_tracker_types); /* Documented at it's declaration. */ @@ -1095,18 +1093,10 @@ prefixify_subexp (struct expression *inexpr, expression_up parse_exp_1 (const char **stringptr, CORE_ADDR pc, const struct block *block, - int comma) + int comma, innermost_block_tracker_types tracker_types) { - return parse_exp_in_context (stringptr, pc, block, comma, 0, NULL); -} - -static expression_up -parse_exp_in_context (const char **stringptr, CORE_ADDR pc, - const struct block *block, - int comma, int void_context_p, int *out_subexp) -{ - return parse_exp_in_context_1 (stringptr, pc, block, comma, - void_context_p, out_subexp); + return parse_exp_in_context (stringptr, pc, block, comma, 0, NULL, + tracker_types); } /* As for parse_exp_1, except that if VOID_CONTEXT_P, then @@ -1117,9 +1107,10 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc, is left untouched. */ static expression_up -parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc, - const struct block *block, - int comma, int void_context_p, int *out_subexp) +parse_exp_in_context (const char **stringptr, CORE_ADDR pc, + const struct block *block, + int comma, int void_context_p, int *out_subexp, + innermost_block_tracker_types tracker_types) { const struct language_defn *lang = NULL; int subexp; @@ -1132,6 +1123,7 @@ parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc, expout_last_struct = -1; expout_tag_completion_type = TYPE_CODE_UNDEF; expout_completion_name.reset (); + innermost_block.reset (tracker_types); comma_terminates = comma; @@ -1286,7 +1278,8 @@ parse_expression_for_completion (const char *string, TRY { parse_completion = 1; - exp = parse_exp_in_context (&string, 0, 0, 0, 0, &subexp); + exp = parse_exp_in_context (&string, 0, 0, 0, 0, &subexp, + INNERMOST_BLOCK_FOR_SYMBOLS); } CATCH (except, RETURN_MASK_ERROR) { |