dwarves/btfdiff
Arnaldo Carvalho de Melo 9a4d719304 fprintf: Allow suppressing the inferred __attribute__((__packed__))
We use things like DW_AT_alignment, so not all of those attributes are
inferred by formats like BTF that lack that info, allow suppressing the
output and make btfdiff ask for both DWARF and BTF output to have this
suppressed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-04-15 15:01:53 -03:00

33 lines
1017 B
Bash
Executable File

#!/bin/bash
# Copyright © 2019 Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
# Use pahole to produce output from BTF and from DWARF, then do a diff
# Use --flat_arrays with DWARF as BTF, like CTF, flattens arrays.
# Use --show_private_classes as BTF shows all structs, while pahole knows
# if some struct is defined only inside another struct/class or in a function,
# this information is not available when loading from BTF.
if [ $# -eq 0 ] ; then
echo "Usage: btfdiff <filename_with_BTF_and_DWARF_info>"
exit 1
fi
file=$1
btf_output=$(mktemp /tmp/btfdiff.btf.XXXXXX)
dwarf_output=$(mktemp /tmp/btfdiff.dwarf.XXXXXX)
pahole_bin=${PAHOLE-"pahole"}
${pahole_bin} -F dwarf \
--flat_arrays \
--suppress_aligned_attribute \
--suppress_force_paddings \
--suppress_packed \
--show_private_classes $file > $dwarf_output
${pahole_bin} -F btf \
--suppress_packed \
$file > $btf_output
diff -up $dwarf_output $btf_output
rm -f $btf_output $dwarf_output
exit 0