This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Nother little one, this time in varobj.c
- From: Jim Ingham <jingham at apple dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 9 Apr 2002 17:36:18 -0700
- Subject: Nother little one, this time in varobj.c
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