From dc375bd1b7f15f41665f002ec61f68ce1e7ff889 Mon Sep 17 00:00:00 2001 From: "Guillermo E. Martinez" Date: Mon, 6 Mar 2023 09:50:38 -0600 Subject: [PATCH] tools-utils: Fix looking for vmlinux binary in debuginfo package When abipkgdiff is invoked on a `kernel' package, compare_prepared_linux_kernel_packages fails to look for the `vmlinux' file from the debuginfo package, because of a thinko. Then, build_corpus_group_from_kernel_dist_under, also fails to find `vmlinux' from the debuginfo package because of another thinko. This patch fixes the two thinkos. * src/abg-tools-utils.cc (get_binary_paths_from_kernel_dist): Fix a thinko and really use the kernel_modules_root variable. Look for modules under kernel_modules_root and look for vmlinux (if necessary) under debug_info_root. Add comments. (compare_prepared_linux_kernel_packages): Fix another thinko. Now we do have the path to vmlinux, from debuginfo packages before getting into get_binary_paths_from_kernel_dist. Signed-off-by: Guillermo E. Martinez Signed-off-by: Dodji Seketeli --- src/abg-tools-utils.cc | 20 +++++++++++++++----- tools/abipkgdiff.cc | 6 ++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc index 94dd8d05..87af4445 100644 --- a/src/abg-tools-utils.cc +++ b/src/abg-tools-utils.cc @@ -2573,19 +2573,29 @@ get_binary_paths_from_kernel_dist(const string& dist_root, string debug_info_root; if (dir_exists(dist_root + "/lib/modules")) { - dist_root + "/lib/modules"; + kernel_modules_root = dist_root + "/lib/modules"; debug_info_root = debug_info_root_path.empty() - ? dist_root + ? dist_root + "/usr/lib/debug" : debug_info_root_path; - debug_info_root += "/usr/lib/debug"; } if (dir_is_empty(debug_info_root)) debug_info_root.clear(); bool found = false; - string from = dist_root; - if (find_vmlinux_and_module_paths(from, vmlinux_path, module_paths)) + // If vmlinux_path is empty, we want to look for it under + // debug_info_root, because this is where Enterprise Linux packages + // put it. Modules however are to be looked for under + // kernel_modules_root. + if (// So, Let's look for modules under kernel_modules_root ... + find_vmlinux_and_module_paths(kernel_modules_root, + vmlinux_path, + module_paths) + // ... and if vmlinux_path is empty, look for vmlinux under the + // debug info root. + || find_vmlinux_and_module_paths(debug_info_root, + vmlinux_path, + module_paths)) found = true; std::sort(module_paths.begin(), module_paths.end()); diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc index c2fc09ca..46b920a1 100644 --- a/tools/abipkgdiff.cc +++ b/tools/abipkgdiff.cc @@ -3106,8 +3106,7 @@ compare_prepared_linux_kernel_packages(package& first_package, string vmlinux_path1, vmlinux_path2; - if (!vmlinux_path1.empty() - && !get_vmlinux_path_from_kernel_dist(debug_dir1, vmlinux_path1)) + if (!get_vmlinux_path_from_kernel_dist(debug_dir1, vmlinux_path1)) { emit_prefix("abipkgdiff", cerr) << "Could not find vmlinux in debuginfo package '" @@ -3116,8 +3115,7 @@ compare_prepared_linux_kernel_packages(package& first_package, return abigail::tools_utils::ABIDIFF_ERROR; } - if (!vmlinux_path2.empty() - && !get_vmlinux_path_from_kernel_dist(debug_dir2, vmlinux_path2)) + if (!get_vmlinux_path_from_kernel_dist(debug_dir2, vmlinux_path2)) { emit_prefix("abipkgdiff", cerr) << "Could not find vmlinux in debuginfo package '" -- 2.34.1