Make dwarf_expr_context::stack an std::vector
authorSimon Marchi <simon.marchi@ericsson.com>
Thu, 14 Sep 2017 20:36:57 +0000 (22:36 +0200)
committerSimon Marchi <simon.marchi@ericsson.com>
Thu, 14 Sep 2017 20:36:57 +0000 (22:36 +0200)
commitd185219da329805075ba5e0e72ec4c89c925cff2
treee0c67acb37781d15ef668c142141cfc3603363c8
parent79254a5260cf49887b4017700bd75b27f483b322
Make dwarf_expr_context::stack an std::vector

Replace the manually managed array with a vector.  It is mostly
straightforward, except maybe one thing in execute_stack_op, in the
handling of DW_OP_fbreg.  When the code stumbles on that opcode while
evaluating an expression, it needs to evaluate a subexpression to find
where the fb reg has been saved.  Rather than creating a new context, it
reuses the current context.  It saves the size of the stack before and
restores the stack to that size after.

I think we can do a little bit better by saving the current stack
locally and installing a new empty stack.  This way, if the
subexpression is malformed and underflows, we'll get an exception.
Before, it would have overwritten the top elements of the top-level
expression.  The evaluation of the top-level expression would have then
resumed with the same stack size, but possibly some corrupted elements.

gdb/ChangeLog:

* dwarf2expr.h (dwarf_stack_value): Add constructor.
(dwarf_expr_context) <~dwarf_expr_context>: Define as default.
<stack>: Change type to std::vector.
<stack_len, stack_allocated>: Remove.
<grow_stack>: Remove.
* dwarf2expr.c (dwarf_expr_context::dwarf_expr_context): Adjust.
(dwarf_expr_context::~dwarf_expr_context): Remove.
(dwarf_expr_context::grow_stack): Remove.
(dwarf_expr_context::push): Adjust.
(dwarf_expr_context::pop): Adjust.
(dwarf_expr_context::fetch): Adjust.
(dwarf_expr_context::fetch_in_stack_memory): Adjust.
(dwarf_expr_context::stack_empty_p): Adjust.
(dwarf_expr_context::execute_stack_op): Adjust.
gdb/ChangeLog
gdb/dwarf2expr.c
gdb/dwarf2expr.h
This page took 0.029591 seconds and 4 git commands to generate.