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

@ -68,7 +68,7 @@ const struct exp_descriptor exp_descriptor_standard =
/* Global variables declared in parser-defs.h (and commented there). */
const struct block *expression_context_block;
CORE_ADDR expression_context_pc;
const struct block *innermost_block;
innermost_block_tracker innermost_block;
int arglist_len;
static struct type_stack type_stack;
const char *lexptr;
@ -121,6 +121,15 @@ static expression_up parse_exp_in_context_1 (const char **, CORE_ADDR,
const struct block *, int,
int, int *);
/* Documented at it's declaration. */
void
innermost_block_tracker::update (const struct block *b)
{
if (m_innermost_block == NULL || contained_in (b, m_innermost_block))
m_innermost_block = b;
}
/* Data structure for saving values of arglist_len for function calls whose
arguments contain other function calls. */