Bug rhbz#2182807 -- abipkgdiff crashes on missing debuginfo package
authorDodji Seketeli <dodji@redhat.com>
Mon, 3 Apr 2023 09:58:14 +0000 (11:58 +0200)
committerDodji Seketeli <dodji@redhat.com>
Mon, 3 Apr 2023 15:01:44 +0000 (17:01 +0200)
commited205e0e79e3a37d443b800530bcc25ffa820aac
treee7dbcd31368cfa9bca57f783feb8ffd1b27a175d
parentddb6abd2d3abd7e7d38a71a7ea78bbd9c272e9f1
Bug rhbz#2182807 --  abipkgdiff crashes on missing debuginfo package

When abipkgdiff is called with a debug info package that references an
alternate debug info file that is not found -- because debug info
package is missing from the command line -- the program aborts.  This
is because the libabigail library is further invoked by the tool with
debuginfo in an inconsistent state (missing alternate debug info).

Note however that abipkgdiff only emits an explanatory message when
invoked with the --verbose option.

This patch teaches abipkgdiff to emit explanatory messages when an
alternate debug info file is not found.  The message suggests that the
user adds the missing RPM package (which contains the alternate
missing debuginfo file) to the command line using the --d1/--d2
switches.

* src/abg-fe-iface.cc (status_to_diagnostic_string): Remove the
newline from the end of the returned diagnostic string.
* tools/abipkgdiff.cc (get_pretty_printed_list_of_packages)
(emit_alt_debug_info_not_found_error): Define new static
functions.
(compare, compare_to_self): Add an ostream& parameter as a
destination of diagnostic messages.  If the
abigail::fe_iface::STATUS_ALT_DEBUG_INFO_NOT_FOUND bit is set in
the status code, emit the explanatory message to output stream
associated to the current comparison task.  Remove the previous
handling of this case.
(compare_task::maybe_emit_pretty_error_message_to_output): Define
new member function to get the output stream associated to the
current task massage it and stick to result into the pretty output
string to be emitted to the user in the end, namely the
compare_task::pretty_output string data member.
({compares, self_compare}_task::perform): Adjust this to call the
new maybe_emit_pretty_error_message_to_output in case of error.
* tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt:
Adjust.
* tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt:
Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-fe-iface.cc
tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt
tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt
tools/abipkgdiff.cc