Change funcall_chain to be a std::vector
This simplifies the handling of funcall_chain, by changing it to be a std::vector<int> and then fixing the users. This allows the removal of a cleanup. It would be even cleaner to replace this with better logic in the parsers; but a baby step seemed ok. gdb/ChangeLog 2017-09-05 Tom Tromey <tom@tromey.com> * parse.c (funcall_chain): Now a std::vector. (start_arglist, end_arglist): Simplify. (free_funcalls): Remove. (parse_exp_in_context_1): Remove cleanup.
This commit is contained in:
parent
fef704bfec
commit
69c1e056df
2 changed files with 14 additions and 39 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2017-09-05 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* parse.c (funcall_chain): Now a std::vector.
|
||||||
|
(start_arglist, end_arglist): Simplify.
|
||||||
|
(free_funcalls): Remove.
|
||||||
|
(parse_exp_in_context_1): Remove cleanup.
|
||||||
|
|
||||||
2017-09-05 Tom Tromey <tom@tromey.com>
|
2017-09-05 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* go-exp.y (go_parse): Don't create a cleanup.
|
* go-exp.y (go_parse): Don't create a cleanup.
|
||||||
|
|
46
gdb/parse.c
46
gdb/parse.c
|
@ -111,8 +111,6 @@ show_parserdebug (struct ui_file *file, int from_tty,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void free_funcalls (void *ignore);
|
|
||||||
|
|
||||||
static int prefixify_subexp (struct expression *, struct expression *, int,
|
static int prefixify_subexp (struct expression *, struct expression *, int,
|
||||||
int);
|
int);
|
||||||
|
|
||||||
|
@ -128,13 +126,7 @@ void _initialize_parse (void);
|
||||||
/* Data structure for saving values of arglist_len for function calls whose
|
/* Data structure for saving values of arglist_len for function calls whose
|
||||||
arguments contain other function calls. */
|
arguments contain other function calls. */
|
||||||
|
|
||||||
struct funcall
|
static std::vector<int> *funcall_chain;
|
||||||
{
|
|
||||||
struct funcall *next;
|
|
||||||
int arglist_len;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct funcall *funcall_chain;
|
|
||||||
|
|
||||||
/* Begin counting arguments for a function call,
|
/* Begin counting arguments for a function call,
|
||||||
saving the data about any containing call. */
|
saving the data about any containing call. */
|
||||||
|
@ -142,13 +134,8 @@ static struct funcall *funcall_chain;
|
||||||
void
|
void
|
||||||
start_arglist (void)
|
start_arglist (void)
|
||||||
{
|
{
|
||||||
struct funcall *newobj;
|
funcall_chain->push_back (arglist_len);
|
||||||
|
|
||||||
newobj = XNEW (struct funcall);
|
|
||||||
newobj->next = funcall_chain;
|
|
||||||
newobj->arglist_len = arglist_len;
|
|
||||||
arglist_len = 0;
|
arglist_len = 0;
|
||||||
funcall_chain = newobj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the number of arguments in a function call just terminated,
|
/* Return the number of arguments in a function call just terminated,
|
||||||
|
@ -158,28 +145,11 @@ int
|
||||||
end_arglist (void)
|
end_arglist (void)
|
||||||
{
|
{
|
||||||
int val = arglist_len;
|
int val = arglist_len;
|
||||||
struct funcall *call = funcall_chain;
|
arglist_len = funcall_chain->back ();
|
||||||
|
funcall_chain->pop_back ();
|
||||||
funcall_chain = call->next;
|
|
||||||
arglist_len = call->arglist_len;
|
|
||||||
xfree (call);
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free everything in the funcall chain.
|
|
||||||
Used when there is an error inside parsing. */
|
|
||||||
|
|
||||||
static void
|
|
||||||
free_funcalls (void *ignore)
|
|
||||||
{
|
|
||||||
struct funcall *call, *next;
|
|
||||||
|
|
||||||
for (call = funcall_chain; call; call = next)
|
|
||||||
{
|
|
||||||
next = call->next;
|
|
||||||
xfree (call);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* See definition in parser-defs.h. */
|
/* See definition in parser-defs.h. */
|
||||||
|
@ -1160,7 +1130,6 @@ parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc,
|
||||||
const struct block *block,
|
const struct block *block,
|
||||||
int comma, int void_context_p, int *out_subexp)
|
int comma, int void_context_p, int *out_subexp)
|
||||||
{
|
{
|
||||||
struct cleanup *old_chain;
|
|
||||||
const struct language_defn *lang = NULL;
|
const struct language_defn *lang = NULL;
|
||||||
struct parser_state ps;
|
struct parser_state ps;
|
||||||
int subexp;
|
int subexp;
|
||||||
|
@ -1180,8 +1149,9 @@ parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc,
|
||||||
if (lexptr == 0 || *lexptr == 0)
|
if (lexptr == 0 || *lexptr == 0)
|
||||||
error_no_arg (_("expression to compute"));
|
error_no_arg (_("expression to compute"));
|
||||||
|
|
||||||
old_chain = make_cleanup (free_funcalls, 0 /*ignore*/);
|
std::vector<int> funcalls;
|
||||||
funcall_chain = 0;
|
scoped_restore save_funcall_chain = make_scoped_restore (&funcall_chain,
|
||||||
|
&funcalls);
|
||||||
|
|
||||||
expression_context_block = block;
|
expression_context_block = block;
|
||||||
|
|
||||||
|
@ -1275,8 +1245,6 @@ parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc,
|
||||||
if (expressiondebug)
|
if (expressiondebug)
|
||||||
dump_prefix_expression (ps.expout, gdb_stdlog);
|
dump_prefix_expression (ps.expout, gdb_stdlog);
|
||||||
|
|
||||||
discard_cleanups (old_chain);
|
|
||||||
|
|
||||||
*stringptr = lexptr;
|
*stringptr = lexptr;
|
||||||
return expression_up (ps.expout);
|
return expression_up (ps.expout);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue