/* Find a variable's value in memory, for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free
- Software Foundation, Inc.
+ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+ 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2007
+ Free Software Foundation, Inc.
This file is part of GDB.
return v;
}
+/* Install default attributes for register values. */
+
+struct value *
+default_value_from_register (struct type *type, int regnum,
+ struct frame_info *frame)
+{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ int len = TYPE_LENGTH (type);
+ struct value *value = allocate_value (type);
+
+ VALUE_LVAL (value) = lval_register;
+ VALUE_FRAME_ID (value) = get_frame_id (frame);
+ VALUE_REGNUM (value) = regnum;
+
+ /* Any structure stored in more than one register will always be
+ an integral number of registers. Otherwise, you need to do
+ some fiddling with the last register copied here for little
+ endian machines. */
+ if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
+ && len < register_size (gdbarch, regnum))
+ /* Big-endian, and we want less than full size. */
+ set_value_offset (value, register_size (gdbarch, regnum) - len);
+ else
+ set_value_offset (value, 0);
+
+ return value;
+}
+
/* Return a value of type TYPE, stored in register REGNUM, in frame FRAME. */
struct value *
value_from_register (struct type *type, int regnum, struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
- struct value *v = allocate_value (type);
- CHECK_TYPEDEF (type);
-
- VALUE_LVAL (v) = lval_register;
- VALUE_FRAME_ID (v) = get_frame_id (frame);
- VALUE_REGNUM (v) = regnum;
-
- if (CONVERT_REGISTER_P (regnum, type))
+ struct type *type1 = check_typedef (type);
+ struct value *v;
+
+ if (CONVERT_REGISTER_P (regnum, type1))
{
/* The ISA/ABI need to something weird when obtaining the
specified value from this register. It might need to
the corresponding [integer] type (see Alpha). The assumption
is that REGISTER_TO_VALUE populates the entire value
including the location. */
- REGISTER_TO_VALUE (frame, regnum, type, value_contents_raw (v));
+ v = allocate_value (type);
+ VALUE_LVAL (v) = lval_register;
+ VALUE_FRAME_ID (v) = get_frame_id (frame);
+ VALUE_REGNUM (v) = regnum;
+ REGISTER_TO_VALUE (frame, regnum, type1, value_contents_raw (v));
}
else
{
int len = TYPE_LENGTH (type);
- /* Any structure stored in more than one register will always be
- an integral number of registers. Otherwise, you need to do
- some fiddling with the last register copied here for little
- endian machines. */
- if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
- && len < register_size (gdbarch, regnum))
- /* Big-endian, and we want less than full size. */
- set_value_offset (v, register_size (gdbarch, regnum) - len);
- else
- set_value_offset (v, 0);
+ /* Construct the value. */
+ v = gdbarch_value_from_register (gdbarch, type, regnum, frame);
/* Get the data. */
if (!get_frame_register_bytes (frame, regnum, value_offset (v), len,