/* Perform non-arithmetic operations on values, for GDB.
- Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006
+ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+ 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc.
This file is part of GDB.
/* Since modifying a register can trash the frame chain, and modifying memory
can trash the frame cache, we save the old frame and then restore the new
frame afterwards. */
- old_frame = get_frame_id (deprecated_selected_frame);
+ old_frame = get_frame_id (deprecated_safe_get_selected_frame ());
switch (VALUE_LVAL (toval))
{
if (!frame)
error (_("Value being assigned to is no longer active."));
- if (VALUE_LVAL (toval) == lval_register
- && CONVERT_REGISTER_P (VALUE_REGNUM (toval), type))
+ if (CONVERT_REGISTER_P (VALUE_REGNUM (toval), type))
{
/* If TOVAL is a special machine register requiring
conversion of program values to a special raw format. */
}
else
{
- /* TOVAL is stored in a series of registers in the frame
- specified by the structure. Copy that value out,
- modify it, and copy it back in. */
- int amount_copied;
- int amount_to_copy;
- gdb_byte *buffer;
- int reg_offset;
- int byte_offset;
- int regno;
-
- /* Locate the first register that falls in the value that
- needs to be transfered. Compute the offset of the
- value in that register. */
- {
- int offset;
- for (reg_offset = value_reg, offset = 0;
- offset + register_size (current_gdbarch, reg_offset) <= value_offset (toval);
- reg_offset++);
- byte_offset = value_offset (toval) - offset;
- }
-
- /* Compute the number of register aligned values that need
- to be copied. */
- if (value_bitsize (toval))
- amount_to_copy = byte_offset + 1;
- else
- amount_to_copy = byte_offset + TYPE_LENGTH (type);
-
- /* And a bounce buffer. Be slightly over generous. */
- buffer = alloca (amount_to_copy + MAX_REGISTER_SIZE);
-
- /* Copy it in. */
- for (regno = reg_offset, amount_copied = 0;
- amount_copied < amount_to_copy;
- amount_copied += register_size (current_gdbarch, regno), regno++)
- frame_register_read (frame, regno, buffer + amount_copied);
-
- /* Modify what needs to be modified. */
if (value_bitsize (toval))
- modify_field (buffer + byte_offset,
- value_as_long (fromval),
- value_bitpos (toval), value_bitsize (toval));
- else
- memcpy (buffer + byte_offset, value_contents (fromval),
- TYPE_LENGTH (type));
+ {
+ int changed_len;
+ gdb_byte buffer[sizeof (LONGEST)];
+
+ changed_len = (value_bitpos (toval)
+ + value_bitsize (toval)
+ + HOST_CHAR_BIT - 1)
+ / HOST_CHAR_BIT;
+
+ if (changed_len > (int) sizeof (LONGEST))
+ error (_("Can't handle bitfields which don't fit in a %d bit word."),
+ (int) sizeof (LONGEST) * HOST_CHAR_BIT);
- /* Copy it out. */
- for (regno = reg_offset, amount_copied = 0;
- amount_copied < amount_to_copy;
- amount_copied += register_size (current_gdbarch, regno), regno++)
- put_frame_register (frame, regno, buffer + amount_copied);
+ get_frame_register_bytes (frame, value_reg,
+ value_offset (toval),
+ changed_len, buffer);
+ modify_field (buffer, value_as_long (fromval),
+ value_bitpos (toval), value_bitsize (toval));
+
+ put_frame_register_bytes (frame, value_reg,
+ value_offset (toval),
+ changed_len, buffer);
+ }
+ else
+ {
+ put_frame_register_bytes (frame, value_reg,
+ value_offset (toval),
+ TYPE_LENGTH (type),
+ value_contents (fromval));
+ }
}
+
if (deprecated_register_changed_hook)
deprecated_register_changed_hook (-1);
observer_notify_target_changed (¤t_target);
BUILTIN_TYPE_LONGEST would seem to be a mistake. */
if (TYPE_CODE (base_type) == TYPE_CODE_INT)
return value_at_lazy (builtin_type_int,
- (CORE_ADDR) value_as_long (arg1));
+ (CORE_ADDR) value_as_address (arg1));
else if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
{
struct type *enc_type;
struct symbol *func, *sym;
struct block *b;
struct value * ret;
+ struct frame_info *frame;
- if (deprecated_selected_frame == 0)
+ if (complain)
+ frame = get_selected_frame (_("no frame selected"));
+ else
{
- if (complain)
- error (_("no frame selected"));
- else
+ frame = deprecated_safe_get_selected_frame ();
+ if (frame == 0)
return 0;
}
- func = get_frame_function (deprecated_selected_frame);
+ func = get_frame_function (frame);
if (!func)
{
if (complain)
return NULL;
}
- ret = read_var_value (sym, deprecated_selected_frame);
+ ret = read_var_value (sym, frame);
if (ret == 0 && complain)
error (_("`%s' argument unreadable"), name);
return ret;