From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16846 invoked by alias); 10 Apr 2002 00:36:21 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 16839 invoked from network); 10 Apr 2002 00:36:20 -0000 Received: from unknown (HELO mail-out2.apple.com) (17.254.0.51) by sources.redhat.com with SMTP; 10 Apr 2002 00:36:20 -0000 Received: from mailgate1.apple.com (A17-128-100-225.apple.com [17.128.100.225]) by mail-out2.apple.com (8.11.3/8.11.3) with ESMTP id g3A0aKs06439 for ; Tue, 9 Apr 2002 17:36:20 -0700 (PDT) Received: from scv1.apple.com (scv1.apple.com) by mailgate1.apple.com (Content Technologies SMTPRS 4.2.1) with ESMTP id for ; Tue, 9 Apr 2002 17:35:53 -0700 Received: from inghji (inghji.apple.com [17.202.40.220]) by scv1.apple.com (8.11.3/8.11.3) with ESMTP id g3A0aJs00552 for ; Tue, 9 Apr 2002 17:36:19 -0700 (PDT) Date: Tue, 09 Apr 2002 17:36:00 -0000 Mime-Version: 1.0 (Apple Message framework v481) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: Nother little one, this time in varobj.c From: Jim Ingham To: gdb-patches@sources.redhat.com Content-Transfer-Encoding: 7bit Message-Id: X-SW-Source: 2002-04/txt/msg00390.txt.bz2 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