@@ -281,12 +281,7 @@ value_of_register_lazy (frame_info_ptr next_frame, int regnum)
/* We should have a valid next frame. */
gdb_assert (frame_id_p (get_frame_id (next_frame)));
- value *reg_val = value::allocate_lazy (register_type (gdbarch, regnum));
- reg_val->set_lval (lval_register);
- VALUE_REGNUM (reg_val) = regnum;
- VALUE_NEXT_FRAME_ID (reg_val) = get_frame_id (next_frame);
-
- return reg_val;
+ return value::allocate_register_lazy (next_frame, regnum);
}
/* Given a pointer of type TYPE in target form in BUF, return the
@@ -751,25 +746,20 @@ value *
default_value_from_register (gdbarch *gdbarch, type *type, int regnum,
frame_info_ptr this_frame)
{
- int len = type->length ();
- struct value *value = value::allocate (type);
- value->set_lval (lval_register);
-
frame_info_ptr next_frame = get_next_frame_sentinel_okay (this_frame);
while (get_frame_type (next_frame) == INLINE_FRAME)
next_frame = get_next_frame_sentinel_okay (next_frame);
- VALUE_NEXT_FRAME_ID (value) = get_frame_id (next_frame);
- VALUE_REGNUM (value) = regnum;
+ value *value = value::allocate_register (next_frame, regnum, 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 (type_byte_order (type) == BFD_ENDIAN_BIG
- && len < register_size (gdbarch, regnum))
+ && type->length () < register_size (gdbarch, regnum))
/* Big-endian, and we want less than full size. */
- value->set_offset (register_size (gdbarch, regnum) - len);
+ value->set_offset (register_size (gdbarch, regnum) - type->length ());
else
value->set_offset (0);
@@ -842,10 +832,8 @@ value_from_register (struct type *type, int regnum, frame_info_ptr frame)
the corresponding [integer] type (see Alpha). The assumption
is that gdbarch_register_to_value populates the entire value
including the location. */
- v = value::allocate (type);
- v->set_lval (lval_register);
- VALUE_NEXT_FRAME_ID (v) = get_frame_id (get_next_frame_sentinel_okay (frame));
- VALUE_REGNUM (v) = regnum;
+ v = value::allocate_register (get_next_frame_sentinel_okay (frame),
+ regnum, type);
ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1,
v->contents_raw ().data (), &optim,
&unavail);
@@ -2751,30 +2751,25 @@ static value *
rs6000_value_from_register (gdbarch *gdbarch, type *type, int regnum,
frame_info_ptr this_frame)
{
- int len = type->length ();
- struct value *value = value::allocate (type);
-
/* We have an IEEE 128-bit float -- need to change regnum mapping from
fpr to vsr. */
regnum = ieee_128_float_regnum_adjust (gdbarch, type, regnum);
- value->set_lval (lval_register);
-
frame_info_ptr next_frame = get_next_frame_sentinel_okay (this_frame);
while (get_frame_type (next_frame) == INLINE_FRAME)
next_frame = get_next_frame_sentinel_okay (next_frame);
- VALUE_NEXT_FRAME_ID (value) = get_frame_id (next_frame);
- VALUE_REGNUM (value) = regnum;
+ value *value
+ = value::allocate_register (next_frame, regnum, 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 (type_byte_order (type) == BFD_ENDIAN_BIG
- && len < register_size (gdbarch, regnum))
+ && type->length () < register_size (gdbarch, regnum))
/* Big-endian, and we want less than full size. */
- value->set_offset (register_size (gdbarch, regnum) - len);
+ value->set_offset (register_size (gdbarch, regnum) - type->length ());
else
value->set_offset (0);
@@ -961,11 +961,14 @@ value::allocate (struct type *type)
/* See value.h */
-struct value *
-value::allocate_register (frame_info_ptr next_frame, int regnum)
+value *
+value::allocate_register_lazy (frame_info_ptr next_frame, int regnum,
+ struct type *type)
{
- value *result
- = value::allocate (register_type (frame_unwind_arch (next_frame), regnum));
+ if (type == nullptr)
+ type = register_type (frame_unwind_arch (next_frame), regnum);
+
+ value *result = value::allocate_lazy (type);
result->set_lval (lval_register);
VALUE_REGNUM (result) = regnum;
@@ -974,6 +977,17 @@ value::allocate_register (frame_info_ptr next_frame, int regnum)
return result;
}
+/* See value.h */
+
+value *
+value::allocate_register (frame_info_ptr next_frame, int regnum,
+ struct type *type)
+{
+ value *result = value::allocate_register_lazy (next_frame, regnum, type);
+ result->set_lazy (false);
+ return result;
+}
+
/* Allocate a value that has the correct length
for COUNT repetitions of type TYPE. */
@@ -159,12 +159,17 @@ struct value
/* Allocate a value and its contents for type TYPE. */
static struct value *allocate (struct type *type);
- /* Allocate a non-lazy value representing register RENUM in the frame previous
- to NEXT_FRAME. The type of the value is found using `register_type`.
-
+ /* Allocate a lazy value representing register REGNUM in the frame previous
+ to NEXT_FRAME. If TYPE is non-nullptr, use it as the value type.
+ Otherwise, use `register_type` to obtain the type. */
+ static struct value *allocate_register_lazy (frame_info_ptr next_frame,
+ int regnum, type *type = nullptr);
+
+ /* Same as `allocate_register_lazy`, but make the value non-lazy.
+
The caller is responsible for filling the value's contents. */
static struct value *allocate_register (frame_info_ptr next_frame,
- int regnum);
+ int regnum, type *type = nullptr);
/* Create a computed lvalue, with type TYPE, function pointers
FUNCS, and closure CLOSURE. */