From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Awx+NRogP2f+STkAWB0awg (envelope-from ) for ; Thu, 21 Nov 2024 06:57:14 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=dVIwu7kL; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C0BD41E259; Thu, 21 Nov 2024 06:57:14 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C88E71E257 for ; Thu, 21 Nov 2024 06:57:10 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09A433857830 for ; Thu, 21 Nov 2024 11:57:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09A433857830 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1732190230; bh=9VOiuu0tQggq4q2QrnQc+aYFWrGQaPlR9idvb3fietg=; h=Date:To:cc:Subject:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=dVIwu7kLNvdYNtvp4OboRSBeXA3zzltbUwSgrBW4Ms9TTGZYbrHoYJcQ+PlHMcBPD GBLXPd32dg9GHzWyKRU1njCkFvYtffcveeYmthgQqTFqNnV+7+ROHn9b3HBfAf9uYn Zw4PjMDMTcKKEI2Fme6qoj7DN2sNwK+sGl0Ub5dM= Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id DB9803857707 for ; Thu, 21 Nov 2024 11:56:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB9803857707 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DB9803857707 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732190183; cv=none; b=b16N/Eqd5+lb5+mwzlWmCi4E1l26kqzLsFCGZuNxs3EvgwrGVgkpqS6wNovygkpfozrHHsZ/14aHAppvXdcK87RrvEqD0wjIjJJITa1ZubvVoGpxqQwBh0j4iWKkyw0eXTPqUQO1dAnA61zQj8QHvpBhFCP5jAHyHN8O8xnP2/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732190183; c=relaxed/simple; bh=huuk8PWfAQwzYamBM0QXgSZmfcbWHwCcY5jIxbJuvec=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=JhaGcvo+929MCbVUqQmmeo0sQyB/t8RzbTeso/nsIxELZ8aGj3Cy0CH0MvBrD2DVr35fUrnO37FtzFhTmTh3/BNyj4enao5gfJ5VeMm2o0JFdYeQ4tyictRBPF9WzdGTQB/O1jeYOxwYg0osFIxC9jdWKFJqNRYJRJswmzwroWI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB9803857707 Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D480D21A10; Thu, 21 Nov 2024 11:56:21 +0000 (UTC) Date: Thu, 21 Nov 2024 12:56:21 +0100 (CET) To: Jakub Jelinek cc: Jason Merrill , Mark Wielaard , gcc-patches@gcc.gnu.org, Alexandra Petlanova Hajkova , gdb@sourceware.org Subject: Re: [RFC PATCH] dwarf2out: Use post-DWARF 5 DW_LANG_* codes for -gdwarf-5 -gno-strict-dwarf In-Reply-To: Message-ID: <05234510-ro9o-n144-5q24-q56027979sq5@fhfr.qr> References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MISSING_XM_UA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Richard Biener via Gdb Reply-To: Richard Biener Errors-To: gdb-bounces~public-inbox=simark.ca@sourceware.org Sender: "Gdb" On Thu, 21 Nov 2024, Jakub Jelinek wrote: > Hi! > > DWARF now maintains DW_LANG_* code assignment online and 27 language codes > have been assigned already after DWARF 5 has been released, see > https://dwarfstd.org/languages.html > including one added yesterday (DW_LANG_C23). > DWARF 6 plans to use something different, DW_AT_language_{name,version} > pair where the new language versions will be just dealt with automatically > rather than adding new codes, say for C23 we'll be able to use > DW_LNAME_C 202311 while for C2Y for now to use > DW_LNAME_C 202500 until the standard is finalized. > > Now, the question is whether the toolchain should use those post DWARF 5 > codes for -gdwarf-5 -gno-strict-dwarf, or if we'll just ignore those > and only switch to DWARF 6 stuff when the standard is released and people > use -gdwarf-6 (or when we switch over to that as default). > > The following patch starts using those new codes (just for C/C++ for now, > Ada/Fortran not switched, Ada because I'm really not familiar with Ada and > Fortran because it doesn't say 2018 in the language string). > > The problem with the patch is that it regresses quite a few tests, > in particular > gcc.dg/guality/pr78726.c > g++.dg/guality/redeclaration1.C > libstdc++-prettyprinters/*.cc > libstdc++-xmethods/deque.cc > because my gdb doesn't handle those (but git trunk gdb doesn't either), > so for those the new codes are just unknown languages rather than newer > revisions of C or C++. > From what I can read in gdb, it doesn't seem to care about exact standard > revision, all it cares about is if the TU is C, C++, Fortran, Ada etc. > So, from this POV perhaps we shouldn't switch at all and ignore all the > post-DWARF 5 codes. > Or shall we wait until gdb, elfutils, whatever else actually looks at > DW_AT_language values is changed to handle the new codes and apply this > patch after that (still one would need a new version of gdb/elfutils/etc.)? > Or wait say half a year or year after that support is added in the > consumers? I'd say we at least wait until some consumers have support, if it regresses behavior with "older" consumers I don't think we want to have this as default for now anyway. Richard. > The DWARF 6 planned scheme was designed exactly to overcome this problem, > consumers that only care if something is C or C++ etc. will be able to > hardcode the code once and if they care for some behavior on something > more specific, they can just compare the version, DW_AT_language_version >= > 201703 for C++ (or < etc.), or for Fortran DW_AT_language_version >= 2008, > ... > > 2024-11-21 Jakub Jelinek > > gcc/ > * dwarf2out.cc (is_c): Handle also DW_LANG_C{17,23}. > (is_cxx): Handle also DW_LANG_C_plus_plus_{17,20,23}. > (is_fortran): Handle also DW_LANG_Fortran18. > (is_ada): Handle also DW_LANG_Ada20{05,12}. > (lower_bound_default): Handle also > DW_LANG_{C{17,23},C_plus_plus_{17,20,23},Fortran18,Ada20{05,12}}. > (add_prototyped_attribute): Handle DW_LANG_C{17,23}. > (gen_compile_unit_die): Use DW_LANG_C17 if not -gstrict-dwarf > for C17. Use DW_LANG_C23 if not -gstrict-dwarf for C23/C2Y. Use > DW_LANG_C_plus_plus_{17,20,23} if not -gstrict-dwarf for C++{17,20,23} > and the last one also for C++26. Handle DW_LANG_Fortran18. > include/ > * g++.dg/debug/dwarf2/lang-cpp17.C: Add -gno-strict-dwarf to > dg-options and expect different DW_AT_language value. > * g++.dg/debug/dwarf2/lang-cpp20.C: Likewise. > * g++.dg/debug/dwarf2/lang-cpp23.C: New test. > > --- gcc/dwarf2out.cc.jj 2024-10-25 10:00:29.445768186 +0200 > +++ gcc/dwarf2out.cc 2024-11-20 21:49:48.237062064 +0100 > @@ -5540,7 +5540,8 @@ is_c (void) > unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language); > > return (lang == DW_LANG_C || lang == DW_LANG_C89 || lang == DW_LANG_C99 > - || lang == DW_LANG_C11 || lang == DW_LANG_ObjC); > + || lang == DW_LANG_C11 || lang == DW_LANG_C17 || lang == DW_LANG_C23 > + || lang == DW_LANG_ObjC); > > > } > @@ -5553,7 +5554,9 @@ is_cxx (void) > unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language); > > return (lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus > - || lang == DW_LANG_C_plus_plus_11 || lang == DW_LANG_C_plus_plus_14); > + || lang == DW_LANG_C_plus_plus_11 || lang == DW_LANG_C_plus_plus_14 > + || lang == DW_LANG_C_plus_plus_17 || lang == DW_LANG_C_plus_plus_20 > + || lang == DW_LANG_C_plus_plus_23); > } > > /* Return TRUE if DECL was created by the C++ frontend. */ > @@ -5581,7 +5584,8 @@ is_fortran (void) > || lang == DW_LANG_Fortran90 > || lang == DW_LANG_Fortran95 > || lang == DW_LANG_Fortran03 > - || lang == DW_LANG_Fortran08); > + || lang == DW_LANG_Fortran08 > + || lang == DW_LANG_Fortran18); > } > > static inline bool > @@ -5617,7 +5621,8 @@ is_ada (void) > { > unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language); > > - return lang == DW_LANG_Ada95 || lang == DW_LANG_Ada83; > + return (lang == DW_LANG_Ada95 || lang == DW_LANG_Ada83 > + || lang == DW_LANG_Ada2005 || lang == DW_LANG_Ada2012); > } > > /* Return TRUE if the language is D. */ > @@ -21645,9 +21650,14 @@ lower_bound_default (void) > case DW_LANG_C89: > case DW_LANG_C99: > case DW_LANG_C11: > + case DW_LANG_C17: > + case DW_LANG_C23: > case DW_LANG_C_plus_plus: > case DW_LANG_C_plus_plus_11: > case DW_LANG_C_plus_plus_14: > + case DW_LANG_C_plus_plus_17: > + case DW_LANG_C_plus_plus_20: > + case DW_LANG_C_plus_plus_23: > case DW_LANG_ObjC: > case DW_LANG_ObjC_plus_plus: > return 0; > @@ -21656,13 +21666,16 @@ lower_bound_default (void) > case DW_LANG_Fortran95: > case DW_LANG_Fortran03: > case DW_LANG_Fortran08: > + case DW_LANG_Fortran18: > return 1; > case DW_LANG_UPC: > case DW_LANG_D: > case DW_LANG_Python: > return dwarf_version >= 4 ? 0 : -1; > - case DW_LANG_Ada95: > case DW_LANG_Ada83: > + case DW_LANG_Ada95: > + case DW_LANG_Ada2005: > + case DW_LANG_Ada2012: > case DW_LANG_Cobol74: > case DW_LANG_Cobol85: > case DW_LANG_Modula2: > @@ -22025,6 +22038,8 @@ add_prototyped_attribute (dw_die_ref die > case DW_LANG_C89: > case DW_LANG_C99: > case DW_LANG_C11: > + case DW_LANG_C17: > + case DW_LANG_C23: > case DW_LANG_ObjC: > if (prototype_p (func_type)) > add_AT_flag (die, DW_AT_prototyped, 1); > @@ -25372,11 +25387,17 @@ gen_compile_unit_die (const char *filena > language = DW_LANG_C99; > > if (dwarf_version >= 5 /* || !dwarf_strict */) > - if (strcmp (language_string, "GNU C11") == 0 > - || strcmp (language_string, "GNU C17") == 0 > - || strcmp (language_string, "GNU C23") == 0 > - || strcmp (language_string, "GNU C2Y") == 0) > - language = DW_LANG_C11; > + { > + if (strcmp (language_string, "GNU C11") == 0) > + language = DW_LANG_C11; > + else if (strcmp (language_string, "GNU C17") == 0) > + language = DW_LANG_C17; > + else if (strcmp (language_string, "GNU C23") == 0 > + || strcmp (language_string, "GNU C2Y") == 0) > + language = DW_LANG_C23; > + if (dwarf_strict && language > DW_LANG_C11) > + language = DW_LANG_C11; > + } > } > } > else if (startswith (language_string, "GNU C++")) > @@ -25388,11 +25409,14 @@ gen_compile_unit_die (const char *filena > language = DW_LANG_C_plus_plus_11; > else if (strcmp (language_string, "GNU C++14") == 0) > language = DW_LANG_C_plus_plus_14; > - else if (strcmp (language_string, "GNU C++17") == 0 > - || strcmp (language_string, "GNU C++20") == 0 > - || strcmp (language_string, "GNU C++23") == 0 > + else if (strcmp (language_string, "GNU C++17") == 0) > + language = DW_LANG_C_plus_plus_17; > + else if (strcmp (language_string, "GNU C++20") == 0) > + language = DW_LANG_C_plus_plus_20; > + else if (strcmp (language_string, "GNU C++23") == 0 > || strcmp (language_string, "GNU C++26") == 0) > - /* For now. */ > + language = DW_LANG_C_plus_plus_23; > + if (dwarf_strict && language > DW_LANG_C_plus_plus_14) > language = DW_LANG_C_plus_plus_14; > } > } > @@ -25445,6 +25469,7 @@ gen_compile_unit_die (const char *filena > case DW_LANG_Fortran95: > case DW_LANG_Fortran03: > case DW_LANG_Fortran08: > + case DW_LANG_Fortran18: > /* Fortran has case insensitive identifiers and the front-end > lowercases everything. */ > add_AT_unsigned (die, DW_AT_identifier_case, DW_ID_down_case); > --- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C.jj 2021-01-18 14:52:42.946040137 +0100 > +++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp17.C 2024-11-21 09:08:09.868183593 +0100 > @@ -1,8 +1,7 @@ > // { dg-do compile } > // { dg-options "-O -std=c++17 -gdwarf-5 -dA -gno-strict-dwarf" } > // { dg-skip-if "AIX DWARF5" { powerpc-ibm-aix* } } > -// For -gdwarf-6 hopefully DW_LANG_C_plus_plus_17 > -// DW_LANG_C_plus_plus_14 = 0x0021 > -// { dg-final { scan-assembler "0x21\[^\n\r]* DW_AT_language" } } */ > +// DW_LANG_C_plus_plus_177 = 0x002a > +// { dg-final { scan-assembler "0x2a\[^\n\r]* DW_AT_language" } } */ > > int version; > --- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C.jj 2021-01-18 14:52:42.946040137 +0100 > +++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp20.C 2024-11-21 09:08:31.391877872 +0100 > @@ -1,8 +1,7 @@ > // { dg-do compile } > // { dg-options "-O -std=c++20 -gdwarf-5 -dA -gno-strict-dwarf" } > // { dg-skip-if "AIX DWARF5" { powerpc-ibm-aix* } } > -// For -gdwarf-6 hopefully DW_LANG_C_plus_plus_20 > -// DW_LANG_C_plus_plus_14 = 0x0021 > -// { dg-final { scan-assembler "0x21\[^\n\r]* DW_AT_language" } } */ > +// DW_LANG_C_plus_plus_20 = 0x002b > +// { dg-final { scan-assembler "0x2b\[^\n\r]* DW_AT_language" } } */ > > int version; > --- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp23.C.jj 2024-11-21 09:08:41.801729997 +0100 > +++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp23.C 2024-11-21 09:08:57.226510904 +0100 > @@ -0,0 +1,7 @@ > +// { dg-do compile } > +// { dg-options "-O -std=c++23 -gdwarf-5 -dA -gno-strict-dwarf" } > +// { dg-skip-if "AIX DWARF5" { powerpc-ibm-aix* } } > +// DW_LANG_C_plus_plus_23 = 0x003a > +// { dg-final { scan-assembler "0x3a\[^\n\r]* DW_AT_language" } } */ > + > +int version; > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)