linux-debuggers.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH dwarves v3 0/5] Emit global variables in BTF
@ 2024-10-02 23:52 Stephen Brennan
  2024-10-02 23:52 ` [PATCH dwarves v3 1/5] btf_encoder: use bitfield to control var encoding Stephen Brennan
                   ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: Stephen Brennan @ 2024-10-02 23:52 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: bpf, dwarves, linux-debuggers, Stephen Brennan, Alan Maguire

Hello all,

This is v3 of the series to add global variables to pahole's generated BTF.
Patches 1-3 of v2 were already merged. This series splits the last patch of v2
and does some small updates. It should apply cleanly to the "next" branch.
https://github.com/acmel/dwarves/commits/btf_global_vars/

Changes since v2:
1. Split things out into several smaller patches as can be seen in the log
   below.
2. Previously the global_var feature was defined with BTF_DEFAULT_FEATURE, but I
   think we agreed in the discussion of v2 that it would be better as
   BTF_NON_DEFAULT_FEATURE, so I changed it to align with our discussion.
3. Removed the "--encode_btf_global_vars" option.
3. I went through and straightened out my use of integer types for ELF section
   index (size_t, as returned by libelf) as well as the variable addr and size.
   To this end I did add a few checks to explicitly ensure we don't overflow the
   uint32_t fields in the DATASEC.

To test this out on a Linux build, you'll want to make the following change:

---------
diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf
index b75f09f3f424..c88d9e526426 100644
--- a/scripts/Makefile.btf
+++ b/scripts/Makefile.btf
@@ -19,7 +19,7 @@ pahole-flags-$(call test-ge, $(pahole-ver), 125)      += --skip_encoding_btf_inconsis
 else

 # Switch to using --btf_features for v1.26 and later.
-pahole-flags-$(call test-ge, $(pahole-ver), 126)  = -j --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs
+pahole-flags-$(call test-ge, $(pahole-ver), 126)  = -j --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs,global_var

 ifneq ($(KBUILD_EXTMOD),)
 module-pahole-flags-$(call test-ge, $(pahole-ver), 126) += --btf_features=distilled_base
---------

With a suitable kernel config that has BTF enabled, you could then build like
so:

    PATH=path/to/pahole_build_dir make all

And you'll be able to examine the size of the results with readelf, or dump the
results with bpftool.

v2: https://lore.kernel.org/dwarves/20240920081903.13473-1-stephen.s.brennan@oracle.com/T/
v1: https://lore.kernel.org/dwarves/20240912190827.230176-1-stephen.s.brennan@oracle.com/

Stephen Brennan (5):
  btf_encoder: use bitfield to control var encoding
  btf_encoder: stop indexing symbols for VARs
  btf_encoder: explicitly check addr/size for u32 overflow
  btf_encoder: allow encoding VARs from many sections
  pahole: add global_var BTF feature

 btf_encoder.c      | 348 +++++++++++++++++++++------------------------
 btf_encoder.h      |   7 +
 dwarves.h          |   1 +
 man-pages/pahole.1 |   7 +-
 pahole.c           |   3 +-
 5 files changed, 178 insertions(+), 188 deletions(-)

-- 
2.43.5


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2024-10-03 20:59 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-02 23:52 [PATCH dwarves v3 0/5] Emit global variables in BTF Stephen Brennan
2024-10-02 23:52 ` [PATCH dwarves v3 1/5] btf_encoder: use bitfield to control var encoding Stephen Brennan
2024-10-03 13:41   ` Alan Maguire
2024-10-03 14:41     ` Arnaldo Carvalho de Melo
2024-10-02 23:52 ` [PATCH dwarves v3 2/5] btf_encoder: stop indexing symbols for VARs Stephen Brennan
2024-10-03 13:59   ` Alan Maguire
2024-10-03 17:26     ` Stephen Brennan
2024-10-02 23:52 ` [PATCH dwarves v3 3/5] btf_encoder: explicitly check addr/size for u32 overflow Stephen Brennan
2024-10-03 14:19   ` Alan Maguire
2024-10-02 23:52 ` [PATCH dwarves v3 4/5] btf_encoder: allow encoding VARs from many sections Stephen Brennan
2024-10-03 14:52   ` Alan Maguire
2024-10-03 17:29     ` Stephen Brennan
2024-10-02 23:52 ` [PATCH dwarves v3 5/5] pahole: add global_var BTF feature Stephen Brennan
2024-10-03 14:40   ` Alan Maguire
2024-10-03 14:53     ` Arnaldo Carvalho de Melo
2024-10-03 15:21       ` Alan Maguire
2024-10-03 17:18         ` Arnaldo Carvalho de Melo
2024-10-03 17:48           ` Stephen Brennan
2024-10-03 18:33             ` Arnaldo Carvalho de Melo
2024-10-03 20:59 ` [PATCH dwarves v3 0/5] Emit global variables in BTF Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).