Debian Codegraph @

btfdiff

raw
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright © 2019 Red Hat Inc, Arnaldo Carvalho de Melo <[email protected]>
4 # Use pahole to produce output from BTF and from DWARF, then do a diff
5 # Use --flat_arrays with DWARF as BTF, like CTF, flattens arrays.
6 # Use --show_private_classes as BTF shows all structs, while pahole knows
7 # if some struct is defined only inside another struct/class or in a function,
8 # this information is not available when loading from BTF.
9
10 if [ $# -eq 0 ] ; then
11 echo "Usage: btfdiff <filename_with_DWARF_and_maybe_BTF_info> [<filename_with_BTF_info>]"
12 exit 1
13 fi
14
15 dwarf_input=$1
16 btf_input=$dwarf_input
17
18 if [ $# -eq 2 ] ; then
19 btf_input=$2
20 fi
21
22 btf_output=$(mktemp /tmp/btfdiff.btf.XXXXXX)
23 dwarf_output=$(mktemp /tmp/btfdiff.dwarf.XXXXXX)
24 pahole_bin=${PAHOLE-"pahole"}
25
26 ${pahole_bin} -E -F dwarf \
27 --flat_arrays \
28 --sort \
29 --jobs \
30 --suppress_aligned_attribute \
31 --suppress_force_paddings \
32 --suppress_packed \
33 --lang_exclude rust \
34 --show_private_classes $dwarf_input > $dwarf_output &
35 dwarf=$!
36
37 ${pahole_bin} -E -F btf \
38 --sort \
39 --suppress_aligned_attribute \
40 --suppress_packed \
41 $btf_input > $btf_output
42
43 wait $dwarf
44
45 diff -up $dwarf_output $btf_output
46
47 rm -f $btf_output $dwarf_output
48 exit 0