From ee779f4f30dec4b5d37eea238efcad582f7ec617 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 21 May 2010 21:13:10 +0000 Subject: 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) : New field. * dwarf2expr.c (add_piece): New arguments bit_piece, offset. Always use xrealloc to resize piece array. (execute_stack_op) : Handle DW_OP_bit_piece. : Update. : 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. --- gdb/dwarf2expr.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'gdb/dwarf2expr.c') 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 " -- cgit v1.2.1