diff --git a/.dwarves.metadata b/.dwarves.metadata new file mode 100644 index 0000000..583d84c --- /dev/null +++ b/.dwarves.metadata @@ -0,0 +1 @@ +90995f46f9fcec884748a1deeb2283a4ae202594 SOURCES/dwarves-1.15.tar.xz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f9ce5da --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/dwarves-1.15.tar.xz diff --git a/SOURCES/0001-fprintf-Fixup-handling-classes-with-no-members.patch b/SOURCES/0001-fprintf-Fixup-handling-classes-with-no-members.patch new file mode 100644 index 0000000..d5f7618 --- /dev/null +++ b/SOURCES/0001-fprintf-Fixup-handling-classes-with-no-members.patch @@ -0,0 +1,94 @@ +From b1412a88bb616f449401be285d43b028962992b9 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Mon, 1 Jul 2019 11:37:40 -0300 +Subject: [PATCH 1/1] fprintf: Fixup handling classes with no members + +Will Cohen reported this NULL pointer dereference while processing some +object linking with cuda: + + #0 0x00007ffff7f91453 in __class__fprintf (class=0x522560, cu=0x40ff80, conf=0x7fffffffa930, fp=0x7ffff7ece780 <_IO_2_1_stdout_>) + at /home/acme/git/pahole/dwarves_fprintf.c:1624 + #1 0x00007ffff7f92195 in tag__fprintf (tag=0x522560, cu=0x40ff80, conf=0x7fffffffa930, fp=0x7ffff7ece780 <_IO_2_1_stdout_>) + at /home/acme/git/pahole/dwarves_fprintf.c:1835 + #2 0x00007ffff7f90b57 in __class__fprintf (class=0x5224c0, cu=0x40ff80, conf=0x7fffffffaaa0, fp=0x7ffff7ece780 <_IO_2_1_stdout_>) + at /home/acme/git/pahole/dwarves_fprintf.c:1406 + #3 0x00007ffff7f92195 in tag__fprintf (tag=0x5224c0, cu=0x40ff80, conf=0x40a200 , fp=0x7ffff7ece780 <_IO_2_1_stdout_>) + at /home/acme/git/pahole/dwarves_fprintf.c:1835 + #4 0x0000000000402d03 in class_formatter (class=0x5224c0, cu=0x40ff80, id=1257) at /home/acme/git/pahole/pahole.c:224 + #5 0x0000000000403074 in print_classes (cu=0x40ff80) at /home/acme/git/pahole/pahole.c:319 + #6 0x0000000000404bb2 in pahole_stealer (cu=0x40ff80, conf_load=0x40a240 ) at /home/acme/git/pahole/pahole.c:1174 + #7 0x00007ffff7f9ff73 in finalize_cu (cus=0x40b2b0, cu=0x40ff80, dcu=0x7fffffffacf0, conf=0x40a240 ) + at /home/acme/git/pahole/dwarf_loader.c:2227 + #8 0x00007ffff7f9ffac in finalize_cu_immediately (cus=0x40b2b0, cu=0x40ff80, dcu=0x7fffffffacf0, conf=0x40a240 ) + at /home/acme/git/pahole/dwarf_loader.c:2236 + #9 0x00007ffff7fa064c in cus__load_module (cus=0x40b2b0, conf=0x40a240 , mod=0x40d760, dw=0x40e980, elf=0x40b360, + filename=0x7fffffffd5e3 "examples/wcohen/02_Exercise.cuda") at /home/acme/git/pahole/dwarf_loader.c:2389 + #10 0x00007ffff7fa0760 in cus__process_dwflmod (dwflmod=0x40d760, userdata=0x40d770, name=0x40d910 "examples/wcohen/02_Exercise.cuda", + base=4194304, arg=0x7fffffffcf10) at /home/acme/git/pahole/dwarf_loader.c:2434 + #11 0x00007ffff7f32be1 in dwfl_getmodules () from /lib64/libdw.so.1 + #12 0x00007ffff7fa0820 in cus__process_file (cus=0x40b2b0, conf=0x40a240 , fd=3, + filename=0x7fffffffd5e3 "examples/wcohen/02_Exercise.cuda") at /home/acme/git/pahole/dwarf_loader.c:2487 + #13 0x00007ffff7fa089c in dwarf__load_file (cus=0x40b2b0, conf=0x40a240 , filename=0x7fffffffd5e3 "examples/wcohen/02_Exercise.cuda") + at /home/acme/git/pahole/dwarf_loader.c:2504 + #14 0x00007ffff7f8b0dd in cus__load_file (cus=0x40b2b0, conf=0x40a240 , filename=0x7fffffffd5e3 "examples/wcohen/02_Exercise.cuda") + at /home/acme/git/pahole/dwarves.c:1745 + #15 0x00007ffff7f8bc2a in cus__load_files (cus=0x40b2b0, conf=0x40a240 , filenames=0x7fffffffd150) + at /home/acme/git/pahole/dwarves.c:2109 + #16 0x0000000000404ff0 in main (argc=2, argv=0x7fffffffd148) at /home/acme/git/pahole/pahole.c:1294 + (gdb) + + (gdb) p class__name(class, cu) + $6 = 0x5cbb85 "__nv_hdl_helper_trait<__nv_dl_tag, void (main(int, char**)::__lambda0::*)(int, double&)const>" + (gdb) p class->type.nr_members + $7 = 0 + (gdb) p last + $8 = (struct class_member *) 0x0 + (gdb) + +So, before checking for bitfield details, first check if there were +members. + +Now, if we show all structs/classes in that object file and look for the +above data structure, we find it inside another: + + $ pahole examples/wcohen/02_Exercise.cuda + + struct __nv_hdl_helper_trait_outer, Kokkos::View, Kokkos::View > { + struct __nv_hdl_helper_trait<__nv_dl_tag, void (main(int, char**)::__lambda0::*)(int, double&)const> { + class __nv_hdl_wrapper_t, void(int, double&), int, Kokkos::View(class __lambda0, int, class View, class View, class View); + + /* size: 1, cachelines: 0, members: 0 */ + /* padding: 1 */ + /* last cacheline: 1 bytes */ + }; + + /* size: 1, cachelines: 0, members: 0 */ + /* padding: 1 */ + /* last cacheline: 1 bytes */ + }; + + $ + +Reported-by: William Cohen +Fixes: 13e5b9fc00ee ("fprintf: Add unnamed bitfield padding at the end to rebuild original type") +Signed-off-by: Arnaldo Carvalho de Melo +--- + dwarves_fprintf.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c +index 8ad1ced7840c..706f1b5033f5 100644 +--- a/dwarves_fprintf.c ++++ b/dwarves_fprintf.c +@@ -1620,7 +1620,7 @@ static size_t __class__fprintf(struct class *class, const struct cu *cu, + * to avoid adding the forced bitfield paddings and have btfdiff happy. + */ + if (class->padding != 0 && type->alignment == 0 && cconf.has_alignment_info && +- !cconf.suppress_force_paddings) { ++ !cconf.suppress_force_paddings && last != NULL) { + tag_pos = cu__type(cu, last->tag.type); + size = tag__size(tag_pos, cu); + +-- +2.20.1 + diff --git a/SPECS/dwarves.spec b/SPECS/dwarves.spec new file mode 100644 index 0000000..76235cf --- /dev/null +++ b/SPECS/dwarves.spec @@ -0,0 +1,130 @@ +%define libname libdwarves +%define libver 1 + +Name: dwarves +Version: 1.15 +Release: 5%{?dist} +License: GPLv2 +Summary: Debugging Information Manipulation Tools (pahole & friends) +URL: http://acmel.wordpress.com +Source: http://fedorapeople.org/~acme/dwarves/%{name}-%{version}.tar.xz +Patch: 0001-fprintf-Fixup-handling-classes-with-no-members.patch +Requires: %{libname}%{libver} = %{version}-%{release} +BuildRequires: gcc +BuildRequires: cmake +BuildRequires: zlib-devel +BuildRequires: elfutils-devel >= 0.130 + +%description +dwarves is a set of tools that use the debugging information inserted in +ELF binaries by compilers such as GCC, used by well known debuggers such as +GDB, and more recent ones such as systemtap. + +Utilities in the dwarves suite include pahole, that can be used to find +alignment holes in structs and classes in languages such as C, C++, but not +limited to these. + +It also extracts other information such as CPU cacheline alignment, helping +pack those structures to achieve more cache hits. + +These tools can also be used to encode and read the BTF type information format +used with the Linux kernel bpf syscall, using 'pahole -J' and 'pahole -F btf'. + +A diff like tool, codiff can be used to compare the effects changes in source +code generate on the resulting binaries. + +Another tool is pfunct, that can be used to find all sorts of information about +functions, inlines, decisions made by the compiler about inlining, etc. + +%package -n %{libname}%{libver} +Summary: Debugging information processing library + +%description -n %{libname}%{libver} +Debugging information processing library. + +%package -n %{libname}%{libver}-devel +Summary: Debugging information library development files +Requires: %{libname}%{libver} = %{version}-%{release} + +%description -n %{libname}%{libver}-devel +Debugging information processing library development files. + +%prep +%setup -q -c -n %{name}-%{version} +%patch -p1 + +%build +%cmake . +make VERBOSE=1 %{?_smp_mflags} + +%install +rm -Rf %{buildroot} +make install DESTDIR=%{buildroot} + +%ldconfig_scriptlets -n %{libname}%{libver} + +%files +%doc README.ctracer +%doc README.btf +%doc NEWS +%{_bindir}/btfdiff +%{_bindir}/codiff +%{_bindir}/ctracer +%{_bindir}/dtagnames +%{_bindir}/fullcircle +%{_bindir}/pahole +%{_bindir}/pdwtags +%{_bindir}/pfunct +%{_bindir}/pglobal +%{_bindir}/prefcnt +%{_bindir}/scncopy +%{_bindir}/syscse +%{_bindir}/ostra-cg +%dir %{_datadir}/dwarves/ +%dir %{_datadir}/dwarves/runtime/ +%dir %{_datadir}/dwarves/runtime/python/ +%defattr(0644,root,root,0755) +%{_mandir}/man1/pahole.1* +%{_datadir}/dwarves/runtime/Makefile +%{_datadir}/dwarves/runtime/linux.blacklist.cu +%{_datadir}/dwarves/runtime/ctracer_relay.c +%{_datadir}/dwarves/runtime/ctracer_relay.h +%attr(0755,root,root) %{_datadir}/dwarves/runtime/python/ostra.py* + +%files -n %{libname}%{libver} +%{_libdir}/%{libname}.so.* +%{_libdir}/%{libname}_emit.so.* +%{_libdir}/%{libname}_reorganize.so.* + +%files -n %{libname}%{libver}-devel +%doc MANIFEST README +%{_includedir}/dwarves/btf_encoder.h +%{_includedir}/dwarves/config.h +%{_includedir}/dwarves/ctf_encoder.h +%{_includedir}/dwarves/ctf.h +%{_includedir}/dwarves/dutil.h +%{_includedir}/dwarves/dwarves.h +%{_includedir}/dwarves/dwarves_emit.h +%{_includedir}/dwarves/dwarves_reorganize.h +%{_includedir}/dwarves/elfcreator.h +%{_includedir}/dwarves/elf_symtab.h +%{_includedir}/dwarves/gobuffer.h +%{_includedir}/dwarves/hash.h +%{_includedir}/dwarves/libbtf.h +%{_includedir}/dwarves/libctf.h +%{_includedir}/dwarves/list.h +%{_includedir}/dwarves/rbtree.h +%{_includedir}/dwarves/strings.h +%{_libdir}/%{libname}.so +%{_libdir}/%{libname}_emit.so +%{_libdir}/%{libname}_reorganize.so + +%changelog +* Wed Nov 06 2019 Jiri Olsa - 1.15-5 +- Add libdwarves version dependency to dwarves package + +* Mon Nov 04 2019 Jiri Olsa - 1.15-4 +- CI rebuild + +* Wed Sep 25 2019 Jiri Olsa - 1.15-1 +- Initial build