This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc] Don't thwack frame->pc in infun.c (DECR_PC_AFTER_BREAK)


Hello,

The file "infrun.c" currently contains the `cute' trick:

/* Make sure that the current_frame's pc is correct. This
is a correction for setting up the frame info before doing
DECR_PC_AFTER_BREAK */
- if (target_has_execution && get_current_frame ())
- (get_current_frame ())->pc = read_pc ();

Come the revolution, and when all DECR_PC_AFTER_BREAK has been slain, this hack will just go away.

In the mean time, I'm trying to figure out a cleaner way of doing it ...

First thing to note is that the get_current_frame() [!= NULL] part of the `if' conditional is redundant. If there isn't a current frame, get_current_frame() will throw an error. Consequently the test can be dropped (with the side effect of forcing a frame create).

Second thing to note is that by changing the frame's PC the code has invalidated anything cached in that frame. Consequently, the code should flush the cache, rather than just tweak the PC. An unnecessary flush can be avoided by checking to see if the PC changed.

The attached patch implements both of these changes. It only flushes the cache when the frame's PC has, some how, become invalid.

Unfortunatly, for the i386 (and alpha), this has consequences. It guarentees the sequence:

- create frame (parse prologue)
- flush frames
- create frame (parse prologue)

Where parse prologue involves target reads and, hence, is considered expensive. (I don't feel too guilty since the i386 has its [er, deprecated] codestream which should lessen the damange).

So anyway, the above needs to be changed. An alternative might be to:

if (target_has_execution)
deprecated_resync_current_frame_pc_hack (read_pc ());

thoughts?
Andrew
2002-12-06  Andrew Cagney  <ac131313@redhat.com>

	* infrun.c (normal_stop): If the PC and frame's PC are
	out-of-sync, re-initialize the frame cache.

Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.81
diff -u -r1.81 infrun.c
--- infrun.c	4 Dec 2002 00:05:53 -0000	1.81
+++ infrun.c	6 Dec 2002 17:58:34 -0000
@@ -3281,8 +3281,15 @@
   /* Make sure that the current_frame's pc is correct.  This
      is a correction for setting up the frame info before doing
      DECR_PC_AFTER_BREAK */
-  if (target_has_execution && get_current_frame ())
-    (get_current_frame ())->pc = read_pc ();
+  if (target_has_execution
+      && get_frame_pc (get_current_frame ()) != read_pc ())
+    /* NOTE: cagney/2002-12-06: Ok, things are really messed up.  This
+       architecture has DECR_PC_AFTER_BREAKed the program counter
+       causing the frame's PC to be out-of-sync.  Rebuild the frame
+       cache.  This probably causes a re-parse of the function's
+       prologue.  Sigh!  This doesn't use reinit_frame_cache() since,
+       slightly further down the selected frame is explicitly set.  */
+    flush_cached_frames ();
 
   if (target_has_execution && breakpoints_inserted)
     {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]