diff options
10 files changed, 560 insertions, 0 deletions
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-Added-a-couple-of-small-sysroot-fixes.patch b/meta/recipes-kernel/systemtap/systemtap/0001-Added-a-couple-of-small-sysroot-fixes.patch new file mode 100644 index 0000000000..c0ceb5a412 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-Added-a-couple-of-small-sysroot-fixes.patch | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | From a714658727206d2a98a7194b7e6d29dbd3e27b8d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: David Smith <dsmith@redhat.com> | ||
| 3 | Date: Mon, 19 Mar 2018 16:50:05 -0500 | ||
| 4 | Subject: [PATCH] Added a couple of small sysroot fixes. | ||
| 5 | |||
| 6 | * tapsets.cxx (dwarf_builder::build): Fix commit 4ffecddf5. | ||
| 7 | (path_remove_sysroot): Fix extra '/' present at start of paths. | ||
| 8 | |||
| 9 | Upstream-Status: Backport | ||
| 10 | Signed-off-by: Victor Kamensky <kamensky@cisco.com> | ||
| 11 | --- | ||
| 12 | tapsets.cxx | 10 +++++++--- | ||
| 13 | 1 file changed, 7 insertions(+), 3 deletions(-) | ||
| 14 | |||
| 15 | Index: git/tapsets.cxx | ||
| 16 | =================================================================== | ||
| 17 | --- git.orig/tapsets.cxx | ||
| 18 | +++ git/tapsets.cxx | ||
| 19 | @@ -1395,7 +1395,8 @@ string path_remove_sysroot(const systemt | ||
| 20 | string retval = path; | ||
| 21 | if (!sess.sysroot.empty() && | ||
| 22 | (pos = retval.find(sess.sysroot)) != string::npos) | ||
| 23 | - retval.replace(pos, sess.sysroot.length(), "/"); | ||
| 24 | + retval.replace(pos, sess.sysroot.length(), | ||
| 25 | + (sess.sysroot.back() == '/' ? "/": "")); | ||
| 26 | return retval; | ||
| 27 | } | ||
| 28 | |||
| 29 | @@ -8412,8 +8413,11 @@ dwarf_builder::build(systemtap_session & | ||
| 30 | |||
| 31 | // PR13338: unquote glob results | ||
| 32 | module_name = unescape_glob_chars (module_name); | ||
| 33 | - user_path = find_executable (module_name, "", sess.sysenv); // canonicalize it | ||
| 34 | - if (!is_fully_resolved(user_path, sess.sysroot, sess.sysenv)) | ||
| 35 | + user_path = find_executable (module_name, sess.sysroot, sess.sysenv); // canonicalize it | ||
| 36 | + // Note we don't need to pass the sysroot to | ||
| 37 | + // is_fully_resolved(), since we just passed it to | ||
| 38 | + // find_executable(). | ||
| 39 | + if (!is_fully_resolved(user_path, "", sess.sysenv)) | ||
| 40 | throw SEMANTIC_ERROR(_F("cannot find executable '%s'", | ||
| 41 | user_path.to_string().c_str())); | ||
| 42 | |||
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-Delay-adding-sysroot-path-to-module-name-in-case-of-.patch b/meta/recipes-kernel/systemtap/systemtap/0001-Delay-adding-sysroot-path-to-module-name-in-case-of-.patch new file mode 100644 index 0000000000..89951a2f19 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-Delay-adding-sysroot-path-to-module-name-in-case-of-.patch | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | From 4ffecddf5433d65a6f01241990c9d516586b1c79 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Victor Kamensky <kamensky@cisco.com> | ||
| 3 | Date: Mon, 19 Mar 2018 08:53:51 -0500 | ||
| 4 | Subject: [PATCH] Delay adding sysroot path to module name in case of non | ||
| 5 | absolute executable | ||
| 6 | |||
| 7 | Current stap code adds sysroot prematurely for probes that specify non | ||
| 8 | absolute path name, i.e like "foo", so when find_executable called it | ||
| 9 | receives full path as <sysroot>/foo and find_executable does not search | ||
| 10 | PATH while applying sysroot. | ||
| 11 | |||
| 12 | Fix delays adding sysroot till path inside of sysroot is searched first. | ||
| 13 | |||
| 14 | Also fix missing sysroot addition in glob expansion case. | ||
| 15 | |||
| 16 | Upstream-Status: Backport | ||
| 17 | Signed-off-by: Victor Kamensky <kamensky@cisco.com> | ||
| 18 | --- | ||
| 19 | tapsets.cxx | 8 ++++---- | ||
| 20 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
| 21 | |||
| 22 | Index: git/tapsets.cxx | ||
| 23 | =================================================================== | ||
| 24 | --- git.orig/tapsets.cxx | ||
| 25 | +++ git/tapsets.cxx | ||
| 26 | @@ -746,7 +746,7 @@ base_query::base_query(dwflpp & dw, lite | ||
| 27 | pid_val = 0; | ||
| 28 | get_string_param(params, TOK_PROCESS, module_val); | ||
| 29 | } | ||
| 30 | - module_val = find_executable (module_val, "", sess.sysenv); | ||
| 31 | + module_val = find_executable (module_val, sess.sysroot, sess.sysenv); | ||
| 32 | if (!is_fully_resolved(module_val, "", sess.sysenv)) | ||
| 33 | throw SEMANTIC_ERROR(_F("cannot find executable '%s'", | ||
| 34 | module_val.to_string().c_str())); | ||
| 35 | @@ -8287,7 +8287,6 @@ dwarf_builder::build(systemtap_session & | ||
| 36 | } | ||
| 37 | else | ||
| 38 | { | ||
| 39 | - module_name = (string)sess.sysroot + (string)module_name; | ||
| 40 | filled_parameters[TOK_PROCESS] = new literal_string(module_name); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | @@ -8321,7 +8320,8 @@ dwarf_builder::build(systemtap_session & | ||
| 44 | assert (lit); | ||
| 45 | |||
| 46 | // Evaluate glob here, and call derive_probes recursively with each match. | ||
| 47 | - const auto& globs = glob_executable (module_name); | ||
| 48 | + const auto& globs = glob_executable (sess.sysroot | ||
| 49 | + + string(module_name)); | ||
| 50 | unsigned results_pre = finished_results.size(); | ||
| 51 | for (auto it = globs.begin(); it != globs.end(); ++it) | ||
| 52 | { | ||
| 53 | @@ -8413,7 +8413,7 @@ dwarf_builder::build(systemtap_session & | ||
| 54 | // PR13338: unquote glob results | ||
| 55 | module_name = unescape_glob_chars (module_name); | ||
| 56 | user_path = find_executable (module_name, "", sess.sysenv); // canonicalize it | ||
| 57 | - if (!is_fully_resolved(user_path, "", sess.sysenv)) | ||
| 58 | + if (!is_fully_resolved(user_path, sess.sysroot, sess.sysenv)) | ||
| 59 | throw SEMANTIC_ERROR(_F("cannot find executable '%s'", | ||
| 60 | user_path.to_string().c_str())); | ||
| 61 | |||
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch b/meta/recipes-kernel/systemtap/systemtap/0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch new file mode 100644 index 0000000000..7cd9030eac --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | From 41efad04730be89889d1483719f9a6c9396dc250 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: David Smith <dsmith@redhat.com> | ||
| 3 | Date: Wed, 14 Mar 2018 17:05:25 -0500 | ||
| 4 | Subject: [PATCH] Make sure sysroot paths don't end with a slash. | ||
| 5 | |||
| 6 | * session.cxx (parse_cmdline): Make sure a sysroot path does not end with | ||
| 7 | a '/', since we build paths like: sysroot + "/lib/modules". If the | ||
| 8 | sysroot path ends with a '/', we end up with paths like | ||
| 9 | '/SYSROOT//lib/modules'. | ||
| 10 | (setup_kernel_release): Take a string parameter, not a character pointer. | ||
| 11 | * session.h: Update setup_kernel_release() prototype. | ||
| 12 | |||
| 13 | Upstream-Status: Backport | ||
| 14 | Signed-off-by: Victor Kamensky <kamensky@cisco.com> | ||
| 15 | --- | ||
| 16 | session.cxx | 34 ++++++++++++++++++++++++++-------- | ||
| 17 | session.h | 2 +- | ||
| 18 | 2 files changed, 27 insertions(+), 9 deletions(-) | ||
| 19 | |||
| 20 | Index: git/session.cxx | ||
| 21 | =================================================================== | ||
| 22 | --- git.orig/session.cxx | ||
| 23 | +++ git/session.cxx | ||
| 24 | @@ -722,6 +722,9 @@ systemtap_session::parse_cmdline (int ar | ||
| 25 | client_options_disallowed_for_unprivileged = ""; | ||
| 26 | std::set<std::string> additional_unwindsym_modules; | ||
| 27 | struct rlimit our_rlimit; | ||
| 28 | + bool sysroot_option_seen = false; | ||
| 29 | + string kernel_release_value; | ||
| 30 | + | ||
| 31 | while (true) | ||
| 32 | { | ||
| 33 | char * num_endptr; | ||
| 34 | @@ -887,7 +890,7 @@ systemtap_session::parse_cmdline (int ar | ||
| 35 | // Note that '-' must come last in a regex bracket expression. | ||
| 36 | assert_regexp_match("-r parameter from client", optarg, "^[a-z0-9_.+-]+$"); | ||
| 37 | server_args.push_back (string ("-") + (char)grc + optarg); | ||
| 38 | - setup_kernel_release(optarg); | ||
| 39 | + kernel_release_value = optarg; | ||
| 40 | break; | ||
| 41 | |||
| 42 | case 'a': | ||
| 43 | @@ -1473,7 +1476,7 @@ systemtap_session::parse_cmdline (int ar | ||
| 44 | if (client_options) { | ||
| 45 | cerr << _F("ERROR: %s invalid with %s", "--sysroot", "--client-options") << endl; | ||
| 46 | return 1; | ||
| 47 | - } else if (!sysroot.empty()) { | ||
| 48 | + } else if (sysroot_option_seen) { | ||
| 49 | cerr << "ERROR: multiple --sysroot options not supported" << endl; | ||
| 50 | return 1; | ||
| 51 | } else { | ||
| 52 | @@ -1487,11 +1490,17 @@ systemtap_session::parse_cmdline (int ar | ||
| 53 | |||
| 54 | sysroot = string(spath); | ||
| 55 | free (spath); | ||
| 56 | - if (sysroot[sysroot.size() - 1] != '/') | ||
| 57 | - sysroot.append("/"); | ||
| 58 | |||
| 59 | - break; | ||
| 60 | + // We do path creation like this: | ||
| 61 | + // sysroot + "/lib/modules" | ||
| 62 | + // So, we don't want the sysroot path to end with a '/', | ||
| 63 | + // otherwise we'll end up with '/foo//lib/modules'. | ||
| 64 | + if (sysroot.back() == '/') { | ||
| 65 | + sysroot.pop_back(); | ||
| 66 | + } | ||
| 67 | } | ||
| 68 | + sysroot_option_seen = true; | ||
| 69 | + break; | ||
| 70 | |||
| 71 | case LONG_OPT_SYSENV: | ||
| 72 | if (client_options) { | ||
| 73 | @@ -1501,7 +1510,7 @@ systemtap_session::parse_cmdline (int ar | ||
| 74 | string sysenv_str = optarg; | ||
| 75 | string value; | ||
| 76 | size_t pos; | ||
| 77 | - if (sysroot.empty()) { | ||
| 78 | + if (! sysroot_option_seen) { | ||
| 79 | cerr << "ERROR: --sysenv must follow --sysroot" << endl; | ||
| 80 | return 1; | ||
| 81 | } | ||
| 82 | @@ -1646,6 +1655,15 @@ systemtap_session::parse_cmdline (int ar | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | + if (! kernel_release_value.empty()) | ||
| 87 | + { | ||
| 88 | + setup_kernel_release(kernel_release_value); | ||
| 89 | + } | ||
| 90 | + else if (! sysroot.empty()) | ||
| 91 | + { | ||
| 92 | + kernel_build_tree = sysroot + "/lib/modules/" + kernel_release + "/build"; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | return 0; | ||
| 96 | } | ||
| 97 | |||
| 98 | @@ -2152,7 +2170,7 @@ void systemtap_session::insert_loaded_mo | ||
| 99 | } | ||
| 100 | |||
| 101 | void | ||
| 102 | -systemtap_session::setup_kernel_release (const char* kstr) | ||
| 103 | +systemtap_session::setup_kernel_release (const string& kstr) | ||
| 104 | { | ||
| 105 | // Sometimes we may get dupes here... e.g. a server may have a full | ||
| 106 | // -r /path/to/kernel followed by a client's -r kernel. | ||
| 107 | @@ -2183,7 +2201,7 @@ systemtap_session::setup_kernel_release | ||
| 108 | else | ||
| 109 | { | ||
| 110 | update_release_sysroot = true; | ||
| 111 | - kernel_release = string (kstr); | ||
| 112 | + kernel_release = kstr; | ||
| 113 | if (!kernel_release.empty()) | ||
| 114 | kernel_build_tree = "/lib/modules/" + kernel_release + "/build"; | ||
| 115 | |||
| 116 | Index: git/session.h | ||
| 117 | =================================================================== | ||
| 118 | --- git.orig/session.h | ||
| 119 | +++ git/session.h | ||
| 120 | @@ -144,7 +144,7 @@ public: | ||
| 121 | |||
| 122 | // NB: It is very important for all of the above (and below) fields | ||
| 123 | // to be cleared in the systemtap_session ctor (session.cxx). | ||
| 124 | - void setup_kernel_release (const char* kstr); | ||
| 125 | + void setup_kernel_release (const std::string& kstr); | ||
| 126 | void insert_loaded_modules (); | ||
| 127 | |||
| 128 | // command line parsing | ||
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-Use-sysroot-when-looking-for-the-System.map-file.patch b/meta/recipes-kernel/systemtap/systemtap/0001-Use-sysroot-when-looking-for-the-System.map-file.patch new file mode 100644 index 0000000000..b2820b31e8 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-Use-sysroot-when-looking-for-the-System.map-file.patch | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | From 436063d5e4738a9b03535d330a2242be5118e745 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: David Smith <dsmith@redhat.com> | ||
| 3 | Date: Thu, 8 Mar 2018 16:01:58 -0600 | ||
| 4 | Subject: [PATCH] Use sysroot when looking for the System.map file. | ||
| 5 | |||
| 6 | Add sysroot to system_map_path + "/boot/System.map" case. Otherwise | ||
| 7 | stap tries to look symbols on host system and it produce error like this: | ||
| 8 | |||
| 9 | > Kernel symbol table /boot/System.map-4.9.78-yocto-standard unavailable, (No such file or directory) | ||
| 10 | |||
| 11 | Upstream-Status: Backport | ||
| 12 | Signed-off-by: Victor Kamensky <kamensky@cisco.com> | ||
| 13 | --- | ||
| 14 | session.cxx | 2 +- | ||
| 15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 16 | |||
| 17 | Index: git/session.cxx | ||
| 18 | =================================================================== | ||
| 19 | --- git.orig/session.cxx | ||
| 20 | +++ git/session.cxx | ||
| 21 | @@ -2013,7 +2013,7 @@ systemtap_session::parse_kernel_function | ||
| 22 | clog << _F("Kernel symbol table %s unavailable, (%s)", | ||
| 23 | system_map_path.c_str(), strerror(errno)) << endl; | ||
| 24 | |||
| 25 | - system_map_path = "/boot/System.map-" + kernel_release; | ||
| 26 | + system_map_path = sysroot + "/boot/System.map-" + kernel_release; | ||
| 27 | system_map.clear(); | ||
| 28 | system_map.open(system_map_path.c_str(), ifstream::in); | ||
| 29 | if (! system_map.is_open()) | ||
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-_stp_umodule_relocate-needs-target-file-path-not-hos.patch b/meta/recipes-kernel/systemtap/systemtap/0001-_stp_umodule_relocate-needs-target-file-path-not-hos.patch new file mode 100644 index 0000000000..98181a1294 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-_stp_umodule_relocate-needs-target-file-path-not-hos.patch | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | From 183c7a7a8167333c873525f7908913837b8dc3cb Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Victor Kamensky <kamensky@cisco.com> | ||
| 3 | Date: Tue, 20 Mar 2018 12:41:05 -0500 | ||
| 4 | Subject: [PATCH] _stp_umodule_relocate needs target file path, not host file | ||
| 5 | path | ||
| 6 | |||
| 7 | Strip of sysroot from module name is required when _stp_umodule_relocate | ||
| 8 | call is generated. Otherwise path won't match path on target and could | ||
| 9 | will fail to calculated address within the file. | ||
| 10 | |||
| 11 | Upstream-Status: Backport | ||
| 12 | Signed-off-by: Victor Kamensky <kamensky@cisco.com> | ||
| 13 | --- | ||
| 14 | loc2stap.cxx | 5 ++++- | ||
| 15 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
| 16 | |||
| 17 | diff --git a/loc2stap.cxx b/loc2stap.cxx | ||
| 18 | index 4818ee0..e09954f 100644 | ||
| 19 | --- a/loc2stap.cxx | ||
| 20 | +++ b/loc2stap.cxx | ||
| 21 | @@ -17,6 +17,7 @@ | ||
| 22 | |||
| 23 | #include "loc2stap.h" | ||
| 24 | #include "dwflpp.h" | ||
| 25 | +#include "tapsets.h" | ||
| 26 | |||
| 27 | #if ! _ELFUTILS_PREREQ(0, 153) | ||
| 28 | #define DW_OP_GNU_entry_value 0xf3 | ||
| 29 | @@ -106,7 +107,9 @@ location_context::translate_address(Dwarf_Addr addr) | ||
| 30 | c = "/* pragma:vma */ " | ||
| 31 | "({ unsigned long addr = 0; " | ||
| 32 | "addr = _stp_umodule_relocate (\"" | ||
| 33 | - + resolve_path(dw->module_name.c_str()) + "\", " | ||
| 34 | + + path_remove_sysroot(dw->sess, | ||
| 35 | + resolve_path(dw->module_name.c_str())) | ||
| 36 | + + "\", " | ||
| 37 | + lex_cast_hex (addr) | ||
| 38 | + ", current); addr; })"; | ||
| 39 | } | ||
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-debuginfo-lookup-with-sysroot-case-do-not-remove-sys.patch b/meta/recipes-kernel/systemtap/systemtap/0001-debuginfo-lookup-with-sysroot-case-do-not-remove-sys.patch new file mode 100644 index 0000000000..160642db08 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-debuginfo-lookup-with-sysroot-case-do-not-remove-sys.patch | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | From b29e448e12040ed8f4d83743a14db0f138a7cc67 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Victor Kamensky <kamensky@cisco.com> | ||
| 3 | Date: Wed, 14 Mar 2018 16:54:08 -0500 | ||
| 4 | Subject: [PATCH] debuginfo lookup with sysroot case do not remove sysroot from | ||
| 5 | file_name | ||
| 6 | |||
| 7 | If sysroot option is passed, and debug symbols reside in sysroot along | ||
| 8 | with executable <foo> in <foo_dir>/.debug/<foo_file> directory, | ||
| 9 | stap fails to find debuginfo because it strips out sysroot path | ||
| 10 | from file_name so dwfl_standard_find_debuginfo ends up looking at | ||
| 11 | host <foo_dir>/.debug/<foo_file> rather then checking | ||
| 12 | <sysroot>/<foo_dir>/.debug/<foo_file>. | ||
| 13 | |||
| 14 | Upstream-Status: Backport | ||
| 15 | Signed-off-by: Victor Kamensky <kamensky@cisco.com> | ||
| 16 | --- | ||
| 17 | setupdwfl.cxx | 12 ------------ | ||
| 18 | 1 file changed, 12 deletions(-) | ||
| 19 | |||
| 20 | diff --git a/setupdwfl.cxx b/setupdwfl.cxx | ||
| 21 | index 11e0bb2..2a87982 100644 | ||
| 22 | --- a/setupdwfl.cxx | ||
| 23 | +++ b/setupdwfl.cxx | ||
| 24 | @@ -627,18 +627,6 @@ internal_find_debuginfo (Dwfl_Module *mod, | ||
| 25 | |||
| 26 | call_dwfl_standard_find_debuginfo: | ||
| 27 | |||
| 28 | - if (current_session_for_find_debuginfo) | ||
| 29 | - { | ||
| 30 | - string sysroot = current_session_for_find_debuginfo->sysroot + "/*"; | ||
| 31 | - int found = fnmatch(sysroot.c_str(), file_name, 0); | ||
| 32 | - | ||
| 33 | - if (found) | ||
| 34 | - { | ||
| 35 | - file_name = file_name | ||
| 36 | - + current_session_for_find_debuginfo->sysroot.length() - 1; | ||
| 37 | - } | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | /* Call the original dwfl_standard_find_debuginfo */ | ||
| 41 | return dwfl_standard_find_debuginfo(mod, userdata, modname, base, | ||
| 42 | file_name, debuglink_file, | ||
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling-follow-u.patch b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling-follow-u.patch new file mode 100644 index 0000000000..6fe7d4d1cf --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling-follow-u.patch | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | From 7e11f129ff370ce5f39812ce2ae6ce40818a347f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Victor Kamensky <kamensky@cisco.com> | ||
| 3 | Date: Thu, 22 Mar 2018 16:02:02 -0500 | ||
| 4 | Subject: [PATCH] sysroot: fix short release -r option handling follow up | ||
| 5 | |||
| 6 | In case of sysroot set and short release -r option it does not make sense | ||
| 7 | to pass short release name into dwfl_linux_kernel_report_offline | ||
| 8 | function. This function is not aware about sysroot and it won't look for | ||
| 9 | kernel modules under sysroot directory. | ||
| 10 | |||
| 11 | Upstream-Status: Backport | ||
| 12 | Signed-off-by: Victor Kamensky <kamensky@cisco.com> | ||
| 13 | --- | ||
| 14 | setupdwfl.cxx | 10 +++++++++- | ||
| 15 | 1 file changed, 9 insertions(+), 1 deletion(-) | ||
| 16 | |||
| 17 | diff --git a/setupdwfl.cxx b/setupdwfl.cxx | ||
| 18 | index c419afa..0cf5810 100644 | ||
| 19 | --- a/setupdwfl.cxx | ||
| 20 | +++ b/setupdwfl.cxx | ||
| 21 | @@ -367,7 +367,15 @@ setup_dwfl_kernel (unsigned *modules_found, systemtap_session &s) | ||
| 22 | // hard-code this magic here. | ||
| 23 | string lib_path = s.sysroot + "/lib/modules/" + s.kernel_release + "/build"; | ||
| 24 | if (s.kernel_build_tree == lib_path) | ||
| 25 | - elfutils_kernel_path = s.kernel_release; | ||
| 26 | + { | ||
| 27 | + if (s.sysroot != "") | ||
| 28 | + // If we have sysroot set does not make sense to pass | ||
| 29 | + // short release to dwfl, it won't take a sysroot into | ||
| 30 | + // account. Let's construct full path in such case. | ||
| 31 | + elfutils_kernel_path = string(s.sysroot + "/lib/modules/" + s.kernel_release); | ||
| 32 | + else | ||
| 33 | + elfutils_kernel_path = s.kernel_release; | ||
| 34 | + } | ||
| 35 | else | ||
| 36 | elfutils_kernel_path = s.kernel_build_tree; | ||
| 37 | offline_modules_found = 0; | ||
| 38 | -- | ||
| 39 | 2.7.4 | ||
| 40 | |||
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling.patch b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling.patch new file mode 100644 index 0000000000..b31d6274e2 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling.patch | |||
| @@ -0,0 +1,53 @@ | |||
| 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. | ||
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch new file mode 100644 index 0000000000..8a3d39a5b8 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch | |||
| @@ -0,0 +1,117 @@ | |||
| 1 | From 2041085d1a700201dc088991ca8136e7935bf42f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Victor Kamensky <kamensky@cisco.com> | ||
| 3 | Date: Wed, 21 Mar 2018 11:35:26 -0500 | ||
| 4 | Subject: [PATCH] sysroot: handle symbolic links with absolute name relative to | ||
| 5 | sysroot | ||
| 6 | |||
| 7 | In case of symbolic link found under sysroot point to absolute path, | ||
| 8 | instead of trying to look for such absolute path in host system, | ||
| 9 | apply sysroot prefix first. | ||
| 10 | |||
| 11 | Upstream-Status: Backport | ||
| 12 | Signed-off-by: Victor Kamensky <kamensky@cisco.com> | ||
| 13 | --- | ||
| 14 | util.cxx | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 15 | 1 file changed, 76 insertions(+) | ||
| 16 | |||
| 17 | Index: git/util.cxx | ||
| 18 | =================================================================== | ||
| 19 | --- git.orig/util.cxx | ||
| 20 | +++ git/util.cxx | ||
| 21 | @@ -441,6 +441,64 @@ split_lines(const char *buf, size_t n) | ||
| 22 | return lines; | ||
| 23 | } | ||
| 24 | |||
| 25 | +static string | ||
| 26 | +follow_link(const string& name, const string& sysroot) | ||
| 27 | +{ | ||
| 28 | + char *linkname; | ||
| 29 | + ssize_t r; | ||
| 30 | + string retpath; | ||
| 31 | + struct stat st; | ||
| 32 | + | ||
| 33 | + const char *f = name.c_str(); | ||
| 34 | + | ||
| 35 | + lstat(f, &st); | ||
| 36 | + | ||
| 37 | + linkname = (char *) malloc(st.st_size + 1); | ||
| 38 | + | ||
| 39 | + if (linkname) | ||
| 40 | + { | ||
| 41 | + r = readlink(f, linkname, st.st_size + 1); | ||
| 42 | + linkname[st.st_size] = '\0'; | ||
| 43 | + /* | ||
| 44 | + * If we have non-empty sysroot and we got link that | ||
| 45 | + * points to absolute path name, we need to look at | ||
| 46 | + * this path relative to sysroot itself. access and | ||
| 47 | + * stat will follow symbolic links correctly only in | ||
| 48 | + * case with empty sysroot. | ||
| 49 | + */ | ||
| 50 | + while (r != -1 && linkname && linkname[0] == '/') | ||
| 51 | + { | ||
| 52 | + string fname1 = sysroot + linkname; | ||
| 53 | + const char *f1 = fname1.c_str(); | ||
| 54 | + if (access(f1, X_OK) == 0 | ||
| 55 | + && stat(f1, &st) == 0 | ||
| 56 | + && S_ISREG(st.st_mode)) | ||
| 57 | + { | ||
| 58 | + retpath = fname1; | ||
| 59 | + break; | ||
| 60 | + } | ||
| 61 | + else if (lstat(f1, &st) == 0 | ||
| 62 | + && S_ISLNK(st.st_mode)) | ||
| 63 | + { | ||
| 64 | + free(linkname); | ||
| 65 | + linkname = (char *) malloc(st.st_size + 1); | ||
| 66 | + if (linkname) | ||
| 67 | + { | ||
| 68 | + r = readlink(f1, linkname, st.st_size + 1); | ||
| 69 | + linkname[st.st_size] = '\0'; | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + else | ||
| 73 | + { | ||
| 74 | + break; | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + free(linkname); | ||
| 79 | + | ||
| 80 | + return retpath; | ||
| 81 | +} | ||
| 82 | + | ||
| 83 | // Resolve an executable name to a canonical full path name, with the | ||
| 84 | // same policy as execvp(). A program name not containing a slash | ||
| 85 | // will be searched along the $PATH. | ||
| 86 | @@ -465,6 +523,14 @@ string find_executable(const string& nam | ||
| 87 | if (name.find('/') != string::npos) // slash in the path already? | ||
| 88 | { | ||
| 89 | retpath = sysroot + name; | ||
| 90 | + | ||
| 91 | + const char *f = retpath.c_str(); | ||
| 92 | + if (sysroot != "" | ||
| 93 | + && lstat(f, &st) == 0 | ||
| 94 | + && S_ISLNK(st.st_mode)) | ||
| 95 | + { | ||
| 96 | + retpath = follow_link(f, sysroot); | ||
| 97 | + } | ||
| 98 | } | ||
| 99 | else // Nope, search $PATH. | ||
| 100 | { | ||
| 101 | @@ -493,6 +559,16 @@ string find_executable(const string& nam | ||
| 102 | retpath = fname; | ||
| 103 | break; | ||
| 104 | } | ||
| 105 | + else if (sysroot != "" | ||
| 106 | + && lstat(f, &st) == 0 | ||
| 107 | + && S_ISLNK(st.st_mode)) | ||
| 108 | + { | ||
| 109 | + retpath = follow_link(f, sysroot); | ||
| 110 | + if (retpath != "") | ||
| 111 | + { | ||
| 112 | + break; | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | } | ||
| 116 | } | ||
| 117 | } | ||
diff --git a/meta/recipes-kernel/systemtap/systemtap_git.inc b/meta/recipes-kernel/systemtap/systemtap_git.inc index eef0c9cbe1..e1b7789aed 100644 --- a/meta/recipes-kernel/systemtap/systemtap_git.inc +++ b/meta/recipes-kernel/systemtap/systemtap_git.inc | |||
| @@ -14,6 +14,15 @@ SRC_URI = "git://sourceware.org/git/systemtap.git \ | |||
| 14 | file://0001-staprun-stapbpf-don-t-support-installing-a-non-root.patch \ | 14 | file://0001-staprun-stapbpf-don-t-support-installing-a-non-root.patch \ |
| 15 | file://0001-Fix-PR22551-by-updating-the-use-of-timers-for-the-4..patch \ | 15 | file://0001-Fix-PR22551-by-updating-the-use-of-timers-for-the-4..patch \ |
| 16 | file://0001-Fixes-for-gcc-8.patch \ | 16 | file://0001-Fixes-for-gcc-8.patch \ |
| 17 | file://0001-Use-sysroot-when-looking-for-the-System.map-file.patch \ | ||
| 18 | file://0001-debuginfo-lookup-with-sysroot-case-do-not-remove-sys.patch \ | ||
| 19 | file://0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch \ | ||
| 20 | file://0001-sysroot-fix-short-release-r-option-handling.patch \ | ||
| 21 | file://0001-Delay-adding-sysroot-path-to-module-name-in-case-of-.patch \ | ||
| 22 | file://0001-Added-a-couple-of-small-sysroot-fixes.patch \ | ||
| 23 | file://0001-_stp_umodule_relocate-needs-target-file-path-not-hos.patch \ | ||
| 24 | file://0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch \ | ||
| 25 | file://0001-sysroot-fix-short-release-r-option-handling-follow-u.patch \ | ||
| 17 | " | 26 | " |
| 18 | 27 | ||
| 19 | COMPATIBLE_HOST = '(x86_64|i.86|powerpc|arm|aarch64|microblazeel|mips).*-linux' | 28 | COMPATIBLE_HOST = '(x86_64|i.86|powerpc|arm|aarch64|microblazeel|mips).*-linux' |
