From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 112487 invoked by alias); 15 Jan 2016 14:41:28 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 112477 invoked by uid 89); 15 Jan 2016 14:41:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=Hx-languages-length:2894, qux, ptype 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, 15 Jan 2016 14:41:26 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id C352F28FC6AC; Fri, 15 Jan 2016 15:41:22 +0100 (CET) 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 JVrq6ai_fv9N; Fri, 15 Jan 2016 15:41:22 +0100 (CET) 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 A602D28F9D4B; Fri, 15 Jan 2016 15:41:22 +0100 (CET) Subject: Re: [PATCH] DWARF: add abstract origin links on lexical blocks DIEs To: Richard Biener References: <5695323E.3030700@adacore.com> Cc: GCC Patches , Eric Botcazou From: Pierre-Marie de Rodat Message-ID: <56990512.7070808@adacore.com> Date: Fri, 15 Jan 2016 14:41:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------090107030104090602070109" X-IsSubscribed: yes X-SW-Source: 2016-01/txt/msg01078.txt.bz2 This is a multi-part message in MIME format. --------------090107030104090602070109 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 1950 On 01/13/2016 01:17 PM, Richard Biener wrote: > I wonder if you can construct a guality testcase that passes with and > fails without > the patch? I’ve tried to first look at how guality testcases are written (thanks for your answers on IRC, by the way :-)) and then how I could write a testcase for my fix. It seems there are two ways: match patterns in the assembly file or evaluate an expression in GDB. I already have the testcase I used during development: it’s written in Ada, to build with -O2. The way it checks the fix is to see if GDB manages to put a breakpoint on the Child2 symbol before executing the program (it cannot before my fix and it can afterwards). Oh, and it requires a fairly recent GDB version (7.10 looks good). I managed to get a similar GNU C99 reproducer (it’s attached): the debugging information has the pattern that exhibits the bugfix. Namely: while the “parent” function is inlined, the “child” function (which is in a block inside “parent”) is not. So GDB relies on the DW_TAG_abstract_origin in the inlined block to refer to the abstract block that contains the DIE that materializes “child“. However, it looks like there is no way in GDB to refer to C nested functions when they are not in the current scope: > $ gcc -g -O2 -std=gnu99 nested_fun.c nested_fun_helpers.c > $ gdb -n -q ./a.out > (gdb) ptype child > No symbol "child" in current context. > (gdb) ptype nested_fun.parent.child > No symbol "nested_fun" in current context. On the other hand, this works with the Ada testcase: > (gdb) ptype nested_fun.parent.child > type = (false, true) So I’m not sure what to do next: should I do a fragile testcase based on scanning the assembly file? (it could break with an optimizer change) create a guality testsuite for Ada? > Anyway, the patch looks ok to me but please give others a chance to chime in. Sure. Thank you for reviewing! -- Pierre-Marie de Rodat --------------090107030104090602070109 Content-Type: text/x-csrc; name="nested_fun.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="nested_fun.c" Content-length: 907 /* { dg-do run } */ /* { dg-options "-O2 -g -std=gnu99" } */ extern void *create (const char *); extern void destroy (void *); extern void do_nothing (char); struct string { const char *data; int lb; int ub; }; int main (void) { void *o1 = create ("foo"); void parent (void) { { void *o2 = create ("bar"); int child (struct string s) { int i = s.lb; if (s.lb <= s.ub) while (1) { char c = s.data[i - s.lb]; do_nothing (c); if (c == 'o') return 1; if (i == s.ub) break; ++i; } return 0; } int r; r = child ((struct string) {"baz", 1, 3}); r = child ((struct string) {"qux", 2, 4}); r = child ((struct string) {"foobar", 1, 6}); } do_nothing (0); } /* { dg-final { gdb-test 56 "type:main::parent::child" "int (struct string)" } } */ parent (); return 0; } --------------090107030104090602070109 Content-Type: text/x-csrc; name="nested_fun_helpers.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="nested_fun_helpers.c" Content-length: 124 void * create (const char *s) { return 0; } void destroy (void *o) { return; } void do_nothing (char c) { return; } --------------090107030104090602070109--