aboutsummaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2003-06-14 22:35:25 +0000
committerAndrew Cagney <cagney@redhat.com>2003-06-14 22:35:25 +0000
commitff2e87acc74e44ce5d35a80961469fc9fbd30b46 (patch)
tree893c1f1181bdc8166c7255374ecd714a23fe9414 /gdb/valops.c
parent81a58f5b702942e10bed032f8ab47ecad4cc43e0 (diff)
downloadgdb-ff2e87acc74e44ce5d35a80961469fc9fbd30b46.zip
gdb-ff2e87acc74e44ce5d35a80961469fc9fbd30b46.tar.gz
gdb-ff2e87acc74e44ce5d35a80961469fc9fbd30b46.tar.bz2
2003-06-14 Andrew Cagney <cagney@redhat.com>
Mark Kettenis <kettenis@gnu.org> * gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter. (REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer parameter with "frame". * gdbarch.h, gdbarch.c: Re-generate. * frame.h (put_frame_register): Declare. * frame.c (put_frame_register): New function. * arch-utils.c (legacy_convert_register_p): Add "type" parameter. (legacy_register_to_value): Rewrite, use "frame" to get the register value. (legacy_value_to_register): Rewrite, use "frame" to find the register's location before storing. * arch-utils.h (legacy_convert_register_p): Update. (legacy_register_to_value, legacy_value_to_register): Update. * findvar.c (value_from_register): Rewrite, eliminate use of REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass "frame" to REGISTER_TO_VALUE. * valops.c (value_assign): Move the CONVERT_REGISTER code to the lval_reg_frame_relative + lval_register branch of the switch. Do not use REGISTER_CONVERT_FROM_TYPE. Use put_frame_register. * i386-tdep.c (I386_EBX_REGNUM, I386_ECX_REGNUM, I386_ESI_REGNUM, I386_EDI_REGNUM): New defines. (i386_next_regnum, i386_convert_register_p, i386_register_to_value, i386_value_to_register): New functions. (i386_register_convertible, i386_register_convert_to_virtual, i386_convert_to_raw): Remove functions. (i386_gdbarch_init): Set convert_register_p, register_to_value and value_to_register instead of register_convertible, register_convert_to_virtual and register_convert_to_raw. * mips-tdep.c (mips_convert_register_p): New function. (mips_value_to_register): Replace mips_register_convert_from_type. (mips_register_to_value): Replace mips_register_convert_to_type. (mips_gdbarch_init): Set conver_register_p, value_to_register and register_to_value. * alpha-tdep.c (alpha_convert_register_p): Update. (alpha_value_to_register): Update, store the register. (alpha_register_to_value): Update, fetch the register.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c156
1 files changed, 58 insertions, 98 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index 2767630..9d02a35 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -498,22 +498,6 @@ value_assign (struct value *toval, struct value *fromval)
COERCE_ARRAY (fromval);
CHECK_TYPEDEF (type);
- /* If TOVAL is a special machine register requiring conversion
- of program values to a special raw format,
- convert FROMVAL's contents now, with result in `raw_buffer',
- and set USE_BUFFER to the number of bytes to write. */
-
- if (VALUE_REGNO (toval) >= 0)
- {
- int regno = VALUE_REGNO (toval);
- if (CONVERT_REGISTER_P (regno))
- {
- struct type *fromtype = check_typedef (VALUE_TYPE (fromval));
- VALUE_TO_REGISTER (fromtype, regno, VALUE_CONTENTS (fromval), raw_buffer);
- use_buffer = REGISTER_RAW_SIZE (regno);
- }
- }
-
/* 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. */
@@ -587,17 +571,8 @@ value_assign (struct value *toval, struct value *fromval)
case lval_reg_frame_relative:
case lval_register:
{
- /* value 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;
- char *buffer;
- int value_reg;
- int reg_offset;
- int byte_offset;
- int regno;
struct frame_info *frame;
+ int value_reg;
/* Figure out which frame this is in currently. */
if (VALUE_LVAL (toval) == lval_register)
@@ -613,92 +588,77 @@ value_assign (struct value *toval, struct value *fromval)
if (!frame)
error ("Value being assigned to is no longer active.");
-
- /* 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_RAW_SIZE (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 = (char *) 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_RAW_SIZE (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 if (use_buffer)
+ if (VALUE_LVAL (toval) == lval_reg_frame_relative
+ && CONVERT_REGISTER_P (VALUE_FRAME_REGNUM (toval), type))
{
- memcpy (buffer + VALUE_OFFSET (toval), raw_buffer, use_buffer);
+ /* If TOVAL is a special machine register requiring
+ conversion of program values to a special raw format. */
+ VALUE_TO_REGISTER (frame, VALUE_FRAME_REGNUM (toval),
+ type, VALUE_CONTENTS (fromval));
}
else
{
- memcpy (buffer + byte_offset, VALUE_CONTENTS (fromval),
- TYPE_LENGTH (type));
- /* Do any conversion necessary when storing this type to
- more than one register. */
-#ifdef REGISTER_CONVERT_FROM_TYPE
- REGISTER_CONVERT_FROM_TYPE (value_reg, type,
- (buffer + byte_offset));
-#endif
- }
+ /* 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;
+ char *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_RAW_SIZE (reg_offset) <= VALUE_OFFSET (toval);
+ reg_offset++);
+ byte_offset = VALUE_OFFSET (toval) - offset;
+ }
- /* Copy it out. */
- for (regno = reg_offset, amount_copied = 0;
- amount_copied < amount_to_copy;
- amount_copied += REGISTER_RAW_SIZE (regno), regno++)
- {
- enum lval_type lval;
- CORE_ADDR addr;
- int optim;
- int realnum;
+ /* 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);
- /* Just find out where to put it. */
- frame_register (frame, regno, &optim, &lval, &addr, &realnum,
- NULL);
+ /* And a bounce buffer. Be slightly over generous. */
+ buffer = (char *) 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_RAW_SIZE (regno), regno++)
+ frame_register_read (frame, regno, buffer + amount_copied);
- if (optim)
- error ("Attempt to assign to a value that was optimized out.");
- if (lval == lval_memory)
- write_memory (addr, buffer + amount_copied,
- REGISTER_RAW_SIZE (regno));
- else if (lval == lval_register)
- regcache_cooked_write (current_regcache, realnum,
- (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 if (use_buffer)
+ memcpy (buffer + VALUE_OFFSET (toval), raw_buffer, use_buffer);
else
- error ("Attempt to assign to an unmodifiable value.");
- }
+ memcpy (buffer + byte_offset, VALUE_CONTENTS (fromval),
+ TYPE_LENGTH (type));
+ /* Copy it out. */
+ for (regno = reg_offset, amount_copied = 0;
+ amount_copied < amount_to_copy;
+ amount_copied += REGISTER_RAW_SIZE (regno), regno++)
+ put_frame_register (frame, regno, buffer + amount_copied);
+
+ }
if (register_changed_hook)
register_changed_hook (-1);
target_changed_event ();
-
+ break;
}
- break;
-
default:
error ("Left operand of assignment is not an lvalue.");