From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 7EE793858C83 for ; Wed, 11 Jan 2023 18:24:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7EE793858C83 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id C79B41E110; Wed, 11 Jan 2023 13:24:18 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1673461459; bh=m6KLvwp1Q30DPadflZA8F8t+iLFUhWnB/ZPfg3disP4=; h=Date:Subject:To:References:From:In-Reply-To:From; b=JI1ACi9p5IueqOgMndLxiDNZBRImBtL/woMpoiBgADVWlcIUy71ilJzE4TjHwp6/+ JJCn30SBmbA1cucaqbbG59h2KGVfFYuOVFoPq+SKL0FuiRFmQZHpiOtx4HmLzMcpXv PUhG8XzuQ54PNxOshCVn+gUw9JnUne2md9/oJR/Y= Message-ID: Date: Wed, 11 Jan 2023 13:24:18 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: Decl/def matching with templates without template parameters in the DW_AT_name To: David Blaikie , gdb References: Content-Language: en-US From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 1/6/23 12:37, David Blaikie via Gdb wrote: > I've been working on reducing debug info size, especially for > expression-template heavy code like in Tensorflow and Eigen. > > To that end, I've implemented the flag -gsimple-template-names in > Clang that simplifies the DW_AT_name for templates by omitting > template parameters (eg: "vector" instead of "vector std::allocator>") when the DW_TAG_template_*_parameters contain > sufficient information to reconstruct the original name. This reduces the length of strings, and more importantly it allows more sharing, is that it? It doesn't change the layout of the DIE tree? > This generally seems to work in GDB - that looks intentional (perhaps > because someone else implemented this feature elsewhere, or just for > canonicalization reasons (the full string with template parameters > might have different whitespace, parentheses, other formatting)), it > seems unlikely that GDB would accidentally be able to connect two > "vector" declarations up to the right "vector" definitions based on > the template parameters without intentional code to support this > scenario. Probably this code: https://gitlab.com/gnutools/binutils-gdb/-/blob/1b9af5b949bff0c750ededb459400c1857fec416/gdb/dwarf2/read.c#L9002 > But one place I found a problem was in pretty printers. I have > situations where a type declaration isn't resolved to a definition > when working within a pretty printer (resulting in the pretty printer > being unable to find member variables in the object/of that type) - > but if I print out the variable/member it works correctly - or if I > "list" the source of the file where the definition of the type is, > then the pretty printer works correctly. > > Does this ring a bell for anyone/sound like something sufficient to > file a bug, or would I need to dig in further to create an isolated > reproduction to help communicate the issue I'm seeing? I have no idea about what happens without digging into the code. I just remember some bug where GDB would generate the templated name with let's say "<5u>" for an integer value template parameter, so if you entered "<5>", it didn't match textually. Maybe something like that is happening. I also found: https://sourceware.org/bugzilla/show_bug.cgi?id=17762 There's the possibility that the "partial symbol" and "expanded symbol" don't have the same name. So you could see a difference in behavior depending on whether the CU has been expanded by GDB or not (I'm just speculating). Is it valid DWARF (5) for DW_AT_name of a templated struct instantiation to omit the template parameters? I don't see DWARF mandating one or the other, so I assume that both including them or not are valid. If so, I think we can consider it a GDB bug if it doesn't process the "without" version correctly. Feel free to file a bug with the relevant background information. It would be useful to include some binaries, one compiled with -gsimple-tempalte-names and one without, so it's easy to compare the two. Simon