From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111875 invoked by alias); 24 Jul 2015 09:26:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 111859 invoked by uid 89); 24 Jul 2015 09:26:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 24 Jul 2015 09:26:31 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 3065D28B3857; Fri, 24 Jul 2015 11:26:28 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 80XYrid7y69I; Fri, 24 Jul 2015 11:26:28 +0200 (CEST) Received: from [10.10.1.112] (cacatoes.act-europe.fr [10.10.1.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id C7C0928B3839; Fri, 24 Jul 2015 11:26:27 +0200 (CEST) Subject: Re: [PATCH] Add proper handling for non-local references in nested functions To: Kevin Buettner , gdb-patches@sourceware.org References: <54F47563.4050103@adacore.com> <54FF0D05.70907@redhat.com> <550C1170.9070208@adacore.com> <55685B60.3000004@redhat.com> <55775EB0.4080701@adacore.com> <55AF5F7E.5000600@adacore.com> <20150722173957.7ed51f18@pinnacle.lan> <55B0C583.6050601@adacore.com> <20150723064408.4dd8a9b2@pinnacle.lan> <55B112D4.5010304@adacore.com> <20150723110653.3f4e2f11@pinnacle.lan> From: Pierre-Marie de Rodat Message-ID: <55B204C3.80100@adacore.com> Date: Fri, 24 Jul 2015 09:26:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <20150723110653.3f4e2f11@pinnacle.lan> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00683.txt.bz2 On 07/23/2015 08:06 PM, Kevin Buettner wrote: > Your patch did indeed fix my problem. > > Given this test case (which I cobbled together while looking at another > matter)... > [...] > Breakpoint 1, p () at nested.c:11 > 11 __builtin_printf ("%d %d %d %d\n", b, c, e, f); > (gdb) p a > $1 = 1 > (gdb) p b > $2 = 2 > (gdb) p c > $3 = 7 > (gdb) p d > $4 = 32767 > (gdb) p e > $5 = 5 > (gdb) p f > $6 = 8 > > Note that the value of d is wrong. Out of curiosity, I had a quick look and I understood what is going on (without my most recent patch) in this example: a, b and c are static variables, so they aren't on the stack and thus GDB locates/prints them correctly. The e and f non-local variables are referenced from p and thus GCC materializes them as local references in the debug. info. for p, so GDB locates/prints the correctly. d is both located on the outer frame and not referenced from p, so the only description GDB has is the outer scope variable... which is incorrectly used to locate/print the variable as of today. > So, with your patch, the value of d is correct. > > I don't know why, but with your patch from yesterday, I was still > seeing the faulty behavior. (It is possible that I messed up with > my testing...) That's most likely because my previous patch was broken, as I said in the first mail I sent on Thursday. ;-) -- Pierre-Marie de Rodat