Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame^] | 1 | From a9ce89bcd2d78728faef59bda60e75510972cd56 Mon Sep 17 00:00:00 2001 |
| 2 | From: Victor Kamensky <kamensky@cisco.com> |
| 3 | Date: Wed, 14 Mar 2018 17:09:44 -0500 |
| 4 | Subject: [PATCH] sysroot: fix short release -r option handling |
| 5 | |
| 6 | * setupdwfl.cxx (debuginfo_path_insert_sysroot): Add a '/' to the end of |
| 7 | the sysroot for path_insert_sysroot(). |
| 8 | (setup_dwfl_kernel): Simplify logic when finding the kernel path to send |
| 9 | to elfutils. |
| 10 | |
| 11 | Upstream-Status: Backport |
| 12 | Signed-off-by: Victor Kamensky <kamensky@cisco.com> |
| 13 | --- |
| 14 | setupdwfl.cxx | 19 ++++++++++++------- |
| 15 | 1 file changed, 12 insertions(+), 7 deletions(-) |
| 16 | |
| 17 | diff --git a/setupdwfl.cxx b/setupdwfl.cxx |
| 18 | index 2a87982..f6c3157 100644 |
| 19 | --- a/setupdwfl.cxx |
| 20 | +++ b/setupdwfl.cxx |
| 21 | @@ -339,6 +339,13 @@ static char * path_insert_sysroot(string sysroot, string path) |
| 22 | |
| 23 | void debuginfo_path_insert_sysroot(string sysroot) |
| 24 | { |
| 25 | + // FIXME: This is a short-term fix, until we expect sysroot paths to |
| 26 | + // always end with a '/' (and never be empty). |
| 27 | + // |
| 28 | + // The path_insert_sysroot() function assumes that sysroot has a '/' |
| 29 | + // on the end. Make sure that is true. |
| 30 | + if (sysroot.back() != '/') |
| 31 | + sysroot.push_back('/'); |
| 32 | debuginfo_path = path_insert_sysroot(sysroot, debuginfo_path); |
| 33 | debuginfo_usr_path = path_insert_sysroot(sysroot, debuginfo_usr_path); |
| 34 | } |
| 35 | @@ -358,13 +365,11 @@ setup_dwfl_kernel (unsigned *modules_found, systemtap_session &s) |
| 36 | // no way to set the dwfl_callback.debuginfo_path and always |
| 37 | // passs the plain kernel_release here. So instead we have to |
| 38 | // hard-code this magic here. |
| 39 | - string lib_path = "/lib/modules/" + s.kernel_release + "/build"; |
| 40 | - if (s.kernel_build_tree == string(s.sysroot + lib_path) || |
| 41 | - (s.kernel_build_tree == lib_path |
| 42 | - && s.sysroot == "/")) |
| 43 | - elfutils_kernel_path = s.kernel_release; |
| 44 | - else |
| 45 | - elfutils_kernel_path = s.kernel_build_tree; |
| 46 | + string lib_path = s.sysroot + "/lib/modules/" + s.kernel_release + "/build"; |
| 47 | + if (s.kernel_build_tree == lib_path) |
| 48 | + elfutils_kernel_path = s.kernel_release; |
| 49 | + else |
| 50 | + elfutils_kernel_path = s.kernel_build_tree; |
| 51 | offline_modules_found = 0; |
| 52 | |
| 53 | // First try to report full path modules. |