[PATCH 0/2] Add option for generating BTF types of global variables
From: Stephen Brennan
Date: Thu Feb 06 2025 - 20:21:50 EST
Hello everyone,
These patches add the CONFIG_DEBUG_INFO_BTF_GLOBAL_VARS option, which instructs
pahole to include types of global variables. Pahole >= 1.28 is required. More
context for what this feature enables can be seen in patch 2, as well as the
series which introduced this feature to pahole [1].
To demonstrate the functionality, my "btf_2024" branch of drgn (the current
development branch for the BTF debugging feature, despite the name) can be used
as below to debug a running kernel with these patches enabled.
git clone https://github.com/brenns10/drgn -b btf_2024
cd drgn
python setup.py build_ext -i
sudo python -m drgn --no-default-symbols --btf -k
The "--no-default-symbols" ensures that drgn doesn't accidentially find & use
your DWARF debuginfo :)
The resulting debugging session supports a similar level of capability as drgn
with DWARF debuginfo: variable & function types are available, stack traces may
be unwound (using ORC), and the kallsyms symbol table is available. You can also
try various drgn "contrib" scripts which implement useful utilities. All of the
ones I could readily test are working with BTF, for example:
sudo python -m drgn --no-default-symbols --btf -k contrib/slabinfo.py
[1] https://lore.kernel.org/all/20241002235253.487251-1-stephen.s.brennan@xxxxxxxxxx/#t
Stephen Brennan (2):
kallsyms: output rodata to ".kallsyms_rodata"
btf: Add the option to include global variable types
include/asm-generic/vmlinux.lds.h | 1 +
lib/Kconfig.debug | 10 ++++++++++
scripts/Makefile.btf | 3 +++
scripts/kallsyms.c | 2 +-
4 files changed, 15 insertions(+), 1 deletion(-)
--
2.43.5