Skip to contentSkip to conversation

btf_loader: send warnings to stderr

PATCH Applied Alan Maguire 2 participants 5 messages Oct 17, 2024 – Oct 23, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 btf_loader: send warnings to stderr

Among other things, this helps simplify tests/btf_functions.sh.

---
 btf_loader.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
btf_loader.c +4 -3
index c70b67f..4814f29 100644
@@ -449,7 +449,7 @@ static int create_new_tag(struct cu *cu, int type, const struct btf_type *tp, ui
 	case BTF_KIND_TYPE_TAG:	tag->tag = DW_TAG_LLVM_annotation; break;
 	default:
 		free(tag);
-		printf("%s: Unknown type %d\n\n", __func__, type);
+		fprintf(stderr, "%s: Unknown type %d\n\n", __func__, type);
 		return 0;
 	}
 
@@ -470,7 +470,7 @@ static int process_decl_tag(struct cu *cu, const struct btf_type *tp)
 		tag = cu__tag(cu, tp->type);
 
 	if (tag == NULL) {
-		printf("WARNING: BTF_KIND_DECL_TAG for unknown BTF id %d\n", tp->type);
+		fprintf(stderr, "WARNING: BTF_KIND_DECL_TAG for unknown BTF id %d\n", tp->type);
 		return 0;
 	}
 
@@ -478,7 +478,8 @@ static int process_decl_tag(struct cu *cu, const struct btf_type *tp)
 
 	if (tag->attribute != NULL) {
 		char bf[128];
-		printf("WARNING: still unsuported BTF_KIND_DECL_TAG(%s) for %s already with attribute (%s), ignoring\n",
+
+		fprintf(stderr, "WARNING: still unsuported BTF_KIND_DECL_TAG(%s) for %s already with attribute (%s), ignoring\n",
 		       attribute, tag__name(tag, cu, bf, sizeof(bf), NULL), tag->attribute);
 	} else {
 		tag->attribute = attribute;
Signature · 1 line
2.43.5
#1 lore raw

PATCH 2/2 tests/btf_functions: redirect stderr for pfunct --format_path=btf

...since otherwise we will see the following during test execution

WARNING: still unsuported BTF_KIND_DECL_TAG(bpf_fastcall) for bpf_iter_css_task_next already with attribute (bpf_kfunc), ignoring
WARNING: still unsuported BTF_KIND_DECL_TAG(bpf_fastcall) for bpf_iter_bits_new already with attribute (bpf_kfunc), ignoring

---
 tests/btf_functions.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/btf_functions.sh +2 -2
index 5794be9..1a28923 100755
@@ -53,13 +53,13 @@ pahole --btf_features=default --btf_encode_detached=$outdir/vmlinux.btf --verbos
 
 test -n "$VERBOSE" && printf "done.\n"
 
-funcs=$(pfunct --format_path=btf $outdir/vmlinux.btf |sort)
+funcs=$(pfunct --format_path=btf $outdir/vmlinux.btf 2>/dev/null|sort)
 
 # all functions from DWARF; some inline functions are not inlined so include them too
 pfunct --all --no_parm_names --format_path=dwarf $vmlinux | \
 	sort|uniq > $outdir/dwarf.funcs
 # all functions from BTF (removing bpf_kfunc prefix where found)
-pfunct --all --no_parm_names --format_path=btf $outdir/vmlinux.btf |\
+pfunct --all --no_parm_names --format_path=btf $outdir/vmlinux.btf 2>/dev/null|\
 	awk '{ gsub("^bpf_kfunc ",""); print $0}'|sort|uniq > $outdir/btf.funcs
 
 exact=0
Signature · 1 line
2.43.5
#2 lore raw
In reply to Alan Maguire
Quoted 1 line · Alan Maguire

Among other things, this helps simplify tests/btf_functions.sh.

Thanks, applied both patches.

- Arnaldo

Quoted 39 lines
---
 btf_loader.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
btf_loader.c +4 -3
index c70b67f..4814f29 100644
@@ -449,7 +449,7 @@ static int create_new_tag(struct cu *cu, int type, const struct btf_type *tp, ui
 	case BTF_KIND_TYPE_TAG:	tag->tag = DW_TAG_LLVM_annotation; break;
 	default:
 		free(tag);
-		printf("%s: Unknown type %d\n\n", __func__, type);
+		fprintf(stderr, "%s: Unknown type %d\n\n", __func__, type);
 		return 0;
 	}
 
@@ -470,7 +470,7 @@ static int process_decl_tag(struct cu *cu, const struct btf_type *tp)
 		tag = cu__tag(cu, tp->type);
 
 	if (tag == NULL) {
-		printf("WARNING: BTF_KIND_DECL_TAG for unknown BTF id %d\n", tp->type);
+		fprintf(stderr, "WARNING: BTF_KIND_DECL_TAG for unknown BTF id %d\n", tp->type);
 		return 0;
 	}
 
@@ -478,7 +478,8 @@ static int process_decl_tag(struct cu *cu, const struct btf_type *tp)
 
 	if (tag->attribute != NULL) {
 		char bf[128];
-		printf("WARNING: still unsuported BTF_KIND_DECL_TAG(%s) for %s already with attribute (%s), ignoring\n",
+
+		fprintf(stderr, "WARNING: still unsuported BTF_KIND_DECL_TAG(%s) for %s already with attribute (%s), ignoring\n",
 		       attribute, tag__name(tag, cu, bf, sizeof(bf), NULL), tag->attribute);
 	} else {
 		tag->attribute = attribute;
Signature · 1 line
2.43.5
#3 lore raw

hey Arnaldo

Quoted 5 lines · Arnaldo Carvalho de Melo
Quoted 1 line · Alan Maguire

Among other things, this helps simplify tests/btf_functions.sh.

Thanks, applied both patches.

I'm still not seeing those patches in the next tree; is it possible they got lost in the flurry of changes? Thanks!

Alan

Quoted 41 lines

- Arnaldo

Quoted 39 lines
---
 btf_loader.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
btf_loader.c +4 -3
index c70b67f..4814f29 100644
@@ -449,7 +449,7 @@ static int create_new_tag(struct cu *cu, int type, const struct btf_type *tp, ui
 	case BTF_KIND_TYPE_TAG:	tag->tag = DW_TAG_LLVM_annotation; break;
 	default:
 		free(tag);
-		printf("%s: Unknown type %d\n\n", __func__, type);
+		fprintf(stderr, "%s: Unknown type %d\n\n", __func__, type);
 		return 0;
 	}
 
@@ -470,7 +470,7 @@ static int process_decl_tag(struct cu *cu, const struct btf_type *tp)
 		tag = cu__tag(cu, tp->type);
 
 	if (tag == NULL) {
-		printf("WARNING: BTF_KIND_DECL_TAG for unknown BTF id %d\n", tp->type);
+		fprintf(stderr, "WARNING: BTF_KIND_DECL_TAG for unknown BTF id %d\n", tp->type);
 		return 0;
 	}
 
@@ -478,7 +478,8 @@ static int process_decl_tag(struct cu *cu, const struct btf_type *tp)
 
 	if (tag->attribute != NULL) {
 		char bf[128];
-		printf("WARNING: still unsuported BTF_KIND_DECL_TAG(%s) for %s already with attribute (%s), ignoring\n",
+
+		fprintf(stderr, "WARNING: still unsuported BTF_KIND_DECL_TAG(%s) for %s already with attribute (%s), ignoring\n",
 		       attribute, tag__name(tag, cu, bf, sizeof(bf), NULL), tag->attribute);
 	} else {
 		tag->attribute = attribute;
Signature · 1 line
2.43.5
#4 lore raw
Quoted 5 lines · Alan Maguire

hey Arnaldo

On 17/10/2024 21:27, Arnaldo Carvalho de Melo wrote:

Quoted 8 lines
Quoted 5 lines · Alan Maguire
Quoted 1 line

Among other things, this helps simplify tests/btf_functions.sh.

Thanks, applied both patches.

I'm still not seeing those patches in the next tree; is it possible they got lost in the flurry of changes? Thanks!

It was on my office machine:

b77d88003eb53fa1 (HEAD -> master) btf_encoder: Use the ELF_C_READ_MMAP mode with elf_begin() 11b59c00770dbe26 tests/btf_functions: Redirect stderr for pfunct --format_path=btf 0ee47254eae5ae26 btf_loader: Send warnings to stderr
e91433cb3bb5bf58 tests: Use PAHOLE_LANG_EXCLUDE=rust to skip Rust CUs
97f2f7ba05508273 pfunct: Use languages__init() to honour PAHOLE_LANG_EXCLUDE cbb1149c4eaf01b1 languages: Introduce languages__cu_filtered() from pahole's cu__filter() fa7458521b6e421f languages: Use PAHOLE_LANG_EXCLUDE env var if present, as a fallback 1f25386486e4d7b5 languages: Introduce language__init()
8fc09fd3315ce934 core: Adopt the languages__parse(), languages__in() and 'struct languages' from pahole b9a0283d24fe31c5 languages: Start making 'struct languages' a class
⬢ [acme@toolbox pahole]$

I'm doing some tests and pushing it out to next.

- Arnaldo