Skip to contentSkip to conversation

btf_encoder: filter var names before btf name check

PATCH In review Alan Maguire 4 participants 5 messages Oct 18, 2024 – Oct 23, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btf_encoder: filter var names before btf name check

...as this means we avoid seeing multiple messages of the form

PAHOLE: Warning: Found invalid variable name when encoding btf, ignored (sym: '__UNIQUE_ID___addressable__RNvXsa_NtCs2vSfyxKMEZc_4core4charNtB5_11EscapeDebugNtNtNtNtB7_4iter6traits10exact_size17ExactSizeIterator3len57').

Such symbols are filtered anyway due to the __UNIQUE_ID prefix, so warning about them is not necessary; simply reordering the checks should ensure we will not see these warnings.

---
 btf_encoder.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
btf_encoder.c +3 -3
index 5954238..e507e60 100644
@@ -2241,6 +2241,9 @@ static int btf_encoder__encode_cu_variables(struct btf_encoder *encoder)
 		if (!name)
 			continue;
 
+		if (filter_variable_name(name))
+			continue;
+
 		/* Check for invalid BTF names */
 		if (!btf_name_valid(name)) {
 			dump_invalid_symbol("Found invalid variable name when encoding btf",
@@ -2251,9 +2254,6 @@ static int btf_encoder__encode_cu_variables(struct btf_encoder *encoder)
 				return -1;
 		}
 
-		if (filter_variable_name(name))
-			continue;
-
 		if (var->ip.tag.type == 0) {
 			fprintf(stderr, "error: found variable '%s' in CU '%s' that has void type\n",
 				name, cu->name);
Signature · 1 line
2.43.5
Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · Alan Maguire

...as this means we avoid seeing multiple messages of the form

PAHOLE: Warning: Found invalid variable name when encoding btf, ignored (sym: '__UNIQUE_ID___addressable__RNvXsa_NtCs2vSfyxKMEZc_4core4charNtB5_11EscapeDebugNtNtNtNtB7_4iter6traits10exact_size17ExactSizeIterator3len57').

Such symbols are filtered anyway due to the __UNIQUE_ID prefix, so warning about them is not necessary; simply reordering the checks should ensure we will not see these warnings.

FWIW, I applied the patch and the __UNIQUE_ID warnings indeed go away (but I don't know if those warnings would be useful to see/fix for other reasons):

Cheers,
Miguel

#2 lore raw
Quoted 10 lines · Miguel Ojeda
Quoted 9 lines · Alan Maguire

...as this means we avoid seeing multiple messages of the form

PAHOLE: Warning: Found invalid variable name when encoding btf, ignored (sym: '__UNIQUE_ID___addressable__RNvXsa_NtCs2vSfyxKMEZc_4core4charNtB5_11EscapeDebugNtNtNtNtB7_4iter6traits10exact_size17ExactSizeIterator3len57').

Such symbols are filtered anyway due to the __UNIQUE_ID prefix, so warning about them is not necessary; simply reordering the checks should ensure we will not see these warnings.

Quoted 6 lines
Quoted 2 lines

FWIW, I applied the patch and the __UNIQUE_ID warnings indeed go away (but I don't know if those warnings would be useful to see/fix for other reasons):

Maybe we should have a debug mode where anything that is skipped gets reported.

Quoted 1 line

Thanks, since this hasn't hit 'master' yet, I added it to the cset,

- Arnaldo

Reviewed-by on v1 1/1
#3 lore raw
In reply to Alan Maguire
Quoted 3 lines · Alan Maguire

...as this means we avoid seeing multiple messages of the form

PAHOLE: Warning: Found invalid variable name when encoding btf, ignored (sym: '__UNIQUE_ID___addressable__RNvXsa_NtCs2vSfyxKMEZc_4core4charNtB5_11EscapeDebugNtNtNtNtB7_4iter6traits10exact_size17ExactSizeIterator3len57').

a beautiful variable name :P

Quoted 6 lines

Such symbols are filtered anyway due to the __UNIQUE_ID prefix, so warning about them is not necessary; simply reordering the checks should ensure we will not see these warnings.

Sorry I'm late to review. This is a good catch and is clearly correct to me.

Quoted 30 lines
---
 btf_encoder.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
btf_encoder.c +3 -3
index 5954238..e507e60 100644
@@ -2241,6 +2241,9 @@ static int btf_encoder__encode_cu_variables(struct btf_encoder *encoder)
 		if (!name)
 			continue;
 
+		if (filter_variable_name(name))
+			continue;
+
 		/* Check for invalid BTF names */
 		if (!btf_name_valid(name)) {
 			dump_invalid_symbol("Found invalid variable name when encoding btf",
@@ -2251,9 +2254,6 @@ static int btf_encoder__encode_cu_variables(struct btf_encoder *encoder)
 				return -1;
 		}
 
-		if (filter_variable_name(name))
-			continue;
-
 		if (var->ip.tag.type == 0) {
 			fprintf(stderr, "error: found variable '%s' in CU '%s' that has void type\n",
 				name, cu->name);
Signature · 1 line
2.43.5
#4 lore raw
Quoted 6 lines · Stephen Brennan
Quoted 3 lines · Alan Maguire

...as this means we avoid seeing multiple messages of the form

PAHOLE: Warning: Found invalid variable name when encoding btf, ignored (sym: '__UNIQUE_ID___addressable__RNvXsa_NtCs2vSfyxKMEZc_4core4charNtB5_11EscapeDebugNtNtNtNtB7_4iter6traits10exact_size17ExactSizeIterator3len57').

a beautiful variable name :P

A unique one :-)

Quoted 9 lines
Quoted 6 lines

Such symbols are filtered anyway due to the __UNIQUE_ID prefix, so warning about them is not necessary; simply reordering the checks should ensure we will not see these warnings.

Sorry I'm late to review. This is a good catch and is clearly correct to me.

Thanks, since it hasn't moved to master, I'm adding it.

Quoted 1 line

- Arnaldo