diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2017-09-14 22:36:57 +0200 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2017-09-14 22:36:57 +0200 |
commit | d185219da329805075ba5e0e72ec4c89c925cff2 (patch) | |
tree | e0c67acb37781d15ef668c142141cfc3603363c8 /gdb/unittests/array-view-selftests.c | |
parent | 79254a5260cf49887b4017700bd75b27f483b322 (diff) | |
download | binutils-d185219da329805075ba5e0e72ec4c89c925cff2.zip binutils-d185219da329805075ba5e0e72ec4c89c925cff2.tar.gz binutils-d185219da329805075ba5e0e72ec4c89c925cff2.tar.bz2 |
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.
Diffstat (limited to 'gdb/unittests/array-view-selftests.c')
0 files changed, 0 insertions, 0 deletions