aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2expr.h
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.h
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.h')
-rw-r--r--gdb/dwarf2expr.h101
1 files changed, 49 insertions, 52 deletions
diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h
index 7df697d..39bcea3 100644
--- a/gdb/dwarf2expr.h
+++ b/gdb/dwarf2expr.h
@@ -49,6 +49,53 @@ enum dwarf_value_location
DWARF_VALUE_IMPLICIT_POINTER
};
+/* A piece of an object, as recorded by DW_OP_piece or DW_OP_bit_piece. */
+struct dwarf_expr_piece
+{
+ enum dwarf_value_location location;
+
+ union
+ {
+ struct
+ {
+ /* This piece's address, for DWARF_VALUE_MEMORY pieces. */
+ CORE_ADDR addr;
+ /* Non-zero if the piece is known to be in memory and on
+ the program's stack. */
+ int in_stack_memory;
+ } mem;
+
+ /* The piece's register number, for DWARF_VALUE_REGISTER pieces. */
+ int regno;
+
+ /* The piece's literal value, for DWARF_VALUE_STACK pieces. */
+ struct value *value;
+
+ struct
+ {
+ /* A pointer to the data making up this piece,
+ for DWARF_VALUE_LITERAL pieces. */
+ const gdb_byte *data;
+ /* The length of the available data. */
+ ULONGEST length;
+ } literal;
+
+ /* Used for DWARF_VALUE_IMPLICIT_POINTER. */
+ struct
+ {
+ /* The referent DIE from DW_OP_implicit_pointer. */
+ sect_offset die_sect_off;
+ /* The byte offset into the resulting data. */
+ LONGEST offset;
+ } ptr;
+ } v;
+
+ /* The length of the piece, in bits. */
+ ULONGEST size;
+ /* The piece offset, in bits. */
+ ULONGEST offset;
+};
+
/* The dwarf expression stack. */
struct dwarf_stack_value
@@ -114,8 +161,7 @@ struct dwarf_expr_context
initialized; zero otherwise. */
int initialized;
- /* An array of pieces. PIECES points to its first element;
- NUM_PIECES is its length.
+ /* A vector of pieces.
Each time DW_OP_piece is executed, we add a new element to the
end of this array, recording the current top of the stack, the
@@ -137,8 +183,7 @@ struct dwarf_expr_context
no DW_OP_piece operations have no value to place in a piece's
'size' field; the size comes from the surrounding data. So the
two cases need to be handled separately.) */
- int num_pieces;
- struct dwarf_expr_piece *pieces;
+ std::vector<dwarf_expr_piece> pieces;
/* Return the value of register number REGNUM (a DWARF register number),
read as an address. */
@@ -213,54 +258,6 @@ private:
void pop ();
};
-
-/* A piece of an object, as recorded by DW_OP_piece or DW_OP_bit_piece. */
-struct dwarf_expr_piece
-{
- enum dwarf_value_location location;
-
- union
- {
- struct
- {
- /* This piece's address, for DWARF_VALUE_MEMORY pieces. */
- CORE_ADDR addr;
- /* Non-zero if the piece is known to be in memory and on
- the program's stack. */
- int in_stack_memory;
- } mem;
-
- /* The piece's register number, for DWARF_VALUE_REGISTER pieces. */
- int regno;
-
- /* The piece's literal value, for DWARF_VALUE_STACK pieces. */
- struct value *value;
-
- struct
- {
- /* A pointer to the data making up this piece,
- for DWARF_VALUE_LITERAL pieces. */
- const gdb_byte *data;
- /* The length of the available data. */
- ULONGEST length;
- } literal;
-
- /* Used for DWARF_VALUE_IMPLICIT_POINTER. */
- struct
- {
- /* The referent DIE from DW_OP_implicit_pointer. */
- sect_offset die_sect_off;
- /* The byte offset into the resulting data. */
- LONGEST offset;
- } ptr;
- } v;
-
- /* The length of the piece, in bits. */
- ULONGEST size;
- /* The piece offset, in bits. */
- ULONGEST offset;
-};
-
void dwarf_expr_require_composition (const gdb_byte *, const gdb_byte *,
const char *);