Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Nother little one, this time in varobj.c
@ 2002-04-09 17:36 Jim Ingham
  2002-04-09 23:44 ` Keith Seitz
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Ingham @ 2002-04-09 17:36 UTC (permalink / raw)
  To: gdb-patches

Here is another little buglet.  varobj_update stores the current frame, 
and then resets it
when it is done.  This is great, because the varobj may be in a 
different frame than the current one.  Unfortunately, the intervening 
code can call c_value_of_root, which calls reinit_frame_cache, which 
blows away the frame cache, leaving varobj_update holding a pointer to a 
freed frame_info structure.

The patch below fixes this goof.

BTW, I am not sure why it is necessary to call reinit_frame_cache here.  
Keith, do you remember why this was necessary?  It is inefficient, 
especially if you are evaluating a bunch of variables that are fairly 
high up on the stack.  But since I don't remember why this was done, I 
am reluctant to just change it outright...

Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.27
diff -c -w -r1.27 varobj.c
*** varobj.c    5 Apr 2002 22:04:42 -0000       1.27
--- varobj.c    10 Apr 2002 00:30:06 -0000
***************
*** 850,856 ****
     struct value *new;
     struct vstack *stack = NULL;
     struct vstack *result = NULL;
!   struct frame_info *old_fi;

     /* sanity check: have we been passed a pointer? */
     if (changelist == NULL)
--- 850,858 ----
     struct value *new;
     struct vstack *stack = NULL;
     struct vstack *result = NULL;
!   CORE_ADDR old_frame;
!   int old_level;
!

     /* sanity check: have we been passed a pointer? */
     if (changelist == NULL)
***************
*** 861,869 ****
       /* Not a root var */
       return -1;

!   /* Save the selected stack frame, since we will need to change it
!      in order to evaluate expressions. */
!   old_fi = selected_frame;

     /* Update the root variable. value_of_root can return NULL
        if the variable is no longer around, i.e. we stepped out of
--- 863,875 ----
       /* Not a root var */
       return -1;

!   /* Save the selected stack frame, since we will need to change it in
!      order to evaluate expressions.  However, you have to hold onto
!      the address not the struct frame, because value_of_root calls
!      reinit_frame_cache for its own mysterious purposes, leaving you
!      holding onto garbage... */
!
!   record_selected_frame (&old_frame, &old_level);

     /* Update the root variable. value_of_root can return NULL
        if the variable is no longer around, i.e. we stepped out of
***************
*** 983,989 ****
       }

     /* Restore selected frame */
!   select_frame (old_fi, -1);

     if (type_changed)
       return -2;
--- 989,999 ----
       }

     /* Restore selected frame */
!   if (old_frame != 0)
!     {
!       old_fi = find_frame_addr_in_frame_chain (old_frame);
!       select_frame (old_fi, old_level);
!     }

     if (type_changed)
       return -2;

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-04-10 18:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-09 17:36 Nother little one, this time in varobj.c Jim Ingham
2002-04-09 23:44 ` Keith Seitz
2002-04-10  6:27   ` Fernando Nasser
2002-04-10  7:33     ` Andrew Cagney
2002-04-10 11:07   ` Jim Ingham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox