summaryrefslogtreecommitdiff
path: root/gdb/dwarf2expr.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2010-05-21 21:13:10 +0000
committerTom Tromey <tromey@redhat.com>2010-05-21 21:13:10 +0000
commitee779f4f30dec4b5d37eea238efcad582f7ec617 (patch)
tree973720316c88e824b34abe3e877c7ecde96a22cd /gdb/dwarf2expr.c
parente5bc3cd416a16fa5ee24f4a7c7f91a58f22fa4ba (diff)
downloadgdb-ee779f4f30dec4b5d37eea238efcad582f7ec617.tar.gz
gdb
* dwarf2loc.c (extract_bits_primitive): New function. (extract_bits): Likewise. (insert_bits): Likewise. (copy_bitwise): Likewise. (read_pieced_value): Do all operations in bits. (write_pieced_value): Likewise. * dwarf2expr.h (struct dwarf_expr_piece) <offset>: New field. * dwarf2expr.c (add_piece): New arguments bit_piece, offset. Always use xrealloc to resize piece array. (execute_stack_op) <DW_OP_reg0>: Handle DW_OP_bit_piece. <DW_OP_piece>: Update. <DW_OP_bit_piece>: New case. gdb/testsuite * gdb.dwarf2/pieces.exp (pieces_test_f3): New proc. Call it. * gdb.dwarf2/pieces.S: Update. * gdb.dwarf2/pieces.c (struct B): Remove initial field.
Diffstat (limited to 'gdb/dwarf2expr.c')
-rw-r--r--gdb/dwarf2expr.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index bf5f7c9e3f9..723293bd747 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -153,23 +153,21 @@ dwarf_expr_stack_empty_p (struct dwarf_expr_context *ctx)
/* Add a new piece to CTX's piece list. */
static void
-add_piece (struct dwarf_expr_context *ctx, ULONGEST size)
+add_piece (struct dwarf_expr_context *ctx, ULONGEST size, ULONGEST offset)
{
struct dwarf_expr_piece *p;
ctx->num_pieces++;
- if (ctx->pieces)
- ctx->pieces = xrealloc (ctx->pieces,
- (ctx->num_pieces
- * sizeof (struct dwarf_expr_piece)));
- else
- ctx->pieces = xmalloc (ctx->num_pieces
- * sizeof (struct dwarf_expr_piece));
+ ctx->pieces = xrealloc (ctx->pieces,
+ (ctx->num_pieces
+ * sizeof (struct dwarf_expr_piece)));
p = &ctx->pieces[ctx->num_pieces - 1];
p->location = ctx->location;
p->size = size;
+ p->offset = offset;
+
if (p->location == DWARF_VALUE_LITERAL)
{
p->v.literal.data = ctx->data;
@@ -499,9 +497,11 @@ execute_stack_op (struct dwarf_expr_context *ctx,
case DW_OP_reg31:
if (op_ptr != op_end
&& *op_ptr != DW_OP_piece
+ && *op_ptr != DW_OP_bit_piece
&& *op_ptr != DW_OP_GNU_uninit)
error (_("DWARF-2 expression error: DW_OP_reg operations must be "
- "used either alone or in conjuction with DW_OP_piece."));
+ "used either alone or in conjuction with DW_OP_piece "
+ "or DW_OP_bit_piece."));
result = op - DW_OP_reg0;
ctx->location = DWARF_VALUE_REGISTER;
@@ -872,7 +872,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
/* Record the piece. */
op_ptr = read_uleb128 (op_ptr, op_end, &size);
- add_piece (ctx, size);
+ add_piece (ctx, 8 * size, 0);
/* Pop off the address/regnum, and reset the location
type. */
@@ -883,6 +883,24 @@ execute_stack_op (struct dwarf_expr_context *ctx,
}
goto no_push;
+ case DW_OP_bit_piece:
+ {
+ ULONGEST size, offset;
+
+ /* Record the piece. */
+ op_ptr = read_uleb128 (op_ptr, op_end, &size);
+ op_ptr = read_uleb128 (op_ptr, op_end, &offset);
+ add_piece (ctx, size, offset);
+
+ /* Pop off the address/regnum, and reset the location
+ type. */
+ if (ctx->location != DWARF_VALUE_LITERAL
+ && ctx->location != DWARF_VALUE_OPTIMIZED_OUT)
+ dwarf_expr_pop (ctx);
+ ctx->location = DWARF_VALUE_MEMORY;
+ }
+ goto no_push;
+
case DW_OP_GNU_uninit:
if (op_ptr != op_end)
error (_("DWARF-2 expression error: DW_OP_GNU_uninit must always "