pahole: Don't fail when encoding BTF on an object with no DWARF info
PATCH 1/1 pahole: Don't fail when encoding BTF on an object with no DWARF info
If pahole is asked to encode BTF for a file with no DWARF info, don't fail, just skip it.
This is the case, for instance, in this file in a kernel build with DWARF info generation enabled:
$ pahole ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o libbpf: failed to find '.BTF' ELF section in ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o pahole: file '../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o' has no supported type information. $
Before it was failing when encoding BTF for it, now:
$ pahole --btf_encode ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o $ echo $? 0 $
--- pahole.c | 7 +++++++ 1 file changed, 7 insertions(+)
pahole.c +7 -0
@@ -3659,6 +3659,13 @@ try_sole_arg_as_class_names: remaining = argc; goto try_sole_arg_as_class_names; } + +if (btf_encode || ctf_encode) { +// If encoding is asked for and there is no DEBUG info to encode from, +// there are no errors, continue... + goto out_ok; + } +if (argv[remaining] !=NULL ) {cus__fprintf_load_files_err (cus,"pahole" , argv + remaining, err, stderr); }else {
Signature · 1 line
2.49.0
Quoted 11 lines · Arnaldo Carvalho de Melo
If pahole is asked to encode BTF for a file with no DWARF info, don't fail, just skip it.
This is the case, for instance, in this file in a kernel build with DWARF info generation enabled:
$ pahole ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o libbpf: failed to find '.BTF' ELF section in ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o pahole: file '../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o' has no supported type information. $
Quoted 8 lines
Before it was failing when encoding BTF for it, now:
$ pahole --btf_encode ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o $ echo $? 0 $Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Only potential issue I can see is that in the usual case of encoding BTF from DWARF in the kernel we'd probably like to fall over if we can't encode BTF due to DWARF absence. However current Kconfig dependencies of CONFIG_DEBUG_INFO_BTF mean this can't happen in practice I think so
Quoted 22 lines
--- pahole.c | 7 +++++++ 1 file changed, 7 insertions(+)pahole.c +7
-0@@ -3659,6 +3659,13 @@ try_sole_arg_as_class_names: remaining = argc; goto try_sole_arg_as_class_names; } + +if (btf_encode || ctf_encode) { +// If encoding is asked for and there is no DEBUG info to encode from, +// there are no errors, continue... + goto out_ok; + } +if (argv[remaining] !=NULL ) {cus__fprintf_load_files_err (cus,"pahole" , argv + remaining, err, stderr); }else {
Quoted 19 lines · Alan Maguire
Quoted 17 lines · Arnaldo Carvalho de Melo
If pahole is asked to encode BTF for a file with no DWARF info, don't fail, just skip it.
This is the case, for instance, in this file in a kernel build with DWARF info generation enabled:
$ pahole ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o libbpf: failed to find '.BTF' ELF section in ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o pahole: file '../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o' has no supported type information. $Before it was failing when encoding BTF for it, now:
$ pahole --btf_encode ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o $ echo $? 0 $
Quoted 6 lines
Quoted 1 line
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>Only potential issue I can see is that in the usual case of encoding BTF from DWARF in the kernel we'd probably like to fall over if we can't encode BTF due to DWARF absence. However current
Kconfigdependencies ofCONFIG_DEBUG_INFO_BTFmean this can't happen in practice I think so
Right, this is an exception, just some .o files out of thousands end up without DWARF.
So I think that if we take --btf_encode as "Encode BTF from DWARF, if DWARF is available" is a good interpretation of intent.
- Arnaldo
Quoted 1 line
Reviewed-by Alan Maguire <[email protected]>
Thanks!
- Arnaldo
Quoted 22 lines
Quoted 22 lines
--- pahole.c | 7 +++++++ 1 file changed, 7 insertions(+)pahole.c +7
-0@@ -3659,6 +3659,13 @@ try_sole_arg_as_class_names: remaining = argc; goto try_sole_arg_as_class_names; } + +if (btf_encode || ctf_encode) { +// If encoding is asked for and there is no DEBUG info to encode from, +// there are no errors, continue... + goto out_ok; + } +if (argv[remaining] !=NULL ) {cus__fprintf_load_files_err (cus,"pahole" , argv + remaining, err, stderr); }else {
Alan Maguire
AppliedQuoted 30 lines · Arnaldo Carvalho de Melo
Quoted 19 lines · Alan Maguire
Quoted 17 lines · Arnaldo Carvalho de Melo
If pahole is asked to encode BTF for a file with no DWARF info, don't fail, just skip it.
This is the case, for instance, in this file in a kernel build with DWARF info generation enabled:
$ pahole ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o libbpf: failed to find '.BTF' ELF section in ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o pahole: file '../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o' has no supported type information. $Before it was failing when encoding BTF for it, now:
$ pahole --btf_encode ../build/v6.15.0-rc4+/arch/x86/purgatory/purgatory.o $ echo $? 0 $Quoted 6 lines
Quoted 1 line
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>Only potential issue I can see is that in the usual case of encoding BTF from DWARF in the kernel we'd probably like to fall over if we can't encode BTF due to DWARF absence. However current
Kconfigdependencies ofCONFIG_DEBUG_INFO_BTFmean this can't happen in practice I think soRight, this is an exception, just some .o files out of thousands end up without DWARF.
Quoted 9 lines
So I think that if we take --btf_encode as "Encode BTF from DWARF, if DWARF is available" is a good interpretation of intent.
- Arnaldo
Quoted 1 line
Reviewed-by Alan Maguire <[email protected]>Thanks!
Applied to the next branch of
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/
Thanks!
Alan