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]

infrun.c:restore_selected_frame???


Hi, all...

I am totally confused by restore_selected_frame.  Why is it calling 
find_relative_frame, passing in the current frame and level?  Remember, 
level comes from a stored value of selected_frame_level.  
selected_frame_level is set in select_frame, and is either an absolute 
frame level, or -1 if the caller of select_frame was just selecting by 
frame_info and doesn't care about the level (which is done in a number 
of places).  So it is NOT a relative level at all, certainly not 
relative to whatever the current frame happens to be except by 
accident...

Since you also have the frame address sitting around in the 
restore_selected_frame_args, why not use it to find the frame instead?  
The patch below works for me, and eliminates a bunch of errant kvetching 
about "Unable to restore selected frame"...

Does this seem right?

Jim

Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.56
diff -c -w -r1.56 infrun.c
*** infrun.c    2002/03/18 02:26:31     1.56
--- infrun.c    2002/04/03 23:42:52
***************
*** 4004,4024 ****
     struct restore_selected_frame_args *fr =
     (struct restore_selected_frame_args *) args;
     struct frame_info *frame;
     int level = fr->level;

!   frame = find_relative_frame (get_current_frame (), &level);

     /* If inf_status->selected_frame_address is NULL, there was no
        previously selected frame.  */
!   if (frame == NULL ||
!   /*  FRAME_FP (frame) != fr->frame_address || */
!   /* elz: deleted this check as a quick fix to the problem that
!      for function called by hand gdb creates no internal frame
!      structure and the real stack and gdb's idea of stack are
!      different if nested calls by hands are made.
!
!      mvs: this worries me.  */
!       level != 0)
       {
         warning ("Unable to restore previously selected frame.\n");
         return 0;
--- 4004,4017 ----
     struct restore_selected_frame_args *fr =
     (struct restore_selected_frame_args *) args;
     struct frame_info *frame;
+   CORE_ADDR frame_address = fr->frame_address;
     int level = fr->level;

!   frame = find_frame_addr_in_frame_chain (frame_address);

     /* If inf_status->selected_frame_address is NULL, there was no
        previously selected frame.  */
!   if (frame == NULL)
       {
         warning ("Unable to restore previously selected frame.\n");
         return 0;

--
Jim Ingham                                   jingham@apple.com
Developer Tools - gdb
Apple Computer


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