From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51739 invoked by alias); 5 Feb 2018 16:45:33 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 51534 invoked by uid 89); 5 Feb 2018 16:45:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=efficiently X-HELO: mail-oi0-f46.google.com Received: from mail-oi0-f46.google.com (HELO mail-oi0-f46.google.com) (209.85.218.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Feb 2018 16:45:17 +0000 Received: by mail-oi0-f46.google.com with SMTP id j15so18481046oii.5 for ; Mon, 05 Feb 2018 08:45:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=pdOR09RAqAI0jTPeGiEBOZ5GQ8nby73mdJTYQRDUr5Q=; b=EeAxeYP29Q9vxUjsp0BnXsn5ahVNwOF4rQSOBvt7l+a2jO9JCB40O0i95/uVO0fqry /yWwEkMp5PJuOZ7fdHHtsN7Ubs7+Or7V2Xy3imsQHhO3v27dsaOmCSbvbh2RSOivE/B4 3mWjIF/5GpL6X6oE0gdkLjNyf0ZzpWBdKhJb0p1IxQm9Iqthr7A3pBJ5zv407hxha6Dt OE5QH8NynTUkvrdazYh9j0IfCVhHjnzQLE3DyyKtoDtIX0Cc8GNu8rJdaDjFdJtAGhAm Wd7qErzbf0xD/urmJAVSpvXxqWZaOnYT+2eUxqdO9glvQ134ZIQf3gDZNIjd9UhWBCuU XpDw== X-Gm-Message-State: AKwxytcPWKeOj/UP808LNaPSUC+iCsYJFlg3y0bzIFKwQ4kvoHHWUSoC tEwjviXT9qkPYVTZP94FmE8= X-Google-Smtp-Source: AH8x224RxysnZjB7UJQY7MX7pOEpHSpjaQC0aoOJlPIYofxg5fYDhIPOuJImJ5dZH8137E3FLS2V5Q== X-Received: by 10.202.93.195 with SMTP id r186mr12609720oib.65.1517849107441; Mon, 05 Feb 2018 08:45:07 -0800 (PST) Received: from localhost.localdomain (75-171-255-194.hlrn.qwest.net. [75.171.255.194]) by smtp.gmail.com with ESMTPSA id b40sm4589817ote.81.2018.02.05.08.45.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 08:45:06 -0800 (PST) Subject: Re: gdb 8.x - g++ 7.x compatibility To: Simon Marchi , Manfred References: <1517667601.3405.123.camel@gnu.org> <1b58e2df-5425-4f22-510c-d2e9f51040ba@polymtl.ca> <39845077-6bdf-f60d-9bfc-a491e7fa4fc7@gmail.com> <132fbd97-4f0d-020f-1c0f-1d4097800233@polymtl.ca> Cc: gdb@sourceware.org, gcc@gcc.gnu.org From: Martin Sebor Message-ID: <6da16f7c-4801-4c57-2197-271db491a88f@gmail.com> Date: Mon, 05 Feb 2018 16:45:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <132fbd97-4f0d-020f-1c0f-1d4097800233@polymtl.ca> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2018-02/txt/msg00027.txt.bz2 On 02/04/2018 10:06 PM, Simon Marchi wrote: > Hi Martin, > > Thanks for the reply. > > On 2018-02-04 02:17 PM, Martin Sebor wrote: >> Printing the suffix is unhelpful because it leads to unnecessary >> differences in diagnostics (even in non-template contexts). For >> templates with non-type template parameters there is no difference >> between, say A<1>, A<1U>, A<(unsigned) 1>, or even A when >> Green is an enumerator that evaluates to 1, so including the suffix >> serves no useful purpose. > > This is the part I don't understand. In Roman's example, spelling > foo<10> and foo<10u> resulted in two different instantiations of the > template, with different code. So that means it can make a difference, > can't it? Yes, with auto, the type of the constant does determine the type of the specialization of the template in the source code. In non-type template arguments, and more to the point I was making, in diagnostics, the suffix shouldn't or doesn't need to be what distinguishes the type of the template, even with auto. The part "with auto IVAL = 10" in the message 'void foo::print() [with auto IVAL = 10]': would be far clearer if auto were replaced by the deduced type, say along these lines: 'void foo::print() [with int IVAL = 10]': rather than relying on the suffix alone to distinguish between different specializations of the template. That seems far too subtle to me. But I think the diagnostic format is (or should be) independent of the debug info. >> In the GCC test suite, it would tend to >> cause failures due to differences between the underlying type of >> common typedefs like size_t and ptrdiff_t. Avoiding these >> unnecessary differences was the main motivation for the change. >> Not necessarily just in the GCC test suite but in all setups that >> process GCC messages. > > Ok, I understand. > >> I didn't consider the use of auto as a template parameter but >> I don't think it changes anything. There, just like in other >> contexts, what's important is the deduced types and the values >> of constants, not the minute details of how they are spelled. > > Well, it seems like using decltype on a template constant value is > a way to make the type of constants important, in addition to their > value. I know the standard seems to say otherwise (what Manfred > quoted), but the reality seems different. I'm not a language expert > so I can't tell if this is a deficiency in the language or not. > >> That said, it wasn't my intention to make things difficult for >> the debugger. > > I hope so :). > >> But changing GCC back to include the suffix, >> even just in the debug info, isn't a solution. There are other >> compilers besides GCC that don't emit the suffixes, and there >> even are some that prepend a cast to the number, so if GDB is >> to be usable with all these kinds of producers it needs to be >> able to handle all of these forms. > > As I said earlier, there are probably ways to make GDB cope with it. > The only solution I saw (I'd like to hear about other ones) was to make > GDB ignore the template part in DW_AT_name and re-build it from the > DW_TAG_template_* DIEs in the format it expects. It can already do > that somewhat, because, as you said, some compilers don't emit > the template part in DW_AT_name. > > Doing so would cause major slowdowns in symbol reading, I've tried it > for the sake of experimentation/discussion. I have a patch available > on the "users/simark/template-suffix" branch in the binutils-gdb > repo [1]. It works for Roman's example, but running the GDB testsuite > shows that, of course, the devil is in the details. > > Consider something like this: > > template > struct foo { virtual ~foo() {} }; > > int n; > > int main () > { > foo<&n> f; > } > > > The demangled name that GDB will be looking up is "foo<&n>". The > debug info about the template parameter only contains the resulting > address of n (the value of &n): > > <2>: Abbrev Number: 11 (DW_TAG_template_value_param) > DW_AT_name : P > DW_AT_type : <0x1ac> > DW_AT_location : 10 byte block: 3 34 10 60 0 0 0 0 0 9f (DW_OP_addr: 601034; DW_OP_stack_value) > > I don't see how GDB could reconstruct the "&n" in the template, so > that's where my idea falls short. I'm afraid I know too little about the internals of GDB to fully appreciate the importance of this problem or have an idea how it could be handled. With respect to the suffix, I keep coming back to the reality that even if GCC were to change to emit a format that GDB can interpret easily and efficiently, there still are other compilers that emit a different format. So the conclusion that a general solution that handles more than just one format (at least for non-type template arguments without auto) seems unescapable. For auto, since it's new, a viable alternative might be to standardize the debug info format so that eventually all producers will converge on it. But even that approach won't help users of existing compilers. Martin > > Simon > > [1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=shortlog;h=refs/heads/users/simark/template-suffix >