From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7082 invoked by alias); 7 Aug 2003 17:45:37 -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 7075 invoked from network); 7 Aug 2003 17:45:36 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.131) by sources.redhat.com with SMTP; 7 Aug 2003 17:45:36 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id CB1AA2B7F; Thu, 7 Aug 2003 13:45:28 -0400 (EDT) Message-ID: <3F329038.5040708@redhat.com> Date: Thu, 07 Aug 2003 17:45:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com Subject: Re: RFC: selected frame in read_var_value References: <20030801192951.GA2109@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-08/txt/msg00100.txt.bz2 > Thoughts on this? I observed one case where the selected frame hadn't been > initialized yet: when checking watchpoint values. Oops! The condition > matches the case in which get_current_frame () can be reasonably expected to > succeed. There are a couple other places that need this same check, mostly > functions which will work on globals as well as locals. I think the caller, and not this code, should be the one deciding if/when a get_selected_frame should be called. Otherwize the dependance on global state remains. > An alternative would be to create a lifeless_frame and have > get_current_frame return that when there is no running target; have it call > error if a register is read, its base is requested, et cetera. I suspect > that would require some serious surgery. We'd also need to pass > lifeless_frame everywhere we could be passing a NULL frame now. For > instance, several callers of read_var_value will give it no frame. Which exact case are you thinking of? A core file should have a frame. An exec file? A lifeless frame (throw an error if any register is unwound) should be straight forward. Andrew > --- gdb-5.3.20030801/gdb/findvar.c.orig 2003-08-01 14:46:12.000000000 -0400 > +++ gdb-5.3.20030801/gdb/findvar.c 2003-08-01 14:50:27.000000000 -0400 > @@ -388,7 +388,7 @@ symbol_read_needs_frame (struct symbol * > and a stack frame id, read the value of the variable > and return a (pointer to a) struct value containing the value. > If the variable cannot be found, return a zero pointer. > - If FRAME is NULL, use the deprecated_selected_frame. */ > + If FRAME is NULL, use the selected frame. */ > > struct value * > read_var_value (register struct symbol *var, struct frame_info *frame) > @@ -404,8 +404,9 @@ read_var_value (register struct symbol * > > len = TYPE_LENGTH (type); > > - if (frame == NULL) > - frame = deprecated_selected_frame; > + if (frame == NULL && target_has_registers && target_has_stack > + && target_has_memory) > + frame = get_selected_frame ();