This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit] Assume a frame when lval_register
- From: Andrew Cagney <cagney at gnu dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 15 Nov 2004 17:25:53 -0500
- Subject: [commit] Assume a frame when lval_register
The attached simplifies the code handling lval_register by exploiting
the assumption:
/* In a register. Registers are relative to a frame. */
lval_register,
i.e., there's always a frame. With just that committed, my PPC results
regress. It turns out that the value code was forgetting to propogate
the value id. A sequence like:
(gdb) up
(gdb) set variable u.i = 1
where "u" was in a register in frame #1 would end up trashing the
corresponding register in frame #0.
committed,
Andrew
2004-11-15 Andrew Cagney <cagney@gnu.org>
* findvar.c (value_of_register): Set the frame ID.
* value.c (value_primitive_field): Copy the frame ID.
* valops.c (value_assign): Simplify lval_register case, there's
always a frame.
Index: findvar.c
===================================================================
RCS file: /cvs/src/src/gdb/findvar.c,v
retrieving revision 1.81
diff -p -u -r1.81 findvar.c
--- findvar.c 13 Nov 2004 02:29:48 -0000 1.81
+++ findvar.c 15 Nov 2004 22:14:37 -0000
@@ -288,6 +288,7 @@ value_of_register (int regnum, struct fr
VALUE_ADDRESS (reg_val) = addr;
VALUE_REGNUM (reg_val) = regnum;
VALUE_OPTIMIZED_OUT (reg_val) = optim;
+ VALUE_FRAME_ID (reg_val) = get_frame_id (frame);
return reg_val;
}
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.137
diff -p -u -r1.137 valops.c
--- valops.c 13 Nov 2004 02:29:48 -0000 1.137
+++ valops.c 15 Nov 2004 22:14:38 -0000
@@ -602,16 +602,8 @@ value_assign (struct value *toval, struc
int value_reg;
/* Figure out which frame this is in currently. */
- if (VALUE_LVAL (toval) == lval_register)
- {
- frame = get_current_frame ();
- value_reg = VALUE_REGNUM (toval);
- }
- else
- {
- frame = frame_find_by_id (VALUE_FRAME_ID (toval));
- value_reg = VALUE_REGNUM (toval);
- }
+ frame = frame_find_by_id (VALUE_FRAME_ID (toval));
+ value_reg = VALUE_REGNUM (toval);
if (!frame)
error ("Value being assigned to is no longer active.");
Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.4
diff -p -u -r1.4 value.c
--- value.c 13 Nov 2004 00:53:09 -0000 1.4
+++ value.c 15 Nov 2004 22:14:38 -0000
@@ -964,6 +964,7 @@ value_primitive_field (struct value *arg
VALUE_LVAL (v) = lval_internalvar_component;
VALUE_ADDRESS (v) = VALUE_ADDRESS (arg1);
VALUE_REGNUM (v) = VALUE_REGNUM (arg1);
+ VALUE_FRAME_ID (v) = VALUE_FRAME_ID (arg1);
/* VALUE_OFFSET (v) = VALUE_OFFSET (arg1) + offset
+ TYPE_FIELD_BITPOS (arg_type, fieldno) / 8; */
return v;