Go to file
David Faust ac7027f180 dwarf: create annotation DIEs for btf tags
The btf_decl_tag and btf_type_tag attributes provide a means to annotate
declarations and types respectively with arbitrary user provided
strings.  These strings are recorded in debug information for
post-compilation uses, and despite the name they are meant to be
recorded in DWARF as well as BTF.  New DWARF extensions
DW_TAG_GNU_annotation and DW_AT_GNU_annotation are used to represent
these user annotations in DWARF.

This patch introduces the new DWARF extension DIE and attribute, and
generates them as necessary to represent user annotations from
btf_decl_tag and btf_type_tag.

The format of the new DIE is as follows:

    DW_TAG_GNU_annotation
        DW_AT_name: "btf_decl_tag" or "btf_type_tag"
        DW_AT_const_value: <arbitrary user-supplied string>
        DW_AT_GNU_annotation: <reference to another TAG_GNU_annotation DIE>

DW_AT_GNU_annotation is a new attribute extension used to refer to these
new annotation DIEs.  If non-null in any given declaration or type DIE,
it is a reference to a DW_TAG_GNU_annotation DIE holding an annotation
for that declaration or type.  In addition, the DW_TAG_GNU_annotation
DIEs may also have a non-null DW_AT_GNU_annotation, referring to another
annotation DIE.  This allows chains of annotation DIEs to be formed,
such as in the case where a single declaration has multiple instances of
btf_decl_tag with different string annotations.

gcc/
	* dwarf2out.cc (struct annotation_node, struct annotation_node_hasher)
	(btf_tag_htab): New ancillary structures and hash table.
	(annotation_node_hasher::hash, annotation_node_hasher::equal): New.
	(hash_btf_tag, gen_btf_tag_dies, maybe_gen_btf_type_tag_dies)
	(maybe_gen_btf_decl_tag_dies): New functions.
	(modified_type_die): Add new argument to pass type attributes.
	Handle btf_type_tag, and update recursive calls.
	(base_type_for_mode): Add new arg for modified_type_die call.
	(add_type_attribute): Likewise.
	(gen_array_type_die): Call maybe_gen_btf_type_tag_dies for the type.
	(gen_formal_parameter_die): Call maybe_gen_btf_decl_tag_dies for the
	parameter.
	(override_type_for_decl_p): Add new arg for modified_type_die call.
	(force_type_die): Likewise.
	(gen_tagged_type_die): Call maybe_gen_btf_type_tag_dies for the type.
	(gen_decl_die): Call maybe_gen_btf_decl_tag_dies for the decl.
	(dwarf2out_finish): Empty btf_tag_htab.
	(dwarf2out_cc_finalize): Delete btf_tag_htab hash table.

include/
	* dwarf2.def (DW_TAG_GNU_annotation): New DWARF extension.
	(DW_AT_GNU_annotation): Likewise.

gcc/testsuite/
	* gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-1.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-2.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-3.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-1.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-2.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-3.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-4.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-5.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-6.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-7.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-8.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-9.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-10.c: New test.
2025-10-09 14:13:23 -07:00
.forgejo top-level: Add pull request template for Forgejo 2024-10-23 19:45:09 +01:00
.github
INSTALL
c++tools Daily bump. 2025-06-03 00:18:06 +00:00
config Daily bump. 2025-10-05 16:50:51 +00:00
contrib Daily bump. 2025-10-09 00:21:21 +00:00
fixincludes Daily bump. 2025-08-29 00:19:55 +00:00
gcc dwarf: create annotation DIEs for btf tags 2025-10-09 14:13:23 -07:00
gnattools Daily bump. 2025-06-23 00:16:33 +00:00
gotools Daily bump. 2024-04-16 00:18:06 +00:00
include dwarf: create annotation DIEs for btf tags 2025-10-09 14:13:23 -07:00
libada Update copyright years. 2025-01-02 11:59:57 +01:00
libatomic PR81358: Enable automatic linking of libatomic. 2025-10-09 07:26:51 +00:00
libbacktrace Daily bump. 2025-10-05 16:50:51 +00:00
libcc1 diagnostics: add class sink::extension 2025-10-09 11:38:50 -04:00
libcody Update Copyright year in ChangeLog files 2025-01-02 11:13:18 +01:00
libcpp Daily bump. 2025-10-09 00:21:21 +00:00
libdecnumber Update copyright years. 2025-01-02 11:59:57 +01:00
libffi Daily bump. 2025-10-05 16:50:51 +00:00
libgcc AVR: target/122222 - Add modules for __floatsidf, __floatunsidf. 2025-10-09 21:55:11 +02:00
libgcobol Daily bump. 2025-10-05 16:50:51 +00:00
libgfortran Daily bump. 2025-10-05 16:50:51 +00:00
libgm2 Daily bump. 2025-10-08 00:20:55 +00:00
libgo runtime: avoid libc memmove and memclr 2025-07-08 15:49:16 -07:00
libgomp Daily bump. 2025-10-05 16:50:51 +00:00
libgrust Daily bump. 2025-10-05 16:50:51 +00:00
libiberty Daily bump. 2025-10-05 16:50:51 +00:00
libitm Daily bump. 2025-10-05 16:50:51 +00:00
libobjc Daily bump. 2025-10-05 16:50:51 +00:00
libphobos Daily bump. 2025-10-05 16:50:51 +00:00
libquadmath Daily bump. 2025-10-05 16:50:51 +00:00
libsanitizer Daily bump. 2025-10-05 16:50:51 +00:00
libssp Daily bump. 2025-10-05 16:50:51 +00:00
libstdc++-v3 libstdc++: Extend constexpr if to C++14 in _Hashtable::_S_nothrow_move() 2025-10-09 15:26:08 +01:00
libvtv Daily bump. 2025-10-05 16:50:51 +00:00
lto-plugin Daily bump. 2025-10-05 16:50:51 +00:00
maintainer-scripts Daily bump. 2025-09-02 00:19:26 +00:00
zlib Daily bump. 2025-10-05 16:50:51 +00:00
.b4-config Add config file so b4 uses inbox.sourceware.org automatically 2024-07-28 11:13:16 +01:00
.dir-locals.el dir-locals: apply our C settings in C++ also 2024-07-31 20:38:27 +02:00
.editorconfig toplevel: unify the GCC and GDB/binutils .editorconfig files 2025-10-01 15:42:59 +01:00
.gitattributes
.gitignore Rust: Move 'libformat_parser' build into the GCC build directory 2025-08-05 16:36:43 +02:00
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Daily bump. 2025-10-05 16:50:51 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
MAINTAINERS MAINTAINERS: Add myself as an aarch64 port reviewer 2025-09-04 14:35:30 +00:00
Makefile.def PR81358: Enable automatic linking of libatomic. 2025-10-09 07:26:51 +00:00
Makefile.in PR81358: Enable automatic linking of libatomic. 2025-10-09 07:26:51 +00:00
Makefile.tpl PR81358: Enable automatic linking of libatomic. 2025-10-09 07:26:51 +00:00
README
SECURITY.txt Remove Debian from SECURITY.txt 2024-11-19 12:27:33 +01:00
ar-lib
compile
config-ml.in Remove extra argument from subst macro 2025-03-13 07:26:04 +01:00
config.guess
config.rpath
config.sub
configure PR81358: Enable automatic linking of libatomic. 2025-10-09 07:26:51 +00:00
configure.ac PR81358: Enable automatic linking of libatomic. 2025-10-09 07:26:51 +00:00
depcomp
install-sh
libtool-ldflags
libtool.m4 Sync toplevel files from binutils-gdb 2025-10-02 15:00:06 +08:00
ltgcc.m4
ltmain.sh ltmain.sh: allow more flags at link-time 2024-09-25 19:05:24 +01:00
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
symlink-tree
test-driver
ylwrap

README

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.