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.