{
unsigned int mask;
- gdb_assert (dest_offset_bits >= 0 && dest_offset_bits + nbits <= 8);
+ gdb_assert (dest_offset_bits + nbits <= 8);
mask = (1 << nbits) - 1;
if (bits_big_endian)
break;
case DWARF_VALUE_MEMORY:
- if (p->v.mem.in_stack_memory)
- read_stack (p->v.mem.addr + source_offset, buffer, this_size);
- else
- read_memory (p->v.mem.addr + source_offset, buffer, this_size);
+ read_value_memory (v, offset,
+ p->v.mem.in_stack_memory,
+ p->v.mem.addr + source_offset,
+ buffer, this_size);
break;
case DWARF_VALUE_STACK:
frame = get_selected_frame (_("No frame selected."));
byte_offset = value_as_address (value);
+ gdb_assert (piece);
baton = dwarf2_fetch_die_location_block (piece->v.ptr.die, c->per_cu,
get_frame_address_in_block_wrapper,
frame);
case DWARF_VALUE_LITERAL:
{
bfd_byte *contents;
- const bfd_byte *data;
+ const bfd_byte *ldata;
size_t n = ctx->len;
if (byte_offset + TYPE_LENGTH (type) > n)
retval = allocate_value (type);
contents = value_contents_raw (retval);
- data = ctx->data + byte_offset;
+ ldata = ctx->data + byte_offset;
n -= byte_offset;
if (n > TYPE_LENGTH (type))
n = TYPE_LENGTH (type);
- memcpy (contents, data, n);
+ memcpy (contents, ldata, n);
}
break;
static void
unimplemented (unsigned int op)
{
- error (_("DWARF operator %s cannot be translated to an agent expression"),
- dwarf_stack_op_name (op, 1));
+ const char *name = dwarf_stack_op_name (op);
+
+ if (name)
+ error (_("DWARF operator %s cannot be translated to an agent expression"),
+ name);
+ else
+ error (_("Unknown DWARF operator 0x%02x cannot be translated "
+ "to an agent expression"),
+ op);
}
/* A helper function to convert a DWARF register to an arch register.
example, if the expression cannot be compiled, or if the expression
is invalid. */
-static void
-compile_dwarf_to_ax (struct agent_expr *expr, struct axs_value *loc,
- struct gdbarch *arch, unsigned int addr_size,
- const gdb_byte *op_ptr, const gdb_byte *op_end,
- struct dwarf2_per_cu_data *per_cu)
+void
+dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
+ struct gdbarch *arch, unsigned int addr_size,
+ const gdb_byte *op_ptr, const gdb_byte *op_end,
+ struct dwarf2_per_cu_data *per_cu)
{
struct cleanup *cleanups;
int i, *offsets;
&datastart, &datalen);
op_ptr = read_sleb128 (op_ptr, op_end, &offset);
- compile_dwarf_to_ax (expr, loc, arch, addr_size, datastart,
- datastart + datalen, per_cu);
+ dwarf2_compile_expr_to_ax (expr, loc, arch, addr_size, datastart,
+ datastart + datalen, per_cu);
if (offset != 0)
{
case DW_OP_pick:
offset = *op_ptr++;
- unimplemented (op);
+ ax_pick (expr, offset);
break;
case DW_OP_swap:
break;
case DW_OP_over:
- /* We can't directly support DW_OP_over, but GCC emits it as
- part of a sequence to implement signed modulus. As a
- hack, we recognize this sequence. Note that if GCC ever
- generates a branch to the middle of this sequence, then
- we will die somehow. */
- if (op_end - op_ptr >= 4
- && op_ptr[0] == DW_OP_over
- && op_ptr[1] == DW_OP_div
- && op_ptr[2] == DW_OP_mul
- && op_ptr[3] == DW_OP_minus)
- {
- /* Sign extend the operands. */
- ax_ext (expr, addr_size_bits);
- ax_simple (expr, aop_swap);
- ax_ext (expr, addr_size_bits);
- ax_simple (expr, aop_swap);
- ax_simple (expr, aop_rem_signed);
- op_ptr += 4;
- }
- else
- unimplemented (op);
+ ax_pick (expr, 1);
break;
case DW_OP_rot:
- unimplemented (op);
+ ax_simple (expr, aop_rot);
break;
case DW_OP_deref:
ax_simple (expr, aop_ref64);
break;
default:
+ /* Note that dwarf_stack_op_name will never return
+ NULL here. */
error (_("Unsupported size %d in %s"),
- size, dwarf_stack_op_name (op, 1));
+ size, dwarf_stack_op_name (op));
}
}
break;
break;
case DW_OP_call_frame_cfa:
- unimplemented (op);
+ dwarf2_compile_cfa_to_ax (expr, loc, arch, expr->scope, per_cu);
+ loc->kind = axs_lvalue_memory;
break;
case DW_OP_GNU_push_tls_address:
/* DW_OP_call_ref is currently not supported. */
gdb_assert (block.per_cu == per_cu);
- compile_dwarf_to_ax (expr, loc, arch, addr_size,
- block.data, block.data + block.size,
- per_cu);
+ dwarf2_compile_expr_to_ax (expr, loc, arch, addr_size,
+ block.data, block.data + block.size,
+ per_cu);
}
break;
unimplemented (op);
default:
- error (_("Unhandled dwarf expression opcode 0x%x"), op);
+ unimplemented (op);
}
}
LONGEST l;
const char *name;
- name = dwarf_stack_op_name (op, 0);
+ name = dwarf_stack_op_name (op);
if (!name)
error (_("Unrecognized DWARF opcode 0x%02x at %ld"),
case DW_OP_breg29:
case DW_OP_breg30:
case DW_OP_breg31:
- data = read_sleb128 (data, end, &ul);
- fprintf_filtered (stream, " %s [$%s]", pulongest (ul),
+ data = read_sleb128 (data, end, &l);
+ fprintf_filtered (stream, " %s [$%s]", plongest (l),
gdbarch_register_name (arch, op - DW_OP_breg0));
break;
case DW_OP_bregx:
- {
- ULONGEST offset;
-
- data = read_uleb128 (data, end, &ul);
- data = read_sleb128 (data, end, &offset);
- fprintf_filtered (stream, " register %s [$%s] offset %s",
- pulongest (ul),
- gdbarch_register_name (arch, (int) ul),
- pulongest (offset));
- }
+ data = read_uleb128 (data, end, &ul);
+ data = read_sleb128 (data, end, &l);
+ fprintf_filtered (stream, " register %s [$%s] offset %s",
+ pulongest (ul),
+ gdbarch_register_name (arch, (int) ul),
+ plongest (l));
break;
case DW_OP_fbreg:
- data = read_sleb128 (data, end, &ul);
- fprintf_filtered (stream, " %s", pulongest (ul));
+ data = read_sleb128 (data, end, &l);
+ fprintf_filtered (stream, " %s", plongest (l));
break;
case DW_OP_xderef_size:
if (dlbaton->data == NULL || dlbaton->size == 0)
value->optimized_out = 1;
else
- compile_dwarf_to_ax (ax, value, gdbarch, addr_size,
- dlbaton->data, dlbaton->data + dlbaton->size,
- dlbaton->per_cu);
+ dwarf2_compile_expr_to_ax (ax, value, gdbarch, addr_size,
+ dlbaton->data, dlbaton->data + dlbaton->size,
+ dlbaton->per_cu);
}
/* The set of location functions used with the DWARF-2 expression
if (data == NULL || size == 0)
value->optimized_out = 1;
else
- compile_dwarf_to_ax (ax, value, gdbarch, addr_size, data, data + size,
- dlbaton->per_cu);
+ dwarf2_compile_expr_to_ax (ax, value, gdbarch, addr_size, data, data + size,
+ dlbaton->per_cu);
}
/* The set of location functions used with the DWARF-2 expression