From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6493 invoked by alias); 10 Mar 2004 22:21:41 -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 6442 invoked from network); 10 Mar 2004 22:21:27 -0000 Received: from unknown (HELO localhost.redhat.com) (216.129.200.20) by sources.redhat.com with SMTP; 10 Mar 2004 22:21:27 -0000 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id BEC1B2B92; Wed, 10 Mar 2004 12:09:10 -0500 (EST) Message-ID: <404F4BB6.4010207@gnu.org> Date: Wed, 10 Mar 2004 22:21:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com, Michael Elizabeth Chastain , vinschen@redhat.com Subject: Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope References: <20040309161507.9FBF54B104@berman.michael-chastain.com> <404E2B2C.8030201@gnu.org> <20040309212736.GA8404@nevyn.them.org> <404E45EC.4030205@gnu.org> <20040310005631.GA13440@nevyn.them.org> <404E7489.4010209@gnu.org> <20040310030528.GB16230@nevyn.them.org> <20040310032351.GA16933@nevyn.them.org> In-Reply-To: <20040310032351.GA16933@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-03.o/txt/msg00254.txt > On Tue, Mar 09, 2004 at 10:05:29PM -0500, Daniel Jacobowitz wrote: > >>> Think about this for a moment. I'm going to give addresses so that I >>> can be more precise. >>> >>> 0x10 : ret stuff(int) { } >>> 0x20
: push main() { >>> 0x21 : push { >>> 0x22 : move arg1, i stuff(i) >>> 0x23 : call stuff " >>> 0x24 : pop } >>> 0x25 : pop } >>> 0x26 : ret " >>> >>> The inner scope is probably to inclusive. It is "pc in [,]" -- only after executing the instuction at is the inner most scope destroyed. >>> >>> Suppose PC == 0x10. We backtrace. Look at main; saved PC is 0x24. We >>> want an address in the block. We subtract 1. OK, saved addr-in-block >>> is 0x23. 'i' is in scope. In your example there isn't a need to substract one -- the return address is still inside the correct block (it does no harm though). >>> Suppose PC == 0x24. Shouldn't this be the same? For the purposes of >>> looking at local variables, aren't we still in the the block? PC=24 (that ")" edge case) is also in the correct block. >>> Suppose PC was 0x24 and we got a signal. Ditto. >>> >>> Suppose PC == 0x20 and we get a signal. Obviously we don't want to >>> change the behavior of this. Now consider this example: >>> 10 0x10 : ret stuff(int) { } >>> 11 0x20
: push main() { >>> 12 0x21 : push { >>> 13 0x22 : move arg1, i stuff(i) >>> 14 0x23 : call stuff " >>> 15 } >>> 16 0x25 : pop 2; ret } Note how that closing brace @15 doesn't have code associated with it. Its possible to breakpoint @14 or @16 only. Consequently: - the return address will be @16 and is _out_ of scope hence "@16 - 1" is needed to find the correct block when doing a backtrace - once returned from stuff(), the pc is clearly @16 which, to the user, will visibly reflect the departure from the inner scope > BTW, my proposed replacement is woefully inaccurate, which I should > have realized before posting. I do not have a good solution to this > problem without actually turning back time :) I'm wondering what the 3.4 wierdness MichaelC's refering to is. Andrew From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6493 invoked by alias); 10 Mar 2004 22:21:41 -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 6442 invoked from network); 10 Mar 2004 22:21:27 -0000 Received: from unknown (HELO localhost.redhat.com) (216.129.200.20) by sources.redhat.com with SMTP; 10 Mar 2004 22:21:27 -0000 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id BEC1B2B92; Wed, 10 Mar 2004 12:09:10 -0500 (EST) Message-ID: <404F4BB6.4010207@gnu.org> Date: Fri, 19 Mar 2004 00:09:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com, Michael Elizabeth Chastain , vinschen@redhat.com Subject: Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope References: <20040309161507.9FBF54B104@berman.michael-chastain.com> <404E2B2C.8030201@gnu.org> <20040309212736.GA8404@nevyn.them.org> <404E45EC.4030205@gnu.org> <20040310005631.GA13440@nevyn.them.org> <404E7489.4010209@gnu.org> <20040310030528.GB16230@nevyn.them.org> <20040310032351.GA16933@nevyn.them.org> In-Reply-To: <20040310032351.GA16933@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-03/txt/msg00254.txt.bz2 Message-ID: <20040319000900.ZG5rkx3JpNlf1RrtVEANkfplbVPGt4k_Qzwd2l3CqXo@z> > On Tue, Mar 09, 2004 at 10:05:29PM -0500, Daniel Jacobowitz wrote: > >>> Think about this for a moment. I'm going to give addresses so that I >>> can be more precise. >>> >>> 0x10 : ret stuff(int) { } >>> 0x20
: push main() { >>> 0x21 : push { >>> 0x22 : move arg1, i stuff(i) >>> 0x23 : call stuff " >>> 0x24 : pop } >>> 0x25 : pop } >>> 0x26 : ret " >>> >>> The inner scope is probably to inclusive. It is "pc in [,]" -- only after executing the instuction at is the inner most scope destroyed. >>> >>> Suppose PC == 0x10. We backtrace. Look at main; saved PC is 0x24. We >>> want an address in the block. We subtract 1. OK, saved addr-in-block >>> is 0x23. 'i' is in scope. In your example there isn't a need to substract one -- the return address is still inside the correct block (it does no harm though). >>> Suppose PC == 0x24. Shouldn't this be the same? For the purposes of >>> looking at local variables, aren't we still in the the block? PC=24 (that ")" edge case) is also in the correct block. >>> Suppose PC was 0x24 and we got a signal. Ditto. >>> >>> Suppose PC == 0x20 and we get a signal. Obviously we don't want to >>> change the behavior of this. Now consider this example: >>> 10 0x10 : ret stuff(int) { } >>> 11 0x20
: push main() { >>> 12 0x21 : push { >>> 13 0x22 : move arg1, i stuff(i) >>> 14 0x23 : call stuff " >>> 15 } >>> 16 0x25 : pop 2; ret } Note how that closing brace @15 doesn't have code associated with it. Its possible to breakpoint @14 or @16 only. Consequently: - the return address will be @16 and is _out_ of scope hence "@16 - 1" is needed to find the correct block when doing a backtrace - once returned from stuff(), the pc is clearly @16 which, to the user, will visibly reflect the departure from the inner scope > BTW, my proposed replacement is woefully inaccurate, which I should > have realized before posting. I do not have a good solution to this > problem without actually turning back time :) I'm wondering what the 3.4 wierdness MichaelC's refering to is. Andrew