2a82d593be
For struct/union members, the struct/union type info kind_flag is needed to calculate correct bitfield_size and bit_offset. if (kind_flag) { bitfield_size = BTF_MEMBER_BITFIELD_SIZE(member->offset); bit_offset = BTF_MEMBER_BIT_OFFSET(member->offset); } else { bitfield_size = 0; bit_offset = member->offset; } Note that bitfield_size and bit_offset will not depend on the member type. The member type will help calculate correct bitfield_offset, byte_size, byte_offset, bit_size. For example, with the fix, we will be able to display bit offset and bitfield size properly. -bash-4.4$ cat t.c struct t { int a:2; int b:3; int c:2; } g; -bash-4.4$ gcc -c -O2 -g t.c -bash-4.4$ pahole -JV t.o File t.o: [1] STRUCT t kind_flag=1 size=4 vlen=3 a type_id=2 bitfield_size=2 bits_offset=0 b type_id=2 bitfield_size=3 bits_offset=2 c type_id=2 bitfield_size=2 bits_offset=5 [2] INT int size=4 bit_offset=0 nr_bits=32 encoding=SIGNED -bash-4.4$ pahole -F btf t.o struct t { int a:2; /* 0: 0 4 */ int b:3; /* 0: 2 4 */ int c:2; /* 0: 5 4 */ /* size: 4, cachelines: 1, members: 3 */ /* bit_padding: 25 bits */ /* last cacheline: 4 bytes */ }; Note that the above offset showing is different from the below dwarf as BTF bitfield_offset is always the offset from the start of structure, kindly like big endian encoding. This may need adjustment to be conforming to the dwarf dump format. -bash-4.4$ pahole -F dwarf t.o struct t { int a:2; /* 0:30 4 */ int b:3; /* 0:27 4 */ int c:2; /* 0:25 4 */ /* size: 4, cachelines: 1, members: 3 */ /* bit_padding: 25 bits */ /* last cacheline: 4 bytes */ }; Signed-off-by: Yonghong Song <yhs@fb.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Alexei Starovoitov <ast@fb.com> Cc: Martin KaFai Lau <kafai@fb.com> Cc: dwarves@vger.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> |
||
---|---|---|
cmake/modules | ||
lib | ||
man-pages | ||
ostra | ||
rpm/SPECS | ||
btf_encoder.c | ||
btf_encoder.h | ||
btf_loader.c | ||
btf.h | ||
CMakeLists.txt | ||
codiff.c | ||
config.h.cmake | ||
COPYING | ||
ctf_encoder.c | ||
ctf_encoder.h | ||
ctf_loader.c | ||
ctf.h | ||
ctfdwdiff | ||
ctracer.c | ||
dtagnames.c | ||
dutil.c | ||
dutil.h | ||
dwarf_loader.c | ||
dwarves_emit.c | ||
dwarves_emit.h | ||
dwarves_fprintf.c | ||
dwarves_reorganize.c | ||
dwarves_reorganize.h | ||
dwarves.c | ||
dwarves.h | ||
elf_symtab.c | ||
elf_symtab.h | ||
elfcreator.c | ||
elfcreator.h | ||
gobuffer.c | ||
gobuffer.h | ||
hash.h | ||
libbtf.c | ||
libbtf.h | ||
libctf.c | ||
libctf.h | ||
list.h | ||
MANIFEST | ||
NEWS | ||
pahole.c | ||
pdwtags.c | ||
pfunct.c | ||
pglobal.c | ||
prefcnt.c | ||
rbtree.c | ||
rbtree.h | ||
README | ||
README.btf | ||
README.ctracer | ||
README.DEBUG | ||
regtest | ||
scncopy.c | ||
strings.c | ||
strings.h | ||
syscse.c |
Build instructions: 1. install cmake 2. mkdir build 3. cd build 4. cmake -D__LIB=lib .. 5. make install Default is to be installed on /usr/local, see rpm spec file for installing on other places. Known to work scenarios: Mandriva Cooker: cmake 2.4.5-1mdv2007.1 libelfutils1-devel 0.123-1mdv2007.1 Debian Unstable: cmake 2.4.5-1 libdw-dev 0.123-2 Fedora Core 6: cmake 2.4.5-2.fc6 elfutils-devel 0.126-1.fc6