tools-utils: Fix looking for vmlinux binary in debuginfo package
authorGuillermo E. Martinez <guillermo.e.martinez@oracle.com>
Mon, 6 Mar 2023 15:50:38 +0000 (09:50 -0600)
committerDodji Seketeli <dodji@redhat.com>
Wed, 8 Mar 2023 14:21:16 +0000 (15:21 +0100)
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 <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-tools-utils.cc
tools/abipkgdiff.cc

index 94dd8d0504187a8dfe63496e8fd521f85884b302..87af4445413153dddfc8e7a9a86008868b9b19f6 100644 (file)
@@ -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());
index c2fc09cadcb0c497aef3bc8ded0a59609334dbd1..46b920a196dfa1ad6fdd06cfaefb3942a73b2bb5 100644 (file)
@@ -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 '"