Skip to content
Snippets Groups Projects
  • Jakub Jelinek's avatar
    ec99905f
    dwarf2out: Emit DWARF 6 DW_AT_language_{name,version} · ec99905f
    Jakub Jelinek authored
    DWARF has voted in recently https://dwarfstd.org/issues/241209.1.html ,
    which is basically just a guarantee that the DWARF 6 draft
    DW_AT_language_{name,version} attribute codes and content of
    https://dwarfstd.org/languages-v6.html can be used as an extension
    in DWARF 5 and won't be changed.
    
    So, this patch is an alternative to the
    https://gcc.gnu.org/pipermail/gcc-patches/2024-November/669671.html
    patch, which had the major problem that it required changing all the
    DWARF consumers to be able to debug C17 or later or C++17 or later
    sources.
    This patch uses still DWARF 5 DW_LANG_C11 or DW_LANG_C_plus_plus_14,
    the latest code in DWARF 5 proper, so all DWARF 5 capable consumers
    should be able to deal with that, but additionally emits the
    DWARF 6 attributes so that newer DWARF consumers can see it isn't
    just C++14 but say C++23 or C11 but C23.  Consumers which don't know
    those DWARF 6 attributes would just ignore them.  This is like any other
    -gno-strict-dwarf extension, except that normally we emit say DWARF 5
    codes where possible only after DWARF 5 is released, while in this case
    there is a guarantee it can be used before DWARF 6 is released.
    
    2025-01-08  Jakub Jelinek  <jakub@redhat.com>
    
    include/
    	* dwarf2.h (enum dwarf_source_language): Fix comment pasto.
    	(enum dwarf_source_language_name): New type.
    	* dwarf2.def (DW_AT_language_name, DW_AT_language_version): New
    	DWARF 6 codes.
    gcc/
    	* dwarf2out.cc (break_out_comdat_types): Copy over
    	DW_AT_language_{name,version} if present.
    	(output_skeleton_debug_sections): Remove also
    	DW_AT_language_{name,version}.
    	(gen_compile_unit_die): For C17, C23, C2Y, C++17, C++20, C++23
    	and C++26 emit for -gdwarf-5 -gno-strict-dwarf also
    	DW_AT_language_{name,version} attributes.
    gcc/testsuite/
    	* g++.dg/debug/dwarf2/lang-cpp17.C: Add -gno-strict-dwarf to
    	dg-options.  Check also for DW_AT_language_{name,version} values.
    	* g++.dg/debug/dwarf2/lang-cpp20.C: Likewise.
    	* g++.dg/debug/dwarf2/lang-cpp23.C: New test.
    ec99905f
    History
    dwarf2out: Emit DWARF 6 DW_AT_language_{name,version}
    Jakub Jelinek authored
    DWARF has voted in recently https://dwarfstd.org/issues/241209.1.html ,
    which is basically just a guarantee that the DWARF 6 draft
    DW_AT_language_{name,version} attribute codes and content of
    https://dwarfstd.org/languages-v6.html can be used as an extension
    in DWARF 5 and won't be changed.
    
    So, this patch is an alternative to the
    https://gcc.gnu.org/pipermail/gcc-patches/2024-November/669671.html
    patch, which had the major problem that it required changing all the
    DWARF consumers to be able to debug C17 or later or C++17 or later
    sources.
    This patch uses still DWARF 5 DW_LANG_C11 or DW_LANG_C_plus_plus_14,
    the latest code in DWARF 5 proper, so all DWARF 5 capable consumers
    should be able to deal with that, but additionally emits the
    DWARF 6 attributes so that newer DWARF consumers can see it isn't
    just C++14 but say C++23 or C11 but C23.  Consumers which don't know
    those DWARF 6 attributes would just ignore them.  This is like any other
    -gno-strict-dwarf extension, except that normally we emit say DWARF 5
    codes where possible only after DWARF 5 is released, while in this case
    there is a guarantee it can be used before DWARF 6 is released.
    
    2025-01-08  Jakub Jelinek  <jakub@redhat.com>
    
    include/
    	* dwarf2.h (enum dwarf_source_language): Fix comment pasto.
    	(enum dwarf_source_language_name): New type.
    	* dwarf2.def (DW_AT_language_name, DW_AT_language_version): New
    	DWARF 6 codes.
    gcc/
    	* dwarf2out.cc (break_out_comdat_types): Copy over
    	DW_AT_language_{name,version} if present.
    	(output_skeleton_debug_sections): Remove also
    	DW_AT_language_{name,version}.
    	(gen_compile_unit_die): For C17, C23, C2Y, C++17, C++20, C++23
    	and C++26 emit for -gdwarf-5 -gno-strict-dwarf also
    	DW_AT_language_{name,version} attributes.
    gcc/testsuite/
    	* g++.dg/debug/dwarf2/lang-cpp17.C: Add -gno-strict-dwarf to
    	dg-options.  Check also for DW_AT_language_{name,version} values.
    	* g++.dg/debug/dwarf2/lang-cpp20.C: Likewise.
    	* g++.dg/debug/dwarf2/lang-cpp23.C: New test.