This is the mail archive of the
gdb-testers@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Make dwarf_expr_context::stack an std::vector
- From: sergiodj+buildbot at sergiodj dot net
- To: gdb-testers at sourceware dot org
- Date: Thu, 14 Sep 2017 16:51:55 -0400
- Subject: [binutils-gdb] Make dwarf_expr_context::stack an std::vector
- Authentication-results: sourceware.org; auth=none
*** TEST RESULTS FOR COMMIT d185219da329805075ba5e0e72ec4c89c925cff2 ***
Author: Simon Marchi <simon.marchi@ericsson.com>
Branch: master
Commit: d185219da329805075ba5e0e72ec4c89c925cff2
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.