aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2expr.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2017-09-14 15:57:01 +0200
committerSimon Marchi <simon.marchi@ericsson.com>2017-09-14 15:57:01 +0200
commit1e467161932b6385b51d0bd365a91cf205b399b9 (patch)
tree5863f70edf852de7f805628f810cc7d63ea77bf7 /gdb/dwarf2expr.c
parent4d465c689a8fb27212ef358d0aee89d60dee69a6 (diff)
downloadgdb-1e467161932b6385b51d0bd365a91cf205b399b9.zip
gdb-1e467161932b6385b51d0bd365a91cf205b399b9.tar.gz
gdb-1e467161932b6385b51d0bd365a91cf205b399b9.tar.bz2
Make dwarf_expr_piece::pieces an std::vector
Change the manually managed array dwarf_expr_piece::piece with an std::vector. After passing the pieces array to allocate_piece_closure, dwarf2_evaluate_loc_desc_full doesn't need that data anymore. We can therefore move the content of the vector to avoid copying it. Reg-tested on the buildbot. gdb/ChangeLog: * dwarf2expr.h (struct dwarf_expr_piece): Move up. (struct dwarf_expr_context) <n_pieces>: Remove. <pieces>: Change type to std::vector. * dwarf2expr.c (dwarf_expr_context::dwarf_expr_context): Adjust. (dwarf_expr_context::~dwarf_expr_context): Don't manually free pieces. (dwarf_expr_context::add_piece): Adjust. * dwarf2loc.c (struct piece_closure): Initialize fields. <n_pieces>: Remove. <pieces>: Change type to std::vector. (allocate_piece_closure): Adjust, change parameter to std::vector rvalue and std::move it to piece_closure. (rw_pieced_value): Adjust. (check_pieced_synthetic_pointer): Adjust. (indirect_synthetic_pointer): Adjust. (coerce_pieced_ref): Adjust. (free_pieced_value_closure): Adjust. Use delete to free piece_closure. (dwarf2_evaluate_loc_desc_full): Adjust. std::move ctx.pieces to allocate_piece_closure. (dwarf2_loc_desc_get_symbol_read_needs): Adjust.
Diffstat (limited to 'gdb/dwarf2expr.c')
-rw-r--r--gdb/dwarf2expr.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index e2724da..61a1e9e 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -100,9 +100,7 @@ dwarf_expr_context::dwarf_expr_context ()
location (DWARF_VALUE_MEMORY),
len (0),
data (NULL),
- initialized (0),
- num_pieces (0),
- pieces (NULL)
+ initialized (0)
{
this->stack = XNEWVEC (struct dwarf_stack_value, this->stack_allocated);
}
@@ -112,7 +110,6 @@ dwarf_expr_context::dwarf_expr_context ()
dwarf_expr_context::~dwarf_expr_context ()
{
xfree (this->stack);
- xfree (this->pieces);
}
/* Expand the memory allocated stack to contain at least
@@ -285,47 +282,42 @@ dwarf_expr_context::stack_empty_p () const
void
dwarf_expr_context::add_piece (ULONGEST size, ULONGEST offset)
{
- struct dwarf_expr_piece *p;
+ this->pieces.emplace_back ();
+ dwarf_expr_piece &p = this->pieces.back ();
- this->num_pieces++;
+ p.location = this->location;
+ p.size = size;
+ p.offset = offset;
- this->pieces
- = XRESIZEVEC (struct dwarf_expr_piece, this->pieces, this->num_pieces);
-
- p = &this->pieces[this->num_pieces - 1];
- p->location = this->location;
- p->size = size;
- p->offset = offset;
-
- if (p->location == DWARF_VALUE_LITERAL)
+ if (p.location == DWARF_VALUE_LITERAL)
{
- p->v.literal.data = this->data;
- p->v.literal.length = this->len;
+ p.v.literal.data = this->data;
+ p.v.literal.length = this->len;
}
else if (stack_empty_p ())
{
- p->location = DWARF_VALUE_OPTIMIZED_OUT;
+ p.location = DWARF_VALUE_OPTIMIZED_OUT;
/* Also reset the context's location, for our callers. This is
a somewhat strange approach, but this lets us avoid setting
the location to DWARF_VALUE_MEMORY in all the individual
cases in the evaluator. */
this->location = DWARF_VALUE_OPTIMIZED_OUT;
}
- else if (p->location == DWARF_VALUE_MEMORY)
+ else if (p.location == DWARF_VALUE_MEMORY)
{
- p->v.mem.addr = fetch_address (0);
- p->v.mem.in_stack_memory = fetch_in_stack_memory (0);
+ p.v.mem.addr = fetch_address (0);
+ p.v.mem.in_stack_memory = fetch_in_stack_memory (0);
}
- else if (p->location == DWARF_VALUE_IMPLICIT_POINTER)
+ else if (p.location == DWARF_VALUE_IMPLICIT_POINTER)
{
- p->v.ptr.die_sect_off = (sect_offset) this->len;
- p->v.ptr.offset = value_as_long (fetch (0));
+ p.v.ptr.die_sect_off = (sect_offset) this->len;
+ p.v.ptr.offset = value_as_long (fetch (0));
}
- else if (p->location == DWARF_VALUE_REGISTER)
- p->v.regno = value_as_long (fetch (0));
+ else if (p.location == DWARF_VALUE_REGISTER)
+ p.v.regno = value_as_long (fetch (0));
else
{
- p->v.value = fetch (0);
+ p.v.value = fetch (0);
}
}