gdb: New API for tracking innermost block

This commit is preparation for a later change, at this point there
should be no user visible change.

We currently maintain a global innermost_block which tracks the most
inner block encountered when parsing an expression.

This commit wraps the innermost_block into a new class, and switches all
direct accesses to the variable to use the class API.

gdb/ChangeLog:

	* ada-exp.y (write_var_from_sym): Switch to innermost_block API.
	* ada-lang.c (resolve_subexp): Likewise.
	* breakpoint.c (set_breakpoint_condition) Likewise.
	(watch_command_1) Likewise.
	* c-exp.y (variable): Likewise.
	* d-exp.y (PrimaryExpression): Likewise.
	* f-exp.y (variable): Likewise.
	* go-exp.y (variable): Likewise.
	* m2-exp.y (variable): Likewise.
	* objfiles.c (objfile::~objfile): Likewise.
	* p-exp.y (variable): Likewise.
	* parse.c (innermost_block): Change type.
	* parser-defs.h (class innermost_block_tracker): New.
	(innermost_block): Change to innermost_block_tracker.
	* printcmd.c (display_command): Switch to innermost_block API.
	(do_one_display): Likewise.
	* rust-exp.y (do_one_display): Likewise.
	* symfile.c (clear_symtab_users): Likewise.
	* varobj.c (varobj_create): Switch to innermost_block API, replace
	use of innermost_block with block stored on varobj object.
This commit is contained in:
Andrew Burgess 2017-10-18 19:53:21 +01:00
parent 396af9a152
commit aee1fcdf97
17 changed files with 111 additions and 94 deletions

View file

@ -879,12 +879,12 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp,
{
struct watchpoint *w = (struct watchpoint *) b;
innermost_block = NULL;
innermost_block.reset ();
arg = exp;
w->cond_exp = parse_exp_1 (&arg, 0, 0, 0);
if (*arg)
error (_("Junk at end of expression"));
w->cond_exp_valid_block = innermost_block;
w->cond_exp_valid_block = innermost_block.block ();
}
else
{
@ -10717,7 +10717,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
/* Parse the rest of the arguments. From here on out, everything
is in terms of a newly allocated string instead of the original
ARG. */
innermost_block = NULL;
innermost_block.reset ();
std::string expression (arg, exp_end - arg);
exp_start = arg = expression.c_str ();
expression_up exp = parse_exp_1 (&arg, 0, 0, 0);
@ -10739,7 +10739,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
error (_("Cannot watch constant value `%.*s'."), len, exp_start);
}
exp_valid_block = innermost_block;
exp_valid_block = innermost_block.block ();
mark = value_mark ();
fetch_subexp_value (exp.get (), &pc, &val, &result, NULL, just_location);
@ -10777,13 +10777,13 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
toklen = end_tok - tok;
if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
{
innermost_block = NULL;
innermost_block.reset ();
tok = cond_start = end_tok + 1;
parse_exp_1 (&tok, 0, 0, 0);
/* The watchpoint expression may not be local, but the condition
may still be. E.g.: `watch global if local > 0'. */
cond_exp_valid_block = innermost_block;
cond_exp_valid_block = innermost_block.block ();
cond_end = tok;
}