/* DWARF 2 location expression support for GDB.
- Copyright (C) 2003, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
Contributed by Daniel Jacobowitz, MontaVista Software, Inc.
case DWARF_VALUE_REGISTER:
{
struct gdbarch *arch = get_frame_arch (frame);
- bfd_byte regval[MAX_REGISTER_SIZE];
int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch,
p->v.expr.value);
- get_frame_register (frame, gdb_regnum, regval);
- memcpy (contents + offset, regval, p->size);
+ int reg_offset = 0;
+
+ if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG
+ && p->size < register_size (arch, gdb_regnum))
+ /* Big-endian, and we want less than full size. */
+ reg_offset = register_size (arch, gdb_regnum) - p->size;
+
+ get_frame_register_bytes (frame, gdb_regnum, reg_offset, p->size,
+ contents + offset);
}
break;
case DWARF_VALUE_STACK:
{
- gdb_byte bytes[sizeof (ULONGEST)];
size_t n;
int addr_size = gdbarch_addr_bit (c->arch) / 8;
- store_unsigned_integer (bytes, addr_size,
- gdbarch_byte_order (c->arch),
- p->v.expr.value);
n = p->size;
if (n > addr_size)
n = addr_size;
- memcpy (contents + offset, bytes, n);
+ store_unsigned_integer (contents + offset, n,
+ gdbarch_byte_order (c->arch),
+ p->v.expr.value);
}
break;
{
struct gdbarch *arch = get_frame_arch (frame);
int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, p->v.expr.value);
- put_frame_register (frame, gdb_regnum, contents + offset);
+ int reg_offset = 0;
+
+ if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG
+ && p->size < register_size (arch, gdb_regnum))
+ /* Big-endian, and we want less than full size. */
+ reg_offset = register_size (arch, gdb_regnum) - p->size;
+
+ put_frame_register_bytes (frame, gdb_regnum, reg_offset, p->size,
+ contents + offset);
}
break;
case DWARF_VALUE_MEMORY:
case DWARF_VALUE_STACK:
{
- gdb_byte bytes[sizeof (ULONGEST)];
ULONGEST value = (ULONGEST) dwarf_expr_fetch (ctx, 0);
bfd_byte *contents;
size_t n = ctx->addr_size;
- store_unsigned_integer (bytes, ctx->addr_size,
- gdbarch_byte_order (ctx->gdbarch),
- value);
retval = allocate_value (SYMBOL_TYPE (var));
contents = value_contents_raw (retval);
if (n > TYPE_LENGTH (SYMBOL_TYPE (var)))
n = TYPE_LENGTH (SYMBOL_TYPE (var));
- memcpy (contents, bytes, n);
+ store_unsigned_integer (contents, n,
+ gdbarch_byte_order (ctx->gdbarch),
+ value);
}
break;