This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
RFC: Flush frame cache in value_assign
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 14 Jan 2003 13:21:01 -0500
- Subject: RFC: Flush frame cache in value_assign
This patch just moves the flush from the lval_register /
lval_reg_frame_relative case to somewhere where it can also be used for
lval_memory. Andrew, is this about what you had in mind? It fixes
store.exp and causes no regressions in any configuration I tested.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2003-01-14 Daniel Jacobowitz <drow@mvista.com>
* valops.c (value_assign): Flush frame cache after stores to memory
also.
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.86
diff -u -p -r1.86 valops.c
--- valops.c 4 Jan 2003 22:37:47 -0000 1.86
+++ valops.c 14 Jan 2003 18:17:55 -0000
@@ -515,6 +515,7 @@ value_assign (struct value *toval, struc
struct value *val;
char *raw_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
int use_buffer = 0;
+ struct frame_id old_frame;
if (!toval->modifiable)
error ("Left operand of assignment is not a modifiable lvalue.");
@@ -544,6 +545,11 @@ value_assign (struct value *toval, struc
}
}
+ /* 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);
+
switch (VALUE_LVAL (toval))
{
case lval_internalvar:
@@ -612,7 +618,6 @@ value_assign (struct value *toval, struc
case lval_reg_frame_relative:
case lval_register:
{
- struct frame_id old_frame;
/* 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. */
@@ -625,11 +630,6 @@ value_assign (struct value *toval, struc
int regno;
struct frame_info *frame;
- /* Since modifying a register can trash the frame chain, we
- save the old frame and then restore the new frame
- afterwards. */
- old_frame = get_frame_id (deprecated_selected_frame);
-
/* Figure out which frame this is in currently. */
if (VALUE_LVAL (toval) == lval_register)
{
@@ -731,26 +731,6 @@ value_assign (struct value *toval, struc
register_changed_hook (-1);
target_changed_event ();
- /* Assigning to the stack pointer, frame pointer, and other
- (architecture and calling convention specific) registers
- may cause the frame cache to be out of date. We just do
- this on all assignments to registers for simplicity; I
- doubt the slowdown matters. */
- reinit_frame_cache ();
-
- /* Having destoroyed the frame cache, restore the selected
- frame. */
- /* FIXME: cagney/2002-11-02: There has to be a better way of
- doing this. Instead of constantly saving/restoring the
- frame. Why not create a get_selected_frame() function
- that, having saved the selected frame's ID can
- automatically re-find the previously selected frame
- automatically. */
- {
- struct frame_info *fi = frame_find_by_id (old_frame);
- if (fi != NULL)
- select_frame (fi);
- }
}
break;
@@ -759,6 +739,38 @@ value_assign (struct value *toval, struc
error ("Left operand of assignment is not an lvalue.");
}
+ /* Assigning to the stack pointer, frame pointer, and other
+ (architecture and calling convention specific) registers may
+ cause the frame cache to be out of date. Assigning to memory
+ also can. We just do this on all assignments to registers or
+ memory, for simplicity's sake; I doubt the slowdown matters. */
+ switch (VALUE_LVAL (toval))
+ {
+ case lval_memory:
+ case lval_register:
+ case lval_reg_frame_relative:
+
+ reinit_frame_cache ();
+
+ /* Having destoroyed the frame cache, restore the selected frame. */
+
+ /* FIXME: cagney/2002-11-02: There has to be a better way of
+ doing this. Instead of constantly saving/restoring the
+ frame. Why not create a get_selected_frame() function that,
+ having saved the selected frame's ID can automatically
+ re-find the previously selected frame automatically. */
+
+ {
+ struct frame_info *fi = frame_find_by_id (old_frame);
+ if (fi != NULL)
+ select_frame (fi);
+ }
+
+ break;
+ default:
+ break;
+ }
+
/* If the field does not entirely fill a LONGEST, then zero the sign bits.
If the field is signed, and is negative, then sign extend. */
if ((VALUE_BITSIZE (toval) > 0)