Re: RFCv2: debuginfod debian archive support

2019-12-05 Thread Mark Wielaard
Hi Kurt and Matthias,

On Mon, 2019-12-02 at 17:54 -0500, Frank Ch. Eigler wrote:
> On second thought, generalized the code & terminology.  This may be
> ready for merging, except that it'd be awesome if a
> debian/ubuntu-literate person could create some test .deb/.ddeb files
> matching the tests/debuginfod-rpms.  (cc:'d some maintainers there in
> hope they might have the time.)  Hand-testing here looks okay.

Would you be able to show how to build a minimal (separate) debuginfo
package for Debian and/or Ubunutu? For rpm based systems we use the
attached self contained spec file that creates two nearly identical
hello programs to test any issues with duplicate name/debug/DWARF, it
also tests dwz multi files (if you use those on Debian or Ubuntu). To
(re)create the binary test packages for a different arch one would
simply run rpmbuild -ba hello2.spec.

How would one build a similar binary deb package (and the debuginfo
subpackages) on a Debian/Ubuntu system?

Thanks,

Mark
Summary: hello2 -- double hello, world rpm
Name: hello2
Version: 1.0
Release: 2
Group: Utilities
License: GPL
Distribution: RPM ^W Elfutils test suite.
Vendor: Red Hat Software
Packager: Red Hat Software 
URL: http://www.redhat.com
BuildRequires: gcc make
Source0: hello-1.0.tar.gz

%description
Simple rpm demonstration with an eye to consumption by debuginfod.

%package two
Summary: hello2two
License: GPL

%description two
Dittoish.

%prep
%setup -q -n hello-1.0

%build
gcc -g -O1 hello.c -o hello
gcc -g -O2 -D_FORTIFY_SOURCE=2 hello.c -o hello2

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/local/bin
cp hello $RPM_BUILD_ROOT/usr/local/bin/
cp hello2 $RPM_BUILD_ROOT/usr/local/bin/

%clean
rm -rf $RPM_BUILD_ROOT

%files 
%defattr(-,root,root)
%attr(0751,root,root)   /usr/local/bin/hello

%files two
%defattr(-,root,root)
%attr(0751,root,root)   /usr/local/bin/hello2

%changelog
* Thu Nov 14 2019 Frank Ch. Eigler 
- Added source code right here to make spec file self-contained.
- Dropped misc files not relevant to debuginfod testing.

* Wed May 18 2016 Mark Wielaard 
- Add hello2 for dwz testing support.

* Tue Oct 20 1998 Jeff Johnson 
- create.


[PATCH] tests: Run elfcompress under testrun in run-elfclassify.sh

2019-12-05 Thread Mark Wielaard
Otherwise elfcompress might run against the system libelf which might
be too old or missing.

Signed-off-by: Mark Wielaard 
---
 tests/ChangeLog  | 4 
 tests/run-elfclassify.sh | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 6e3923f5..70100de4 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2019-12-05  Mark Wielaard  
+
+   * run-elfclassify.sh: Run elfcompress under testrun.
+
 2019-11-26  Mark Wielaard  
 
* Makefile.am (BUILD_STATIC): Add libraries needed for libdw.
diff --git a/tests/run-elfclassify.sh b/tests/run-elfclassify.sh
index 5a849bbd..fb14139d 100755
--- a/tests/run-elfclassify.sh
+++ b/tests/run-elfclassify.sh
@@ -267,7 +267,7 @@ $(echo $kmod_files | sed -e "s/ /\n/g")
 EOF
 
 echo "gnu compressed kmods are unstripped"
-${abs_top_builddir}/src/elfcompress -t gnu --force $kmod_files
+testrun ${abs_top_builddir}/src/elfcompress -t gnu --force $kmod_files
 testrun ${abs_top_builddir}/src/elfclassify --unstripped $kmod_files
 testrun_compare ${abs_top_builddir}/src/elfclassify --unstripped --print 
$kmod_files <

[PATCH] libdwfl: Find and handle compressed vmlinuz image.

2019-12-05 Thread Mark Wielaard
Both the dwfl_linux_kernel_find_elf callback and the
dwfl_linux_kernel_report_offline reporting function only handled
vmlinix images possibly compressed with .gz, .bz2 or .xz extension.
They did not find or handle the much more common vmlinuz compressed
images.

It is not completely clear why we didn't up to now. Support for
compressed ELF files was added in 2009 and the code was updated to
to try to find the .gz, .bz2 or .xz extension variants in 2011.
But not the vmlinuz named variant.

Reported-by: Aaron Merey 
Tested-by: Frank Ch. Eigler 
Signed-off-by: Mark Wielaard 
---
 libdwfl/ChangeLog  |  5 +
 libdwfl/linux-kernel-modules.c | 23 +++
 2 files changed, 28 insertions(+)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index b8222189..b6b427d4 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-05  Mark Wielaard  
+
+   * linux-kernel-modules.c (find_kernel_elf): Also try to find
+   vmlinux image.
+
 2019-10-28  Aaron Merey  
 
* dwfl_build_id_find_elf.c (dwfl_build_id_find_elf): Call debuginfod
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index d46ab5aa..48fb1ff0 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -174,6 +174,8 @@ kernel_release (void)
 static int
 find_kernel_elf (Dwfl *dwfl, const char *release, char **fname)
 {
+  /* First try to find an uncompressed vmlinux image.  Possibly
+ including debuginfo.  */
   if ((release[0] == '/'
? asprintf (fname, "%s/vmlinux", release)
: asprintf (fname, "/boot/vmlinux-%s", release)) < 0)
@@ -188,6 +190,27 @@ find_kernel_elf (Dwfl *dwfl, const char *release, char 
**fname)
   fd = try_kernel_name (dwfl, fname, true);
 }
 
+  /* There might be a compressed vmlinuz image.  Probably without
+ debuginfo, but try to find it under the debug path also, just in
+ case.  */
+  if (fd < 0)
+{
+  free (*fname);
+  if ((release[0] == '/'
+   ? asprintf (fname, "%s/vmlinuz", release)
+   : asprintf (fname, "/boot/vmlinuz-%s", release)) < 0)
+return -1;
+
+  fd = try_kernel_name (dwfl, fname, true);
+  if (fd < 0 && release[0] != '/')
+   {
+ free (*fname);
+ if (asprintf (fname, MODULEDIRFMT "/vmlinuz", release) < 0)
+   return -1;
+ fd = try_kernel_name (dwfl, fname, true);
+   }
+}
+
   return fd;
 }
 
-- 
2.18.1



[PATCH] config: Update elfutils.spec with explicit sub-package requires.

2019-12-05 Thread Mark Wielaard
Consistently require version-release subpackages so that everything
is updated together. Technically this isn't always required (it is
for elfutils-libelf and elfutils-libs). But this makes things more
consistent and prevents multilib version mismatches.

Also update a Summary and description to match the current Fedora
text.

Signed-off-by: Mark Wielaard 
---
 config/ChangeLog|  5 +
 config/elfutils.spec.in | 19 ++-
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/config/ChangeLog b/config/ChangeLog
index d71fb39..4e28970 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-05  Mark Wielaard  
+
+   * elfutils.spec.in: Add explicit version-release requires for all
+   packages.
+
 2019-11-28  Mark Wielaard  
 
* elfutils.spec.in (debuginfod): Add an explicit Requires
diff --git a/config/elfutils.spec.in b/config/elfutils.spec.in
index 1cdca21..d7279c7 100644
--- a/config/elfutils.spec.in
+++ b/config/elfutils.spec.in
@@ -1,16 +1,16 @@
 # -*- rpm-spec-*-
-Summary: A collection of utilities and DSOs to handle ELF files and DWARF data
 Name: elfutils
 Version: @PACKAGE_VERSION@
 Release: 1
 URL: http://elfutils.org/
 License: GPLv3+ and (GPLv2+ or LGPLv3+) and GFDL
 Source: 
ftp://sourceware.org/pub/elfutils/%{version}/elfutils-%{version}.tar.bz2
+Summary: A collection of utilities and DSOs to handle ELF files and DWARF data
 
 Requires: elfutils-libelf = %{version}-%{release}
 Requires: elfutils-libs = %{version}-%{release}
 # Can be a Recommends if rpm supports that
-Requires: elfutils-debuginfod-client
+Requires: elfutils-debuginfod-client = %{version}-%{release}
 
 BuildRequires: gcc
 # For libstdc++ demangle support
@@ -54,7 +54,7 @@ License: GPLv2+ or LGPLv3+
 Requires: elfutils-libelf = %{version}-%{release}
 Requires: default-yama-scope
 # Can be a Recommends if rpm supports that
-Requires: elfutils-debuginfod-client
+Requires: elfutils-debuginfod-client = %{version}-%{release}
 
 %description libs
 The elfutils-libs package contains libraries which implement DWARF, ELF,
@@ -68,10 +68,8 @@ Summary: Development libraries to handle compiled objects
 License: GPLv2+ or LGPLv3+
 Requires: elfutils-libs = %{version}-%{release}
 Requires: elfutils-libelf-devel = %{version}-%{release}
-%if 0%{?rhel} >= 8 || 0%{?fedora} >= 20
-Recommends: elfutils-debuginfod-client-devel
-%else
-Requires: elfutils-debuginfod-client-devel
+# Can be a Recommends if rpm supports that
+Requires: elfutils-debuginfod-client-devel = %{version}-%{release}
 %endif
 
 %description devel
@@ -87,8 +85,8 @@ Requires: elfutils-devel = %{version}-%{release}
 Requires: elfutils-libelf-devel-static = %{version}-%{release}
 
 %description devel-static
-The elfutils-devel-static archive contains the static archives
-with the code the handle compiled objects.
+The elfutils-devel-static package contains the static archives
+with the code to handle compiled objects.
 
 %package libelf
 Summary: Library to read and write ELF files
@@ -144,10 +142,13 @@ License: GPLv3+ and (GPLv2+ or LGPLv3+)
 %package debuginfod-client-devel
 Summary: Libraries and headers to build debuginfod client applications
 License: GPLv2+ or LGPLv3+
+Requires: debuginfod-client = %{version}-%{release}
 
 %package debuginfod
 Summary: HTTP ELF/DWARF file server addressed by build-id
 License: GPLv3+
+Requires: elfutils-libs = %{version}-%{release}
+Requires: elfutils-libelf = %{version}-%{release}
 Requires: elfutils-debuginfod-client = %{version}-%{release}
 BuildRequires: systemd
 Requires(post):   systemd
-- 
1.8.3.1