support for DW_TAG_GNU_annotation and fixes
v5 cover support for DW_TAG_GNU_annotation and fixes
Hi,
This series handles gcc generated DW_TAG_GNU_annotation with the end goal to finally enable CONFIG_PAHOLE_HAS_BTF_TAG for gcc kerenel builds.
Patches 1/5 and 5/5 are newly introduced in v5 per Alan's ask.
P.S.: I've optimistically included Reviewed-by/Acked-by from Emil and Yonghong respectively on v4 [4] but those were before additional changes in v5 from Alan for a few things. Please let me know if that's no longer true.
[4] https://lore.kernel.org/bpf/[email protected]/
Thx,
-Vineet
Alan Maguire (2):
btf_loader: Handle decl tag component_idx for parameters
tests: Add btf_type_tag ordering test
Vineet Gupta (3):
dwarf_loader: Extract die__add_btf_type_tag() helper [NFC]
dwarf_loader: Add support for DW_TAG_GNU_annotation
tests: Support GCC in pfunct-btf-decl-tags test
btf_encoder.c | 1 + btf_loader.c | 46 ++++++++- dutil.h | 11 ++ dwarf_loader.c | 185 +++++++++++++++++++++++++++------- dwarves.h | 2 +- dwarves_fprintf.c | 32 ++++-- tests/btf_type_tag_order.sh | 179 ++++++++++++++++++++++++++++++++ tests/pfunct-btf-decl-tags.sh | 93 ++++++++++++----- 8 files changed, 478 insertions(+), 71 deletions(-) create mode 100755 tests/btf_type_tag_order.sh
Signature · 1 line
2.54.0
PATCH v5 1/5 btf_loader: Handle decl tag component_idx for parameters
From: Alan Maguire <[email protected]>
A BTF_KIND_DECL_TAG with a non-negative component_idx applies to a specific function parameter (or struct/union member), not to the function itself. btf_loader.c however attached every decl tag to the type named by btf_type->type, so parameter decl tags were recorded on the function rather than on the parameter, and pfunct never printed them with the parameter.
Resolve a non-negative component_idx to the corresponding parameter via new helpers ftype__parameter()/function__parameter(), and attach the tag there. Teach the pretty printer to emit a parameter's attributes by factoring the function-level attribute loop into tag__attributes_fprintf() and calling it from ftype__fprintf_parms() for each parameter.
--- btf_loader.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- dwarves_fprintf.c | 20 ++++++++++++++++---- 2 files changed, 61 insertions(+), 5 deletions(-)
btf_loader.c +45 -1
@@ -477,12 +477,56 @@ static struct attributes *attributes__realloc(struct attributes *attributes, conreturn result; } +static struct tag *ftype__parameter (const struct ftype *ftype,int component_idx) +{ +struct parameter *pos; +int idx =0 ; + +ftype__for_each_parameter (ftype, pos) { +if (idx == component_idx) +return &pos->tag; + ++idx; + } + +return NULL ; +} + +static struct tag *function__parameter (const struct function *func,struct cu *cu, +int component_idx) +{ +struct tag *tag; + +if (component_idx <0 ) +return NULL ; + + tag =cu__type (cu, func->proto.tag.type); +if (tag ==NULL ) +return NULL ; + +return ftype__parameter (tag__ftype (tag), component_idx); +} +static int process_decl_tag (struct cu *cu,const struct btf_type *tp) { +int component_idx =btf_decl_tag (tp)->component_idx;struct tag *tag =cu__type (cu, tp->type);struct attributes *tmp; -if (tag ==NULL ) +if (component_idx >=0 ) { +struct tag *func_tag =cu__function (cu, tp->type); + +if (func_tag !=NULL ) { + tag =function__parameter (tag__function (func_tag), cu, + component_idx); +if (tag ==NULL ) { +fprintf (stderr,"WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n" , + component_idx, tp->type); +return 0 ; + } + } + } + +if (tag ==NULL && component_idx <0 ) tag =cu__function (cu, tp->type);if (tag ==NULL )
dwarves_fprintf.c +16 -4
@@ -1199,6 +1199,18 @@ const char *function__prototype(const struct function *func, bf, len); } +static size_t tag__attributes_fprintf (const struct tag *tag,FILE *fp) +{ +size_t printed =0 ; +int i; + +if (tag->attributes) +for (i =0 ; i < tag->attributes->cnt; ++i) + printed +=fprintf (fp,"%s " , tag->attributes->values[i]); + +return printed; +} +size_t ftype__fprintf_parms (const struct ftype *ftype,const struct cu *cu,int indent,const struct conf_fprintf *conf,FILE *fp)
@@ -1240,6 +1252,7 @@ size_t ftype__fprintf_parms(const struct ftype *ftype,if (n)return printed + n;if (ptype->tag == DW_TAG_subroutine_type) { + printed +=tag__attributes_fprintf (&pos->tag, fp); printed += ftype__fprintf(tag__ftype(ptype), cu, name, 0, 1, 0,
@@ -1248,12 +1261,14 @@ size_t ftype__fprintf_parms(const struct ftype *ftype, } } }else if (type->tag == DW_TAG_subroutine_type) { + printed +=tag__attributes_fprintf (&pos->tag, fp); printed +=ftype__fprintf (tag__ftype (type), cu, name, true,0 ,0 ,0 , conf, fp);continue ; } stype =tag__name (type, cu, sbf,sizeof (sbf), conf); print_it: + printed +=tag__attributes_fprintf (&pos->tag, fp); printed +=fprintf (fp,"%s%s%s" , stype, name ?" " :"" , name ?:"" ); }
@@ -1405,11 +1420,8 @@ static size_t function__fprintf(const struct tag *tag, const struct cu *cu,struct ftype *ftype = func->btf ?tag__ftype (cu__type (cu, func->proto.tag.type)) : &func->proto;size_t printed =0 ;bool inlined = !conf->strip_inline &&function__declared_inline (func); -int i; -if (tag->attributes) -for (i =0 ; i < tag->attributes->cnt; ++i) - printed +=fprintf (fp,"%s " , tag->attributes->values[i]); + printed +=tag__attributes_fprintf (tag, fp);if (func->virtuality == DW_VIRTUALITY_virtual || func->virtuality == DW_VIRTUALITY_pure_virtual)
Signature · 1 line
2.54.0
PATCH v5 2/5 dwarf_loader: Extract die__add_btf_type_tag() helper [NFC]
In reply to Vineet GuptaNFC change preparing for DW_TAG_GNU_annotation support. Extract the btf_type_tag annotation creation logic into helper die__add_btf_type_tag().
---
Changes since v [4]
- Collected the review tags [Emil, Yonghong]
Changes since v3 [3]
- Fix comment to kernel style [Arnaldo]
Changes since v2 [2]
- die__add_btf_type_tag() returns pointer not error code [Alan]
Changes since v1 [1]
- NFC reinstate some original comments
[4] https://lore.kernel.org/bpf/[email protected]/
[3] https://lore.kernel.org/bpf/[email protected]/
[2] https://lore.kernel.org/bpf/[email protected]/
[1] https://lore.kernel.org/bpf/[email protected]/
--- dwarf_loader.c | 58 +++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 24 deletions(-)
dwarf_loader.c +34 -24
@@ -1600,14 +1600,44 @@ static struct btf_type_tag_type *die__create_new_btf_type_tag_type(Dwarf_Die *direturn tag; } +static struct btf_type_tag_ptr_type *die__add_btf_type_tag (struct btf_type_tag_ptr_type *tag, +Dwarf_Die *die,Dwarf_Die *adie, +struct cu *cu,struct conf_load *conf) +{ +struct btf_type_tag_type *annot; +uint32_t id; + +if (tag ==NULL ) { + tag =die__create_new_btf_type_tag_ptr_type (die, cu); +if (!tag) +return NULL ; + } + + annot =die__create_new_btf_type_tag_type (adie, cu, conf); +if (annot ==NULL ) +return NULL ; + +if (cu__table_add_tag (cu, &annot->tag, &id) <0 ) +return NULL ; + +struct dwarf_tag *dtag =tag__dwarf (&annot->tag); + dtag->small_id = id; +cu__hash (cu, &annot->tag); + +/* +* Prepends: for annotations tag1 -> tag2 -> tag3, +* the tag->tags list ends up as tag3 -> tag2 -> tag1. +*/ +list_add (&annot->node, &tag->tags); +return tag; +} +static struct tag *die__create_new_pointer_tag (Dwarf_Die *die,struct cu *cu,struct conf_load *conf) {struct btf_type_tag_ptr_type *tag =NULL ; -struct btf_type_tag_type *annot;Dwarf_Die *cdie, child;const char *name; -uint32_t id;/* If no child tags or skipping btf_type_tag encoding, just create a new tag * and return
@@ -1627,29 +1657,9 @@ static struct tag *die__create_new_pointer_tag(Dwarf_Die *die, struct cu *cu,if (strcmp (name,"btf_type_tag" ) !=0 )continue ; -if (tag ==NULL ) { -/* Create a btf_type_tag_ptr type. */ - tag =die__create_new_btf_type_tag_ptr_type (die, cu); -if (!tag) -return NULL ; - } - -/* Create a btf_type_tag type for this annotation. */ - annot =die__create_new_btf_type_tag_type (cdie, cu, conf); -if (annot ==NULL ) -return NULL ; - -if (cu__table_add_tag (cu, &annot->tag, &id) <0 ) + tag =die__add_btf_type_tag (tag, die, cdie, cu, conf); +if (tag ==NULL )return NULL ; - -struct dwarf_tag *dtag =tag__dwarf (&annot->tag); - dtag->small_id = id; -cu__hash (cu, &annot->tag); - -/* For a list of DW_TAG_LLVM_annotation like tag1 -> tag2 -> tag3, -* the tag->tags contains tag3 -> tag2 -> tag1. -*/ -list_add (&annot->node, &tag->tags); }while (dwarf_siblingof (cdie, cdie) ==0 );return tag ? &tag->tag :tag__new (die, cu);
Signature · 1 line
2.54.0
PATCH v5 3/5 dwarf_loader: Add support for DW_TAG_GNU_annotation
In reply to Vineet Guptagcc 16 was the first release to support DW_TAG_GNU_annotations and this patch enables the same in pahole. Bulk of changes are dwarf_loader but btf_encoder also gains support with minimal changes.
GCC encodes btf_type_tag and btf_decl_tag annotations differently from LLVM. While LLVM uses DW_TAG_LLVM_annotation (0x6000) as child DIEs, GCC uses DW_TAG_GNU_annotation (0x6001) as standalone sibling DIEs referenced via DW_AT_GNU_annotation (0x2139) attributes, with chaining through the same attribute on annotation DIEs themselves.
Handle both encoding styles:
For btf_type_tag (pointer annotations):
- Recognize DW_TAG_GNU_annotation alongside DW_TAG_LLVM_annotation in child annotation scanning.
- Follow DW_AT_GNU_annotation attribute chains on pointer types for GCC-style btf_type_tag resolution.
- Normalize DW_TAG_GNU_annotation to DW_TAG_LLVM_annotation in the internal representation so downstream code works unchanged.
- Preserve btf_type_tag emission order across both formats: LLVM child DIEs come in source order and are prepended (reversed) into the tag list, while a GCC DW_AT_GNU_annotation chain is already in BTF order and is appended. die__add_btf_type_tag() takes a 'prepend' argument to select between the two.
For btf_decl_tag (function/struct/member annotations):
- Add add_gnu_annotation_chain() to follow DW_AT_GNU_annotation attribute chains on function, struct, and member DIEs.
- GCC puts DW_AT_GNU_annotation on the function/struct DIE itself (not as child DIEs), referencing sibling annotation DIEs that chain via the same attribute.
- Follow DW_AT_GNU_annotation chains on formal parameter DIEs so that GCC-style parameter decl tags are loaded too.
Also:
- Silently skip standalone DW_TAG_GNU_annotation DIEs at CU level.
- Add tag__is_annotation() helper macro for annotation tag checks.
- Rename add_llvm_annotation -> add_tag_annotation, skip_llvm_annotations -> skip_tag_annotations since these now handle both LLVM and GNU annotation formats.
---
Changes since v4 [4]
- Handle gcc-style function paramter tags [Alan]
- Handle multi tag ordering correctly for LLVM and GCC [Alan]
- Collected the review tags [Emil, Yonghong]
Changes since v3 [3]
- Add helper tag__is_annotation [Emil]
- Rename some functions containing "llvm" as they are common to LLVM/GCC tags [Emil]
- Deduplicate checks before loop and inside loop in add_gnu_annotation_chain() and check_gnu_attr [Arnaldo]
- Fix some typos and move some comments [Emi]
Changes since v2 [2]
- Removed loop detection logic [Alan]
- Move test changes to different patch [Alan]
Changes since v1 [1]
- NFC Reduce indentation with early exits (Alexei offlist)
[4] https://lore.kernel.org/bpf/[email protected]/
[3] https://lore.kernel.org/bpf/[email protected]/
[2] https://lore.kernel.org/bpf/[email protected]/
[1] https://lore.kernel.org/bpf/[email protected]/
--- btf_encoder.c | 1 + dutil.h | 11 ++++ dwarf_loader.c | 141 +++++++++++++++++++++++++++++++++++++++------- dwarves.h | 2 +- dwarves_fprintf.c | 12 ++-- 5 files changed, 141 insertions(+), 26 deletions(-)
btf_encoder.c +1 -0
@@ -1831,6 +1831,7 @@ static int btf_encoder__encode_tag(struct btf_encoder *encoder, struct tag *tag, name =namespace__name (tag__namespace (tag));return btf_encoder__add_ref_type (encoder,BTF_KIND_TYPEDEF , ref_type_id, name, false);case DW_TAG_LLVM_annotation: +case DW_TAG_GNU_annotation: name =tag__btf_type_tag (tag)->value;return btf_encoder__add_ref_type (encoder,BTF_KIND_TYPE_TAG , ref_type_id, name, false);case DW_TAG_structure_type:
dutil.h +11 -0
@@ -35,6 +35,17 @@#define DW_TAG_LLVM_annotation 0x6000#endif +#ifndef DW_TAG_GNU_annotation +#define DW_TAG_GNU_annotation 0x6001 +#endif + +#ifndef DW_AT_GNU_annotation +#define DW_AT_GNU_annotation 0x2139 +#endif + +#define tag__is_annotation (tag) \ + ((tag) == DW_TAG_LLVM_annotation || (tag) == DW_TAG_GNU_annotation) +static inline __attribute__((const))bool is_power_of_2 (unsigned long n) {return (n !=0 && ((n & (n -1 )) ==0 ));
dwarf_loader.c +120 -21
245 lines not on this page · raw message
dwarves.h +1 -1
@@ -670,7 +670,7 @@ static inline int tag__is_tag_type(const struct tag *tag) tag->tag == DW_TAG_volatile_type || tag->tag == DW_TAG_atomic_type || tag->tag == DW_TAG_unspecified_type || - tag->tag == DW_TAG_LLVM_annotation; +tag__is_annotation (tag->tag); } static inline const char *tag__decl_file(const struct tag *tag,
dwarves_fprintf.c +8 -4
@@ -140,6 +140,8 @@ const char *dwarf_tag_name(const uint32_t tag)return dwarf_gnu_tag_names[tag - DW_TAG_MIPS_loop]; else if (tag == DW_TAG_LLVM_annotation) return "LLVM_annotation"; + else if (tag == DW_TAG_GNU_annotation) + return "GNU_annotation";return "INVALID" ; }
@@ -658,6 +660,7 @@ static const char *__tag__name(const struct tag *tag, const struct cu *cu,snprintf (bf, len,"%s" ,variable__name (tag__variable (tag)));break ;case DW_TAG_LLVM_annotation: +case DW_TAG_GNU_annotation: type =cu__type (cu, tag->type);if (type ==NULL && tag->type !=0 )tag__id_not_found_snprintf (bf, len, tag->type);
@@ -723,7 +726,7 @@ static size_t type__fprintf_stats(struct type *type, const struct cu *cu,return printed; } -static type_id_t skip_llvm_annotations (const struct cu *cu,type_id_t id) +static type_id_t skip_tag_annotations (const struct cu *cu,type_id_t id) {struct tag *type;
@@ -731,7 +734,7 @@ static type_id_t skip_llvm_annotations(const struct cu *cu, type_id_t id)if (id ==0 )break ; type =cu__type (cu, id); -if (type ==NULL || type->tag != DW_TAG_LLVM_annotation || type->type == id) +if (type ==NULL || !tag__is_annotation (type->tag) || type->type == id)break ; id = type->type; }
@@ -838,7 +841,7 @@ inner_struct: next_type:switch (type->tag) {case DW_TAG_pointer_type: { -type_id_t ptype_id =skip_llvm_annotations (cu, type->type); +type_id_t ptype_id =skip_tag_annotations (cu, type->type);if (ptype_id !=0 ) {int n;
@@ -936,7 +939,8 @@ print_modifier: {else printed +=enumeration__fprintf (type, &tconf, fp);break ; -case DW_TAG_LLVM_annotation: { +case DW_TAG_LLVM_annotation: +case DW_TAG_GNU_annotation: {struct tag *ttype =cu__type (cu, type->type);if (ttype) { type = ttype;
Signature · 1 line
2.54.0
PATCH v5 4/5 tests: Support GCC in pfunct-btf-decl-tags test
In reply to Vineet GuptaGCC 16+ supports btf_decl_tag via DW_TAG_GNU_annotation. Update the test to run with both GCC (>= 16) and clang when available, instead of requiring clang only.
Compile the clang case natively and encode BTF with "pahole -J" (like the GCC case) rather than emitting BPF-target BTF directly, so both compilers exercise the same DWARF -> BTF path.
Add a function with a parameter decl tag (qux) to cover decl tags that carry a component_idx, and make the awk post-processing pass through lines that have no leading tags.
---
Changes since v4 [4]
- Test function param decl tag [Alan]
- Missing "pahole -j" for clang [Yonghong]
- Collected the review tags [Emil, Yonghong]
[4] https://lore.kernel.org/bpf/[email protected]/
---
tests/pfunct-btf-decl-tags.sh | 93 ++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 23 deletions(-)
tests/pfunct-btf-decl-tags.sh +70 -23
@@ -6,43 +6,60 @@ source test_lib.sh outdir=$(make_tmpdir) -tmpobj=$(make_tmpobj) # Comment this out to save test data. trap cleanup EXIT title_log "Check that pfunct can print btf_decl_tags read from BTF." -# gcc now also supports decl tags as of gcc commit 43dcea48b8c, -# in upstream version 16. -# UPTODO: add a check here for that. +# gcc 16+ supports decl tags via DW_TAG_GNU_annotation (gcc commit ac7027f180b). +GCC=${GCC:-gcc} CLANG=${CLANG:-clang} -if ! command -v $CLANG > /dev/null; then - error_log "Need clang for test $0" + +use_gcc=0 +if command -v $GCC > /dev/null; then + gcc_ver=$($GCC -dumpversion 2>/dev/null | cut -d. -f1) + if [ "$gcc_ver" -ge 16 ] 2>/dev/null; then + use_gcc=1 + fi +fi + +use_clang=0 +if command -v $CLANG > /dev/null; then + use_clang=1 +fi + +if [ "$use_gcc" -eq 0 ] && [ "$use_clang" -eq 0 ]; then + error_log "Need gcc >= 16 or clang for test $0" test_fail fi -(cat <<EOF +src=$(cat <<EOF #define __tag(x) __attribute__((btf_decl_tag(#x))) __tag(a) __tag(b) __tag(c) void foo(void) {} __tag(a) __tag(b) void bar(void) {} __tag(a) void buz(void) {} +void qux(int __tag(param_a) arg) {} EOF -) | $CLANG --target=bpf -c -g -x c -o $tmpobj - +) # tags order is not guaranteed sort_tags=$(cat <<EOF { -match(\$0,/^(.*) (void .*)/,tags_and_proto); -tags = tags_and_proto[1]; -proto = tags_and_proto[2]; -split(tags, tags_arr ,/ /); -asort(tags_arr); -for (t in tags_arr) printf "%s ", tags_arr[t]; -print proto; +delete tags_arr; +if (match(\$0,/^(.*) (void .*)/,tags_and_proto)) { + tags = tags_and_proto[1]; + proto = tags_and_proto[2]; + split(tags, tags_arr ,/ /); + asort(tags_arr); + for (t in tags_arr) printf "%s ", tags_arr[t]; + print proto; +} else { + print \$0; +} } EOF )
@@ -51,19 +68,49 @@ expected=$(cat <<EOF a b c void foo(void); a b void bar(void); a void buz(void); +void qux(param_a int arg); EOF ) -out=$(pfunct -P -F btf $tmpobj | awk "$sort_tags" | sort) -d=$(diff -u <(echo "$expected") <(echo "$out")) +run_test() { + local compiler=$1 + local tmpobj=$2 + + info_log "Testing with $compiler" + out=$(pfunct -P -F btf $tmpobj | awk "$sort_tags" | sort) + d=$(diff -u <(echo "$expected") <(echo "$out")) + + if [[ "$d" == "" ]]; then + info_log " passed" + return 0 + else + error_log "pfunct output does not match expected ($compiler):" + info_log "$d" + info_log + info_log "Complete output:" + info_log "$out" + return 1 + fi +} + +failed=0 + +if [ "$use_gcc" -eq 1 ]; then + tmpobj=$(make_tmpobj) + echo "$src" | $GCC -c -g -x c -o $tmpobj - 2>/dev/null + pahole -J $tmpobj 2>/dev/null + run_test "$GCC (version $gcc_ver)" "$tmpobj" || failed=1 +fi + +if [ "$use_clang" -eq 1 ]; then + tmpobj=$(make_tmpobj) + echo "$src" | $CLANG -c -g -x c -o $tmpobj - + pahole -J $tmpobj 2>/dev/null + run_test "$CLANG" "$tmpobj" || failed=1 +fi -if [[ "$d" == "" ]]; then +if [ "$failed" -eq 0 ]; then test_pass else - error_log "pfunct output does not match expected:" - info_log "$d" - info_log - info_log "Complete output:" - info_log "$out" test_fail fi
Signature · 1 line
2.54.0
PATCH v5 5/5 tests: Add btf_type_tag ordering test
In reply to Vineet GuptaFrom: Alan Maguire <[email protected]>
Add a test that compiles a pointer carrying two btf_type_tags (__tag(outer) __tag(inner)) and checks the BTF that pahole emits to ensure the tag chain is PTR -> TYPE_TAG inner -> TYPE_TAG outer -> struct sample, i.e. the innermost tag is closest to the pointer.
This exercises the type_tag ordering for both encodings: LLVM emits the annotations as child DIEs in source order (reversed when building the tag list), while GCC chains them via DW_AT_GNU_annotation already in BTF order. The test runs with gcc and clang when they support btf_type_tag, and is skipped when bpftool is unavailable.
--- tests/btf_type_tag_order.sh | 179 ++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100755 tests/btf_type_tag_order.sh
tests/btf_type_tag_order.sh new file +179 -0
@@ -0,0 +1,179 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +# Check that pahole preserves btf_type_tag order when emitting BTF from DWARF. + +source test_lib.sh + +outdir=$(make_tmpdir) + +# Comment this out to save test data. +trap cleanup EXIT + +title_log "Check BTF type tag order." + +GCC=${GCC:-gcc} +CLANG=${CLANG:-clang} +PAHOLE=${PAHOLE:-pahole} +BPFTOOL=${BPFTOOL:-bpftool} + +if ! command -v "$BPFTOOL" > /dev/null; then + info_log "skip: bpftool not available" + test_skip +fi + +compiler_has_btf_type_tag() +{ + local compiler=$1 + + if ! command -v "$compiler" > /dev/null; then + return 1 + fi + + "$compiler" -x c -E -P - <<'EOF' 2>/dev/null | grep -qx 1 +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#if __has_attribute(btf_type_tag) +1 +#else +0 +#endif +EOF +} + +use_gcc=0 +if compiler_has_btf_type_tag "$GCC"; then + use_gcc=1 +fi + +use_clang=0 +if compiler_has_btf_type_tag "$CLANG"; then + use_clang=1 +fi + +if [ "$use_gcc" -eq 0 ] && [ "$use_clang" -eq 0 ]; then + error_log "Need gcc or clang with btf_type_tag support for test $0" + test_fail +fi + +src=$(cat <<EOF +#define __tag(x) __attribute__((btf_type_tag(#x))) + +struct sample { + int value; +}; + +struct sample __tag(outer) __tag(inner) *global_ptr; + +EOF +) + +check_type_tag_order() +{ + local btf=$1 + local dump + + if ! dump=$("$BPFTOOL" btf dump file "$btf"); then + return 1 + fi + + printf '%s\n' "$dump" | awk ' + function parse_id(line, m) { + if (match(line, /^\[([0-9]+)\]/, m)) + return m[1] + return 0 + } + function parse_name(line, m) { + if (match(line, /\047([^\047]*)\047/, m)) + return m[1] + return "" + } + function parse_type(line, m) { + if (match(line, /type_id=([0-9]+)/, m)) + return m[1] + return 0 + } + function check_ptr(ptr, id, tags, seen) { + id = type[ptr] + while (id != 0 && !seen[id]) { + seen[id] = 1 + if (kind[id] == "TYPE_TAG") { + tags = tags (tags == "" ? "" : " -> ") name[id] + id = type[id] + continue + } + if (kind[id] == "STRUCT" && name[id] == "sample") { + if (tags == "inner -> outer") + exit 0 + candidates = candidates (candidates == "" ? "" : ", ") tags + } + return + } + } + /^\[[0-9]+\]/ { + id = parse_id($0) + kind[id] = $2 + name[id] = parse_name($0) + type[id] = parse_type($0) + if (kind[id] == "PTR") + ptrs[++nr_ptrs] = id + } + END { + for (i = 1; i <= nr_ptrs; i++) + check_ptr(ptrs[i]) + if (candidates != "") { + print "type tag order mismatch; expected inner -> outer, found " candidates > "/dev/stderr" + exit 1 + } + print "could not find tagged pointer to struct sample" > "/dev/stderr" + exit 1 + }' +} + +run_test() +{ + local compiler=$1 + local tmpobj=$2 + local btf=$3 + + info_log "Testing with $compiler" + + if ! echo "$src" | "$compiler" -g -c -x c -o "$tmpobj" - 2>/dev/null; then + error_log "Could not compile type tag order test with $compiler" + return 1 + fi + + if ! "$PAHOLE" --btf_features=+type_tag --btf_encode_detached="$btf" "$tmpobj" 2>/dev/null; then + error_log "Could not encode BTF for $tmpobj" + return 1 + fi + + if check_type_tag_order "$btf"; then + info_log " passed" + return 0 + fi + + error_log "BTF type tag order does not match expected order ($compiler)" + return 1 +} + +failed=0 + +if [ "$use_gcc" -eq 1 ]; then + tmpobj=$(make_tmpobj) + btf=${tmpobj%.o}.btf + run_test "$GCC" "$tmpobj" "$btf" || failed=1 +fi + +if [ "$use_clang" -eq 1 ]; then + tmpobj=$(make_tmpobj) + btf=${tmpobj%.o}.btf + run_test "$CLANG" "$tmpobj" "$btf" || failed=1 +fi + +if [ "$failed" -eq 0 ]; then + test_pass +else + test_fail +fi
Signature · 1 line
2.54.0
Re: [PAHOLE v5 1/5] btf_loader: Handle decl tag component_idx for parameters
In reply to Vineet GuptaQuoted 9 lines · Vineet Gupta
From: Alan Maguire <[email protected]>
A
BTF_KIND_DECL_TAGwith a non-negativecomponent_idxapplies to a specific function parameter (or struct/union member), not to the function itself.btf_loader.chowever attached every decl tag to the type named bybtf_type->type, so parameter decl tags were recorded on the function rather than on the parameter, and pfunct never printed them with the parameter.
Quoted 8 lines
Resolve a non-negative
component_idxto the corresponding parameter via new helpers ftype__parameter()/function__parameter(), and attach the tag there. Teach the pretty printer to emit a parameter's attributes by factoring the function-level attribute loop intotag__attributes_fprintf()and calling it fromftype__fprintf_parms()for each parameter.Signed-off-by Alan Maguire <[email protected]>Signed-off-by Vineet Gupta <[email protected]>
With one nit:
(Also feel free to keep the tags for the other 3 patches since the changes are minimal).
</SNIP>
Quoted 6 lines
btf_loader.c +6
-0+if (component_idx >=0 ) { +struct tag *func_tag =cu__function (cu, tp->type); + +if (func_tag !=NULL ) { + tag =function__parameter (tag__function (func_tag), cu, + component_idx);
btf_loader.c static struct attributes *attributes__realloc(struct attributes *attributes, con · line 530
Quoted 10 lines
btf_loader.c +9
-0+if (tag ==NULL ) { +fprintf (stderr,"WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n" , + component_idx, tp->type); +return 0 ; + } + } + } + +if (tag ==NULL && component_idx <0 ) tag =cu__function (cu, tp->type);
Nit, I think this can be simplified as follows:
tag = cu__function(cu, tp->type);
if (component_idx >= 0 && tag != NULL) {
tag = function__parameter(tag__function(tag), cu, component_idx);
if (tag == NULL) {
fprintf(stderr, "WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n",
component_idx, tp->type);
return 0;
}
}<SNIP>
Re: [PAHOLE v5 5/5] tests: Add btf_type_tag ordering test
In reply to Vineet GuptaQuoted 13 lines · Vineet Gupta
From: Alan Maguire <[email protected]>
Add a test that compiles a pointer carrying two
btf_type_tags(__tag(outer)__tag(inner)) and checks the BTF that pahole emits to ensure the tag chain is PTR ->TYPE_TAGinner ->TYPE_TAGouter -> struct sample, i.e. the innermost tag is closest to the pointer.This exercises the
type_tagordering for both encodings: LLVM emits the annotations as child DIEs in source order (reversed when building the tag list), while GCC chains them viaDW_AT_GNU_annotationalready in BTF order. The test runs with gcc and clang when they supportbtf_type_tag, and is skipped when bpftool is unavailable.
Quoted 3 lines
Signed-off-by Alan Maguire <[email protected]>Signed-off-by Vineet Gupta <[email protected]>---
Quoted 189 lines
tests/btf_type_tag_order.sh | 179 ++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100755 tests/btf_type_tag_order.shtests/btf_type_tag_order.sh new file +179
-0@@ -0,0 +1,179 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +# Check that pahole preserves btf_type_tag order when emitting BTF from DWARF. + +source test_lib.sh + +outdir=$(make_tmpdir) + +# Comment this out to save test data. +trap cleanup EXIT + +title_log "Check BTF type tag order." + +GCC=${GCC:-gcc} +CLANG=${CLANG:-clang} +PAHOLE=${PAHOLE:-pahole} +BPFTOOL=${BPFTOOL:-bpftool} + +if ! command -v "$BPFTOOL" > /dev/null; then + info_log "skip: bpftool not available" + test_skip +fi + +compiler_has_btf_type_tag() +{ + local compiler=$1 + + if ! command -v "$compiler" > /dev/null; then + return 1 + fi + + "$compiler" -x c -E -P - <<'EOF' 2>/dev/null | grep -qx 1 +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#if __has_attribute(btf_type_tag) +1 +#else +0 +#endif +EOF +} + +use_gcc=0 +if compiler_has_btf_type_tag "$GCC"; then + use_gcc=1 +fi + +use_clang=0 +if compiler_has_btf_type_tag "$CLANG"; then + use_clang=1 +fi + +if [ "$use_gcc" -eq 0 ] && [ "$use_clang" -eq 0 ]; then + error_log "Need gcc or clang with btf_type_tag support for test $0" + test_fail +fi + +src=$(cat <<EOF +#define __tag(x) __attribute__((btf_type_tag(#x))) + +struct sample { + int value; +}; + +struct sample __tag(outer) __tag(inner) *global_ptr; + +EOF +) + +check_type_tag_order() +{ + local btf=$1 + local dump + + if ! dump=$("$BPFTOOL" btf dump file "$btf"); then + return 1 + fi + + printf '%s\n' "$dump" | awk ' + function parse_id(line, m) { + if (match(line, /^\[([0-9]+)\]/, m)) + return m[1] + return 0 + } + function parse_name(line, m) { + if (match(line, /\047([^\047]*)\047/, m)) + return m[1] + return "" + } + function parse_type(line, m) { + if (match(line, /type_id=([0-9]+)/, m)) + return m[1] + return 0 + } + function check_ptr(ptr, id, tags, seen) { + id = type[ptr] + while (id != 0 && !seen[id]) { + seen[id] = 1 + if (kind[id] == "TYPE_TAG") { + tags = tags (tags == "" ? "" : " -> ") name[id] + id = type[id] + continue + } + if (kind[id] == "STRUCT" && name[id] == "sample") { + if (tags == "inner -> outer") + exit 0 + candidates = candidates (candidates == "" ? "" : ", ") tags + } + return + } + } + /^\[[0-9]+\]/ { + id = parse_id($0) + kind[id] = $2 + name[id] = parse_name($0) + type[id] = parse_type($0) + if (kind[id] == "PTR") + ptrs[++nr_ptrs] = id + } + END { + for (i = 1; i <= nr_ptrs; i++) + check_ptr(ptrs[i]) + if (candidates != "") { + print "type tag order mismatch; expected inner -> outer, found " candidates > "/dev/stderr" + exit 1 + } + print "could not find tagged pointer to struct sample" > "/dev/stderr" + exit 1 + }' +} + +run_test() +{ + local compiler=$1 + local tmpobj=$2 + local btf=$3 + + info_log "Testing with $compiler" + + if ! echo "$src" | "$compiler" -g -c -x c -o "$tmpobj" - 2>/dev/null; then + error_log "Could not compile type tag order test with $compiler" + return 1 + fi + + if ! "$PAHOLE" --btf_features=+type_tag --btf_encode_detached="$btf" "$tmpobj" 2>/dev/null; then + error_log "Could not encode BTF for $tmpobj" + return 1 + fi + + if check_type_tag_order "$btf"; then + info_log " passed" + return 0 + fi + + error_log "BTF type tag order does not match expected order ($compiler)" + return 1 +} + +failed=0 + +if [ "$use_gcc" -eq 1 ]; then + tmpobj=$(make_tmpobj) + btf=${tmpobj%.o}.btf + run_test "$GCC" "$tmpobj" "$btf" || failed=1 +fi + +if [ "$use_clang" -eq 1 ]; then + tmpobj=$(make_tmpobj) + btf=${tmpobj%.o}.btf + run_test "$CLANG" "$tmpobj" "$btf" || failed=1 +fi + +if [ "$failed" -eq 0 ]; then + test_pass +else + test_fail +fi
Arnaldo Carvalho de Melo
Acked-byRe: [PAHOLE v5 5/5] tests: Add btf_type_tag ordering test
Quoted 14 lines · Emil Tsalapatis
Quoted 13 lines · Vineet Gupta
From: Alan Maguire <[email protected]>
Add a test that compiles a pointer carrying two
btf_type_tags(__tag(outer)__tag(inner)) and checks the BTF that pahole emits to ensure the tag chain is PTR ->TYPE_TAGinner ->TYPE_TAGouter -> struct sample, i.e. the innermost tag is closest to the pointer.This exercises the
type_tagordering for both encodings: LLVM emits the annotations as child DIEs in source order (reversed when building the tag list), while GCC chains them viaDW_AT_GNU_annotationalready in BTF order. The test runs with gcc and clang when they supportbtf_type_tag, and is skipped when bpftool is unavailable.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Alan Maguire <[email protected]>Signed-off-by Vineet Gupta <[email protected]>---
Reviewed-by Emil Tsalapatis <[email protected]>
- Arnaldo
Quoted 189 lines
Quoted 189 lines
tests/btf_type_tag_order.sh | 179 ++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100755 tests/btf_type_tag_order.shtests/btf_type_tag_order.sh new file +179
-0@@ -0,0 +1,179 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +# Check that pahole preserves btf_type_tag order when emitting BTF from DWARF. + +source test_lib.sh + +outdir=$(make_tmpdir) + +# Comment this out to save test data. +trap cleanup EXIT + +title_log "Check BTF type tag order." + +GCC=${GCC:-gcc} +CLANG=${CLANG:-clang} +PAHOLE=${PAHOLE:-pahole} +BPFTOOL=${BPFTOOL:-bpftool} + +if ! command -v "$BPFTOOL" > /dev/null; then + info_log "skip: bpftool not available" + test_skip +fi + +compiler_has_btf_type_tag() +{ + local compiler=$1 + + if ! command -v "$compiler" > /dev/null; then + return 1 + fi + + "$compiler" -x c -E -P - <<'EOF' 2>/dev/null | grep -qx 1 +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#if __has_attribute(btf_type_tag) +1 +#else +0 +#endif +EOF +} + +use_gcc=0 +if compiler_has_btf_type_tag "$GCC"; then + use_gcc=1 +fi + +use_clang=0 +if compiler_has_btf_type_tag "$CLANG"; then + use_clang=1 +fi + +if [ "$use_gcc" -eq 0 ] && [ "$use_clang" -eq 0 ]; then + error_log "Need gcc or clang with btf_type_tag support for test $0" + test_fail +fi + +src=$(cat <<EOF +#define __tag(x) __attribute__((btf_type_tag(#x))) + +struct sample { + int value; +}; + +struct sample __tag(outer) __tag(inner) *global_ptr; + +EOF +) + +check_type_tag_order() +{ + local btf=$1 + local dump + + if ! dump=$("$BPFTOOL" btf dump file "$btf"); then + return 1 + fi + + printf '%s\n' "$dump" | awk ' + function parse_id(line, m) { + if (match(line, /^\[([0-9]+)\]/, m)) + return m[1] + return 0 + } + function parse_name(line, m) { + if (match(line, /\047([^\047]*)\047/, m)) + return m[1] + return "" + } + function parse_type(line, m) { + if (match(line, /type_id=([0-9]+)/, m)) + return m[1] + return 0 + } + function check_ptr(ptr, id, tags, seen) { + id = type[ptr] + while (id != 0 && !seen[id]) { + seen[id] = 1 + if (kind[id] == "TYPE_TAG") { + tags = tags (tags == "" ? "" : " -> ") name[id] + id = type[id] + continue + } + if (kind[id] == "STRUCT" && name[id] == "sample") { + if (tags == "inner -> outer") + exit 0 + candidates = candidates (candidates == "" ? "" : ", ") tags + } + return + } + } + /^\[[0-9]+\]/ { + id = parse_id($0) + kind[id] = $2 + name[id] = parse_name($0) + type[id] = parse_type($0) + if (kind[id] == "PTR") + ptrs[++nr_ptrs] = id + } + END { + for (i = 1; i <= nr_ptrs; i++) + check_ptr(ptrs[i]) + if (candidates != "") { + print "type tag order mismatch; expected inner -> outer, found " candidates > "/dev/stderr" + exit 1 + } + print "could not find tagged pointer to struct sample" > "/dev/stderr" + exit 1 + }' +} + +run_test() +{ + local compiler=$1 + local tmpobj=$2 + local btf=$3 + + info_log "Testing with $compiler" + + if ! echo "$src" | "$compiler" -g -c -x c -o "$tmpobj" - 2>/dev/null; then + error_log "Could not compile type tag order test with $compiler" + return 1 + fi + + if ! "$PAHOLE" --btf_features=+type_tag --btf_encode_detached="$btf" "$tmpobj" 2>/dev/null; then + error_log "Could not encode BTF for $tmpobj" + return 1 + fi + + if check_type_tag_order "$btf"; then + info_log " passed" + return 0 + fi + + error_log "BTF type tag order does not match expected order ($compiler)" + return 1 +} + +failed=0 + +if [ "$use_gcc" -eq 1 ]; then + tmpobj=$(make_tmpobj) + btf=${tmpobj%.o}.btf + run_test "$GCC" "$tmpobj" "$btf" || failed=1 +fi + +if [ "$use_clang" -eq 1 ]; then + tmpobj=$(make_tmpobj) + btf=${tmpobj%.o}.btf + run_test "$CLANG" "$tmpobj" "$btf" || failed=1 +fi + +if [ "$failed" -eq 0 ]; then + test_pass +else + test_fail +fi
Arnaldo Carvalho de Melo
Acked-byRe: [PAHOLE v5 1/5] btf_loader: Handle decl tag component_idx for parameters
In reply to Emil TsalapatisQuoted 48 lines · Emil Tsalapatis
Quoted 9 lines · Vineet Gupta
From: Alan Maguire <[email protected]>
A
BTF_KIND_DECL_TAGwith a non-negativecomponent_idxapplies to a specific function parameter (or struct/union member), not to the function itself.btf_loader.chowever attached every decl tag to the type named bybtf_type->type, so parameter decl tags were recorded on the function rather than on the parameter, and pfunct never printed them with the parameter.Quoted 8 lines
Resolve a non-negative
component_idxto the corresponding parameter via new helpers ftype__parameter()/function__parameter(), and attach the tag there. Teach the pretty printer to emit a parameter's attributes by factoring the function-level attribute loop intotag__attributes_fprintf()and calling it fromftype__fprintf_parms()for each parameter.Signed-off-by Alan Maguire <[email protected]>Signed-off-by Vineet Gupta <[email protected]>With one nit:
Reviewed-by Emil Tsalapatis <[email protected]>(Also feel free to keep the tags for the other 3 patches since the changes are minimal).
</SNIP>
Quoted 6 lines
btf_loader.c +6
-0+if (component_idx >=0 ) { +struct tag *func_tag =cu__function (cu, tp->type); + +if (func_tag !=NULL ) { + tag =function__parameter (tag__function (func_tag), cu, + component_idx);btf_loader.c static struct attributes *attributes__realloc(struct attributes *attributes, con · line 530
Quoted 10 lines
btf_loader.c +9
-0+if (tag ==NULL ) { +fprintf (stderr,"WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n" , + component_idx, tp->type); +return 0 ; + } + } + } + +if (tag ==NULL && component_idx <0 ) tag =cu__function (cu, tp->type);Nit, I think this can be simplified as follows:
tag =
cu__function(cu, tp->type);
Quoted 8 lines
if (component_idx >= 0 && tag != NULL) {
tag = function__parameter(tag__function(tag), cu, component_idx);
if (tag == NULL) {
fprintf(stderr, "WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n",
component_idx, tp->type);
return 0;
}
}Agreed, and with that:
- Arnaldo
Re: [PAHOLE v5 1/5] btf_loader: Handle decl tag component_idx for parameters
In reply to Emil TsalapatisQuoted 57 lines · Emil Tsalapatis
Quoted 9 lines · Vineet Gupta
From: Alan Maguire <[email protected]>
A
BTF_KIND_DECL_TAGwith a non-negativecomponent_idxapplies to a specific function parameter (or struct/union member), not to the function itself.btf_loader.chowever attached every decl tag to the type named bybtf_type->type, so parameter decl tags were recorded on the function rather than on the parameter, and pfunct never printed them with the parameter.Quoted 8 lines
Resolve a non-negative
component_idxto the corresponding parameter via new helpers ftype__parameter()/function__parameter(), and attach the tag there. Teach the pretty printer to emit a parameter's attributes by factoring the function-level attribute loop intotag__attributes_fprintf()and calling it fromftype__fprintf_parms()for each parameter.Signed-off-by Alan Maguire <[email protected]>Signed-off-by Vineet Gupta <[email protected]>With one nit:
Reviewed-by Emil Tsalapatis <[email protected]>(Also feel free to keep the tags for the other 3 patches since the changes are minimal).
</SNIP>
Quoted 6 lines
btf_loader.c +6
-0+if (component_idx >=0 ) { +struct tag *func_tag =cu__function (cu, tp->type); + +if (func_tag !=NULL ) { + tag =function__parameter (tag__function (func_tag), cu, + component_idx);btf_loader.c static struct attributes *attributes__realloc(struct attributes *attributes, con · line 530
Quoted 10 lines
btf_loader.c +9
-0+if (tag ==NULL ) { +fprintf (stderr,"WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n" , + component_idx, tp->type); +return 0 ; + } + } + } + +if (tag ==NULL && component_idx <0 ) tag =cu__function (cu, tp->type);Nit, I think this can be simplified as follows:
tag =
cu__function(cu, tp->type);if (component_idx >= 0 && tag != NULL) { tag = function__parameter(tag__function(tag), cu, component_idx); if (tag == NULL) { fprintf(stderr, "WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n", component_idx, tp->type); return 0; } }
Quoted 1 line
<SNIP>
yep, that looks good to me. if there are no other issues arising from this round and Vineet is happy with that change I can roll it in when landing this to save having to roll a v6.
One other issue; we need to install bpftool for CI. I'm working on a change to support this (installing the version from the kernel tree), I'll try and get this in place ASAP. Thanks!
Re: [PAHOLE v5 1/5] btf_loader: Handle decl tag component_idx for parameters
Quoted 56 lines · Alan Maguire
Quoted 55 lines · Emil Tsalapatis
Quoted 9 lines · Vineet Gupta
From: Alan Maguire <[email protected]>
A
BTF_KIND_DECL_TAGwith a non-negativecomponent_idxapplies to a specific function parameter (or struct/union member), not to the function itself.btf_loader.chowever attached every decl tag to the type named bybtf_type->type, so parameter decl tags were recorded on the function rather than on the parameter, and pfunct never printed them with the parameter.Quoted 8 lines
Resolve a non-negative
component_idxto the corresponding parameter via new helpers ftype__parameter()/function__parameter(), and attach the tag there. Teach the pretty printer to emit a parameter's attributes by factoring the function-level attribute loop intotag__attributes_fprintf()and calling it fromftype__fprintf_parms()for each parameter.Signed-off-by Alan Maguire <[email protected]>Signed-off-by Vineet Gupta <[email protected]>With one nit:
Reviewed-by Emil Tsalapatis <[email protected]>(Also feel free to keep the tags for the other 3 patches since the changes are minimal).
</SNIP>
Quoted 6 lines
btf_loader.c +6
-0+if (component_idx >=0 ) { +struct tag *func_tag =cu__function (cu, tp->type); + +if (func_tag !=NULL ) { + tag =function__parameter (tag__function (func_tag), cu, + component_idx);btf_loader.c static struct attributes *attributes__realloc(struct attributes *attributes, con · line 530
Quoted 10 lines
btf_loader.c +9
-0+if (tag ==NULL ) { +fprintf (stderr,"WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n" , + component_idx, tp->type); +return 0 ; + } + } + } + +if (tag ==NULL && component_idx <0 ) tag =cu__function (cu, tp->type);Nit, I think this can be simplified as follows:
tag =
cu__function(cu, tp->type);if (component_idx >= 0 && tag != NULL) { tag = function__parameter(tag__function(tag), cu, component_idx); if (tag == NULL) { fprintf(stderr, "WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n", component_idx, tp->type); return 0; } }
Quoted 4 lines
Quoted 1 line
<SNIP>
yep, that looks good to me. if there are no other issues arising from this round and Vineet is happy with that change I can roll it in when landing this to save having to roll a v6.
Cool, works for me and and indeed it will be nice to avoid a v6 :-)
Thx,
-Vineet
Quoted 4 lines
One other issue; we need to install bpftool for CI. I'm working on a change to support this (installing the version from the kernel tree), I'll try and get this in place ASAP. Thanks!
Quoted 5 lines · Vineet Gupta
Hi,
This series handles gcc generated
DW_TAG_GNU_annotationwith the end goal to finally enableCONFIG_PAHOLE_HAS_BTF_TAGfor gcc kerenel builds.
Quoted 9 lines
Patches 1/5 and 5/5 are newly introduced in v5 per Alan's ask.
P.S.: I've optimistically included Reviewed-by/Acked-by from Emil and Yonghong respectively on v4 [4] but those were before additional changes in v5 from Alan for a few things. Please let me know if that's no longer true.
series applied, along with CI change to support [1]. Thank you!
Alan
[1] https://lore.kernel.org/dwarves/[email protected]/T/#r0d979ca6aa79a4586b75223ec51a54e7be1d74f8
Quoted 23 lines
Thx,
-VineetAlan Maguire (2):
btf_loader: Handle decl tagcomponent_idxfor parameters
tests: Addbtf_type_tagordering testVineet Gupta (3):
dwarf_loader: Extractdie__add_btf_type_tag()helper [NFC]
dwarf_loader: Add support forDW_TAG_GNU_annotation
tests: Support GCC in pfunct-btf-decl-tags testbtf_encoder.c | 1 + btf_loader.c | 46 ++++++++- dutil.h | 11 ++ dwarf_loader.c | 185 +++++++++++++++++++++++++++------- dwarves.h | 2 +- dwarves_fprintf.c | 32 ++++-- tests/btf_type_tag_order.sh | 179 ++++++++++++++++++++++++++++++++ tests/pfunct-btf-decl-tags.sh | 93 ++++++++++++----- 8 files changed, 478 insertions(+), 71 deletions(-) create mode 100755 tests/btf_type_tag_order.sh
Hi Alan,
Quoted 8 lines · Alan Maguire
Quoted 7 lines · Vineet Gupta
Hi,
This series handles gcc generated
DW_TAG_GNU_annotationwith the end goal to finally enableCONFIG_PAHOLE_HAS_BTF_TAGfor gcc kerenel builds.Patches 1/5 and 5/5 are newly introduced in v5 per Alan's ask.
Quoted 8 lines
Quoted 7 lines
P.S.: I've optimistically included Reviewed-by/Acked-by from Emil and Yonghong respectively on v4 [4] but those were before additional changes in v5 from Alan for a few things. Please let me know if that's no longer true.series applied, along with CI change to support [1]. Thank you!
Thanks for quickly merging this. I now need to plumb this thru on the kernel side to essentially enable CONFIG_PAHOLE_HAS_BTF_TAG for gcc but that would need to be keyed off of a pahole release version. Is pahole due for a release (cadence and/or this changeset). If not I can speculative use the next version whenever that happens. There are other things in flight as well (gcc fix after 16.1) so this is not super urgent but will be good to get out of the way.
Thx,
-Vineet
Quoted 29 lines
Alan
[1] https://lore.kernel.org/dwarves/[email protected]/T/#r0d979ca6aa79a4586b75223ec51a54e7be1d74f8
Quoted 23 lines
Thx,
-VineetAlan Maguire (2):
btf_loader: Handle decl tagcomponent_idxfor parameters
tests: Addbtf_type_tagordering testVineet Gupta (3):
dwarf_loader: Extractdie__add_btf_type_tag()helper [NFC]
dwarf_loader: Add support forDW_TAG_GNU_annotation
tests: Support GCC in pfunct-btf-decl-tags testbtf_encoder.c | 1 + btf_loader.c | 46 ++++++++- dutil.h | 11 ++ dwarf_loader.c | 185 +++++++++++++++++++++++++++------- dwarves.h | 2 +- dwarves_fprintf.c | 32 ++++-- tests/btf_type_tag_order.sh | 179 ++++++++++++++++++++++++++++++++ tests/pfunct-btf-decl-tags.sh | 93 ++++++++++++----- 8 files changed, 478 insertions(+), 71 deletions(-)create mode 100755
tests/btf_type_tag_order.sh
Quoted 16 lines · Vineet Gupta
Hi Alan,
Quoted 13 lines · Alan Maguire
Quoted 12 lines · Vineet Gupta
Hi,
This series handles gcc generated
DW_TAG_GNU_annotationwith the end goal to finally enableCONFIG_PAHOLE_HAS_BTF_TAGfor gcc kerenel builds.Patches 1/5 and 5/5 are newly introduced in v5 per Alan's ask.
P.S.: I've optimistically included Reviewed-by/Acked-by from Emil and Yonghong respectively on v4 [4] but those were before additional changes in v5 from Alan for a few things. Please let me know if that's no longer true.
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
series applied, along with CI change to support [1]. Thank you!
Thanks for quickly merging this. I now need to plumb this thru on the kernel side to essentially enable
CONFIG_PAHOLE_HAS_BTF_TAGfor gcc but that would need to be keyed off of a pahole release version. Is pahole due for a release (cadence and/or this changeset). If not I can speculative use the next version whenever that happens. There are other things in flight as well (gcc fix after 16.1) so this is not super urgent but will be good to get out of the way.
hi Vineet, we will likely spin a 1.32 soon. I'm hoping to get Yonghong's true signature work in, and my inline stuff is close (but is now rebuilt to use some of the true signature changes so is gated on it), but we don't strictly need to wait on the inline work landing.
Given PTO etc I would say we could aim for a 1.32 release in mid-July; does that work from your side? Thanks!
Alan
Quoted 20 lines · Alan Maguire
Quoted 19 lines · Vineet Gupta
Hi Alan,
Quoted 16 lines · Alan Maguire
Quoted 5 lines · Vineet Gupta
Hi,
This series handles gcc generated
DW_TAG_GNU_annotationwith the end goal to finally enableCONFIG_PAHOLE_HAS_BTF_TAGfor gcc kerenel builds.Quoted 9 lines
Patches 1/5 and 5/5 are newly introduced in v5 per Alan's ask.
P.S.: I've optimistically included Reviewed-by/Acked-by from Emil and Yonghong respectively on v4 [4] but those were before additional changes in v5 from Alan for a few things. Please let me know if that's no longer true.series applied, along with CI change to support [1]. Thank you!
Quoted 8 lines
Quoted 2 lines
Thanks for quickly merging this. I now need to plumb this thru on the kernel side to essentially enable
CONFIG_PAHOLE_HAS_BTF_TAGfor gcc but that would need to be keyed off of a pahole release version. Is pahole due for a release (cadence and/or this changeset). If not I can speculative use the next version whenever that happens. There are other things in flight as well (gcc fix after 16.1) so this is not super urgent but will be good to get out of the way.hi Vineet, we will likely spin a 1.32 soon. I'm hoping to get Yonghong's true signature work in, and my inline stuff is close (but is now rebuilt to use some of the true signature changes so is gated on it), but we don't strictly need to wait on the inline work landing.
Given PTO etc I would say we could aim for a 1.32 release in mid-July; does that work from your side? Thanks!
Yeah this seems reasonable.
Thx,
-Vineet