From patchwork Thu Apr 5 18:25:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Victor Kamensky \(kamensky\)" X-Patchwork-Id: 132883 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6606332ljb; Thu, 5 Apr 2018 11:26:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/AOw3hjw25XPGcRp2tqZv+ssc4HAC2EXjd/8B3GkixlY4vZVQZ8TJU68ulajJ4Di8TC6wL X-Received: by 10.101.76.10 with SMTP id u10mr15794658pgq.445.1522952788030; Thu, 05 Apr 2018 11:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522952788; cv=none; d=google.com; s=arc-20160816; b=LJYmsZryGfCLDPeMUhLkpBuEqiYE8BdGdGPw5yTBXQoyqy5JAntfRvc+C/Z/Wdqgwb jQ2qVMLS5+3myWMWmVNgQ43lllFo316Z2D/1vaX5vhSfCmifgN4qa6OS1WYozyk7lghb FJ3Nj6KSYTipwm+bjr8PNakIx5MzLQQSvEel0HixMwFngLpxmw/+5kCMA29hfJ9gYgXf IuutFl/jTaDjcN93NhwOVU0uSh99oUMSn92VzJ7t47E5lsejsyI+gcdjst0RizXg+3dX eDphMS7cgJFph2Uxl6yHobP75f5bLTejcrPea6LiAYZOUu9DSPQP5ZR+3MDS7iQ+bYxZ YA9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=g3Lh6Q7m2B8M6OImR0pDa2Sx3gYAZdeoh631p+GDA0U=; b=0VNCccKq/Zg3A0llLVyGXyJoFIwOoZsL59H153xUqMz+GLbRkWgBrchLPUpszHiYZ9 UFGV7AkSkN3mM3nP80AZj520RF/c2ZRn8wGCaAVQNM14zqLHrhQ3A8wfVlkIjm4O4nRk dUSQdyFJz+cc6fvgREes2L2+dKl82MIgg692BSNwf98NMX4VciHKwPK94h51yHmIlvai 2TeySoyjKE+WMr/BH/Tkd4nVC+5Iq874imSQ9bn9aVWWRUs1HhZqNqB1s8fYeK5t1T6Z yrvDBWESJeDprSuLoRVdF0OupwOj1iIlp6VG5WWIjkPZ2f07/YQ5DcgRY+palnzC2SBs ZeXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cisco.com header.s=iport header.b=I2+TxzLO; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cisco.com Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id r26si5949346pgu.422.2018.04.05.11.26.27; Thu, 05 Apr 2018 11:26:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=fail header.i=@cisco.com header.s=iport header.b=I2+TxzLO; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cisco.com Received: from layers.openembedded.org (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id 312D075078; Thu, 5 Apr 2018 18:26:11 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from rcdn-iport-1.cisco.com (rcdn-iport-1.cisco.com [173.37.86.72]) by mail.openembedded.org (Postfix) with ESMTP id 9D8E775014 for ; Thu, 5 Apr 2018 18:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=27578; q=dns/txt; s=iport; t=1522952744; x=1524162344; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=vw08zk9qw/ZwRSzTSFMQoBusslReX2hrvhkDmNCNGp4=; b=I2+TxzLOK9+PLJzsIawHUleqjfD6I7Vs4YlcAq7CTchBJLbU7JYbnoxW Vojxf93Wmj2pv9xOS+liM0kswdbHHD7HvHyelJDVndprcavv1nqCzYUDz EQQIuxn/bPqJtxNgPHA8MVekuGsiIUTzShY4o4bk1cBnZmz3dkbFV507q 0=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AIAgBYacZa/5tdJa1cGQEBAQEBAQEBAQEBAQcBAQEBAYNCYW8omGiBdIEPixKHQxSBZgsbhGgCgj4hNhYBAgEBAQEBAQJsHAyFIgEDAxoNUhAcAwECFhlPCBmFDa4pM4hDgiWHaoITg1yEXg4hVYUVAoclhFBhimoIhVOIXgKBMDqDIIcxhymIMwIREwGBJSMIKYFSTSMVgn0JghcXEYhIhV4fMIpWgkUBAQ X-IronPort-AV: E=Sophos;i="5.48,412,1517875200"; d="scan'208";a="378321412" Received: from rcdn-core-4.cisco.com ([173.37.93.155]) by rcdn-iport-1.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2018 18:25:42 +0000 Received: from kamensky-w541.cisco.com ([10.24.32.120]) (authenticated bits=0) by rcdn-core-4.cisco.com (8.14.5/8.14.5) with ESMTP id w35IPUvk013347 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Thu, 5 Apr 2018 18:25:41 GMT From: Victor Kamensky To: openembedded-core@lists.openembedded.org Date: Thu, 5 Apr 2018 11:25:28 -0700 Message-Id: <1522952730-5967-4-git-send-email-kamensky@cisco.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522952730-5967-1-git-send-email-kamensky@cisco.com> References: <1522952730-5967-1-git-send-email-kamensky@cisco.com> X-Authenticated-User: kamensky@cisco.com Cc: Alexander Kanavin Subject: [OE-core] [PATCH v3 3/5] systemtap: support --sysroot option in variety of situations in cross build X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org For details on issues fixed please look at commit message of individual patches. Upstream-Status: Backport [systemtap@sourceware.org] Signed-off-by: Victor Kamensky --- ...001-Added-a-couple-of-small-sysroot-fixes.patch | 42 +++++++ ...g-sysroot-path-to-module-name-in-case-of-.patch | 61 ++++++++++ ...sure-sysroot-paths-don-t-end-with-a-slash.patch | 128 +++++++++++++++++++++ ...root-when-looking-for-the-System.map-file.patch | 29 +++++ ...e_relocate-needs-target-file-path-not-hos.patch | 39 +++++++ ...ookup-with-sysroot-case-do-not-remove-sys.patch | 42 +++++++ ...-short-release-r-option-handling-follow-u.patch | 40 +++++++ ...sroot-fix-short-release-r-option-handling.patch | 53 +++++++++ ...dle-symbolic-links-with-absolute-name-rel.patch | 117 +++++++++++++++++++ meta/recipes-kernel/systemtap/systemtap_git.inc | 9 ++ 10 files changed, 560 insertions(+) create mode 100644 meta/recipes-kernel/systemtap/systemtap/0001-Added-a-couple-of-small-sysroot-fixes.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0001-Delay-adding-sysroot-path-to-module-name-in-case-of-.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0001-Use-sysroot-when-looking-for-the-System.map-file.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0001-_stp_umodule_relocate-needs-target-file-path-not-hos.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0001-debuginfo-lookup-with-sysroot-case-do-not-remove-sys.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling-follow-u.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch -- 2.7.4 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core 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 0000000..c0ceb5a --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-Added-a-couple-of-small-sysroot-fixes.patch @@ -0,0 +1,42 @@ +From a714658727206d2a98a7194b7e6d29dbd3e27b8d Mon Sep 17 00:00:00 2001 +From: David Smith +Date: Mon, 19 Mar 2018 16:50:05 -0500 +Subject: [PATCH] Added a couple of small sysroot fixes. + +* tapsets.cxx (dwarf_builder::build): Fix commit 4ffecddf5. + (path_remove_sysroot): Fix extra '/' present at start of paths. + +Upstream-Status: Backport +Signed-off-by: Victor Kamensky +--- + tapsets.cxx | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +Index: git/tapsets.cxx +=================================================================== +--- git.orig/tapsets.cxx ++++ git/tapsets.cxx +@@ -1395,7 +1395,8 @@ string path_remove_sysroot(const systemt + string retval = path; + if (!sess.sysroot.empty() && + (pos = retval.find(sess.sysroot)) != string::npos) +- retval.replace(pos, sess.sysroot.length(), "/"); ++ retval.replace(pos, sess.sysroot.length(), ++ (sess.sysroot.back() == '/' ? "/": "")); + return retval; + } + +@@ -8412,8 +8413,11 @@ dwarf_builder::build(systemtap_session & + + // PR13338: unquote glob results + module_name = unescape_glob_chars (module_name); +- user_path = find_executable (module_name, "", sess.sysenv); // canonicalize it +- if (!is_fully_resolved(user_path, sess.sysroot, sess.sysenv)) ++ user_path = find_executable (module_name, sess.sysroot, sess.sysenv); // canonicalize it ++ // Note we don't need to pass the sysroot to ++ // is_fully_resolved(), since we just passed it to ++ // find_executable(). ++ if (!is_fully_resolved(user_path, "", sess.sysenv)) + throw SEMANTIC_ERROR(_F("cannot find executable '%s'", + user_path.to_string().c_str())); + 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 0000000..89951a2 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-Delay-adding-sysroot-path-to-module-name-in-case-of-.patch @@ -0,0 +1,61 @@ +From 4ffecddf5433d65a6f01241990c9d516586b1c79 Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Mon, 19 Mar 2018 08:53:51 -0500 +Subject: [PATCH] Delay adding sysroot path to module name in case of non + absolute executable + +Current stap code adds sysroot prematurely for probes that specify non +absolute path name, i.e like "foo", so when find_executable called it +receives full path as /foo and find_executable does not search +PATH while applying sysroot. + +Fix delays adding sysroot till path inside of sysroot is searched first. + +Also fix missing sysroot addition in glob expansion case. + +Upstream-Status: Backport +Signed-off-by: Victor Kamensky +--- + tapsets.cxx | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +Index: git/tapsets.cxx +=================================================================== +--- git.orig/tapsets.cxx ++++ git/tapsets.cxx +@@ -746,7 +746,7 @@ base_query::base_query(dwflpp & dw, lite + pid_val = 0; + get_string_param(params, TOK_PROCESS, module_val); + } +- module_val = find_executable (module_val, "", sess.sysenv); ++ module_val = find_executable (module_val, sess.sysroot, sess.sysenv); + if (!is_fully_resolved(module_val, "", sess.sysenv)) + throw SEMANTIC_ERROR(_F("cannot find executable '%s'", + module_val.to_string().c_str())); +@@ -8287,7 +8287,6 @@ dwarf_builder::build(systemtap_session & + } + else + { +- module_name = (string)sess.sysroot + (string)module_name; + filled_parameters[TOK_PROCESS] = new literal_string(module_name); + } + } +@@ -8321,7 +8320,8 @@ dwarf_builder::build(systemtap_session & + assert (lit); + + // Evaluate glob here, and call derive_probes recursively with each match. +- const auto& globs = glob_executable (module_name); ++ const auto& globs = glob_executable (sess.sysroot ++ + string(module_name)); + unsigned results_pre = finished_results.size(); + for (auto it = globs.begin(); it != globs.end(); ++it) + { +@@ -8413,7 +8413,7 @@ dwarf_builder::build(systemtap_session & + // PR13338: unquote glob results + module_name = unescape_glob_chars (module_name); + user_path = find_executable (module_name, "", sess.sysenv); // canonicalize it +- if (!is_fully_resolved(user_path, "", sess.sysenv)) ++ if (!is_fully_resolved(user_path, sess.sysroot, sess.sysenv)) + throw SEMANTIC_ERROR(_F("cannot find executable '%s'", + user_path.to_string().c_str())); + 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 0000000..7cd9030 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch @@ -0,0 +1,128 @@ +From 41efad04730be89889d1483719f9a6c9396dc250 Mon Sep 17 00:00:00 2001 +From: David Smith +Date: Wed, 14 Mar 2018 17:05:25 -0500 +Subject: [PATCH] Make sure sysroot paths don't end with a slash. + +* session.cxx (parse_cmdline): Make sure a sysroot path does not end with + a '/', since we build paths like: sysroot + "/lib/modules". If the + sysroot path ends with a '/', we end up with paths like + '/SYSROOT//lib/modules'. + (setup_kernel_release): Take a string parameter, not a character pointer. +* session.h: Update setup_kernel_release() prototype. + +Upstream-Status: Backport +Signed-off-by: Victor Kamensky +--- + session.cxx | 34 ++++++++++++++++++++++++++-------- + session.h | 2 +- + 2 files changed, 27 insertions(+), 9 deletions(-) + +Index: git/session.cxx +=================================================================== +--- git.orig/session.cxx ++++ git/session.cxx +@@ -722,6 +722,9 @@ systemtap_session::parse_cmdline (int ar + client_options_disallowed_for_unprivileged = ""; + std::set additional_unwindsym_modules; + struct rlimit our_rlimit; ++ bool sysroot_option_seen = false; ++ string kernel_release_value; ++ + while (true) + { + char * num_endptr; +@@ -887,7 +890,7 @@ systemtap_session::parse_cmdline (int ar + // Note that '-' must come last in a regex bracket expression. + assert_regexp_match("-r parameter from client", optarg, "^[a-z0-9_.+-]+$"); + server_args.push_back (string ("-") + (char)grc + optarg); +- setup_kernel_release(optarg); ++ kernel_release_value = optarg; + break; + + case 'a': +@@ -1473,7 +1476,7 @@ systemtap_session::parse_cmdline (int ar + if (client_options) { + cerr << _F("ERROR: %s invalid with %s", "--sysroot", "--client-options") << endl; + return 1; +- } else if (!sysroot.empty()) { ++ } else if (sysroot_option_seen) { + cerr << "ERROR: multiple --sysroot options not supported" << endl; + return 1; + } else { +@@ -1487,11 +1490,17 @@ systemtap_session::parse_cmdline (int ar + + sysroot = string(spath); + free (spath); +- if (sysroot[sysroot.size() - 1] != '/') +- sysroot.append("/"); + +- break; ++ // We do path creation like this: ++ // sysroot + "/lib/modules" ++ // So, we don't want the sysroot path to end with a '/', ++ // otherwise we'll end up with '/foo//lib/modules'. ++ if (sysroot.back() == '/') { ++ sysroot.pop_back(); ++ } + } ++ sysroot_option_seen = true; ++ break; + + case LONG_OPT_SYSENV: + if (client_options) { +@@ -1501,7 +1510,7 @@ systemtap_session::parse_cmdline (int ar + string sysenv_str = optarg; + string value; + size_t pos; +- if (sysroot.empty()) { ++ if (! sysroot_option_seen) { + cerr << "ERROR: --sysenv must follow --sysroot" << endl; + return 1; + } +@@ -1646,6 +1655,15 @@ systemtap_session::parse_cmdline (int ar + } + } + ++ if (! kernel_release_value.empty()) ++ { ++ setup_kernel_release(kernel_release_value); ++ } ++ else if (! sysroot.empty()) ++ { ++ kernel_build_tree = sysroot + "/lib/modules/" + kernel_release + "/build"; ++ } ++ + return 0; + } + +@@ -2152,7 +2170,7 @@ void systemtap_session::insert_loaded_mo + } + + void +-systemtap_session::setup_kernel_release (const char* kstr) ++systemtap_session::setup_kernel_release (const string& kstr) + { + // Sometimes we may get dupes here... e.g. a server may have a full + // -r /path/to/kernel followed by a client's -r kernel. +@@ -2183,7 +2201,7 @@ systemtap_session::setup_kernel_release + else + { + update_release_sysroot = true; +- kernel_release = string (kstr); ++ kernel_release = kstr; + if (!kernel_release.empty()) + kernel_build_tree = "/lib/modules/" + kernel_release + "/build"; + +Index: git/session.h +=================================================================== +--- git.orig/session.h ++++ git/session.h +@@ -144,7 +144,7 @@ public: + + // NB: It is very important for all of the above (and below) fields + // to be cleared in the systemtap_session ctor (session.cxx). +- void setup_kernel_release (const char* kstr); ++ void setup_kernel_release (const std::string& kstr); + void insert_loaded_modules (); + + // 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 0000000..b2820b3 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-Use-sysroot-when-looking-for-the-System.map-file.patch @@ -0,0 +1,29 @@ +From 436063d5e4738a9b03535d330a2242be5118e745 Mon Sep 17 00:00:00 2001 +From: David Smith +Date: Thu, 8 Mar 2018 16:01:58 -0600 +Subject: [PATCH] Use sysroot when looking for the System.map file. + +Add sysroot to system_map_path + "/boot/System.map" case. Otherwise +stap tries to look symbols on host system and it produce error like this: + +> Kernel symbol table /boot/System.map-4.9.78-yocto-standard unavailable, (No such file or directory) + +Upstream-Status: Backport +Signed-off-by: Victor Kamensky +--- + session.cxx | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: git/session.cxx +=================================================================== +--- git.orig/session.cxx ++++ git/session.cxx +@@ -2013,7 +2013,7 @@ systemtap_session::parse_kernel_function + clog << _F("Kernel symbol table %s unavailable, (%s)", + system_map_path.c_str(), strerror(errno)) << endl; + +- system_map_path = "/boot/System.map-" + kernel_release; ++ system_map_path = sysroot + "/boot/System.map-" + kernel_release; + system_map.clear(); + system_map.open(system_map_path.c_str(), ifstream::in); + 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 0000000..98181a1 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-_stp_umodule_relocate-needs-target-file-path-not-hos.patch @@ -0,0 +1,39 @@ +From 183c7a7a8167333c873525f7908913837b8dc3cb Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Tue, 20 Mar 2018 12:41:05 -0500 +Subject: [PATCH] _stp_umodule_relocate needs target file path, not host file + path + +Strip of sysroot from module name is required when _stp_umodule_relocate +call is generated. Otherwise path won't match path on target and could +will fail to calculated address within the file. + +Upstream-Status: Backport +Signed-off-by: Victor Kamensky +--- + loc2stap.cxx | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/loc2stap.cxx b/loc2stap.cxx +index 4818ee0..e09954f 100644 +--- a/loc2stap.cxx ++++ b/loc2stap.cxx +@@ -17,6 +17,7 @@ + + #include "loc2stap.h" + #include "dwflpp.h" ++#include "tapsets.h" + + #if ! _ELFUTILS_PREREQ(0, 153) + #define DW_OP_GNU_entry_value 0xf3 +@@ -106,7 +107,9 @@ location_context::translate_address(Dwarf_Addr addr) + c = "/* pragma:vma */ " + "({ unsigned long addr = 0; " + "addr = _stp_umodule_relocate (\"" +- + resolve_path(dw->module_name.c_str()) + "\", " ++ + path_remove_sysroot(dw->sess, ++ resolve_path(dw->module_name.c_str())) ++ + "\", " + + lex_cast_hex (addr) + + ", current); addr; })"; + } 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 0000000..160642d --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-debuginfo-lookup-with-sysroot-case-do-not-remove-sys.patch @@ -0,0 +1,42 @@ +From b29e448e12040ed8f4d83743a14db0f138a7cc67 Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Wed, 14 Mar 2018 16:54:08 -0500 +Subject: [PATCH] debuginfo lookup with sysroot case do not remove sysroot from + file_name + +If sysroot option is passed, and debug symbols reside in sysroot along +with executable in /.debug/ directory, +stap fails to find debuginfo because it strips out sysroot path +from file_name so dwfl_standard_find_debuginfo ends up looking at +host /.debug/ rather then checking +//.debug/. + +Upstream-Status: Backport +Signed-off-by: Victor Kamensky +--- + setupdwfl.cxx | 12 ------------ + 1 file changed, 12 deletions(-) + +diff --git a/setupdwfl.cxx b/setupdwfl.cxx +index 11e0bb2..2a87982 100644 +--- a/setupdwfl.cxx ++++ b/setupdwfl.cxx +@@ -627,18 +627,6 @@ internal_find_debuginfo (Dwfl_Module *mod, + + call_dwfl_standard_find_debuginfo: + +- if (current_session_for_find_debuginfo) +- { +- string sysroot = current_session_for_find_debuginfo->sysroot + "/*"; +- int found = fnmatch(sysroot.c_str(), file_name, 0); +- +- if (found) +- { +- file_name = file_name +- + current_session_for_find_debuginfo->sysroot.length() - 1; +- } +- } +- + /* Call the original dwfl_standard_find_debuginfo */ + return dwfl_standard_find_debuginfo(mod, userdata, modname, base, + 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 0000000..6fe7d4d --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling-follow-u.patch @@ -0,0 +1,40 @@ +From 7e11f129ff370ce5f39812ce2ae6ce40818a347f Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Thu, 22 Mar 2018 16:02:02 -0500 +Subject: [PATCH] sysroot: fix short release -r option handling follow up + +In case of sysroot set and short release -r option it does not make sense +to pass short release name into dwfl_linux_kernel_report_offline +function. This function is not aware about sysroot and it won't look for +kernel modules under sysroot directory. + +Upstream-Status: Backport +Signed-off-by: Victor Kamensky +--- + setupdwfl.cxx | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/setupdwfl.cxx b/setupdwfl.cxx +index c419afa..0cf5810 100644 +--- a/setupdwfl.cxx ++++ b/setupdwfl.cxx +@@ -367,7 +367,15 @@ setup_dwfl_kernel (unsigned *modules_found, systemtap_session &s) + // hard-code this magic here. + string lib_path = s.sysroot + "/lib/modules/" + s.kernel_release + "/build"; + if (s.kernel_build_tree == lib_path) +- elfutils_kernel_path = s.kernel_release; ++ { ++ if (s.sysroot != "") ++ // If we have sysroot set does not make sense to pass ++ // short release to dwfl, it won't take a sysroot into ++ // account. Let's construct full path in such case. ++ elfutils_kernel_path = string(s.sysroot + "/lib/modules/" + s.kernel_release); ++ else ++ elfutils_kernel_path = s.kernel_release; ++ } + else + elfutils_kernel_path = s.kernel_build_tree; + offline_modules_found = 0; +-- +2.7.4 + 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 0000000..b31d627 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling.patch @@ -0,0 +1,53 @@ +From a9ce89bcd2d78728faef59bda60e75510972cd56 Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Wed, 14 Mar 2018 17:09:44 -0500 +Subject: [PATCH] sysroot: fix short release -r option handling + +* setupdwfl.cxx (debuginfo_path_insert_sysroot): Add a '/' to the end of + the sysroot for path_insert_sysroot(). + (setup_dwfl_kernel): Simplify logic when finding the kernel path to send + to elfutils. + +Upstream-Status: Backport +Signed-off-by: Victor Kamensky +--- + setupdwfl.cxx | 19 ++++++++++++------- + 1 file changed, 12 insertions(+), 7 deletions(-) + +diff --git a/setupdwfl.cxx b/setupdwfl.cxx +index 2a87982..f6c3157 100644 +--- a/setupdwfl.cxx ++++ b/setupdwfl.cxx +@@ -339,6 +339,13 @@ static char * path_insert_sysroot(string sysroot, string path) + + void debuginfo_path_insert_sysroot(string sysroot) + { ++ // FIXME: This is a short-term fix, until we expect sysroot paths to ++ // always end with a '/' (and never be empty). ++ // ++ // The path_insert_sysroot() function assumes that sysroot has a '/' ++ // on the end. Make sure that is true. ++ if (sysroot.back() != '/') ++ sysroot.push_back('/'); + debuginfo_path = path_insert_sysroot(sysroot, debuginfo_path); + debuginfo_usr_path = path_insert_sysroot(sysroot, debuginfo_usr_path); + } +@@ -358,13 +365,11 @@ setup_dwfl_kernel (unsigned *modules_found, systemtap_session &s) + // no way to set the dwfl_callback.debuginfo_path and always + // passs the plain kernel_release here. So instead we have to + // hard-code this magic here. +- string lib_path = "/lib/modules/" + s.kernel_release + "/build"; +- if (s.kernel_build_tree == string(s.sysroot + lib_path) || +- (s.kernel_build_tree == lib_path +- && s.sysroot == "/")) +- elfutils_kernel_path = s.kernel_release; +- else +- elfutils_kernel_path = s.kernel_build_tree; ++ string lib_path = s.sysroot + "/lib/modules/" + s.kernel_release + "/build"; ++ if (s.kernel_build_tree == lib_path) ++ elfutils_kernel_path = s.kernel_release; ++ else ++ elfutils_kernel_path = s.kernel_build_tree; + offline_modules_found = 0; + + // 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 0000000..8a3d39a --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch @@ -0,0 +1,117 @@ +From 2041085d1a700201dc088991ca8136e7935bf42f Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Wed, 21 Mar 2018 11:35:26 -0500 +Subject: [PATCH] sysroot: handle symbolic links with absolute name relative to + sysroot + +In case of symbolic link found under sysroot point to absolute path, +instead of trying to look for such absolute path in host system, +apply sysroot prefix first. + +Upstream-Status: Backport +Signed-off-by: Victor Kamensky +--- + util.cxx | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 76 insertions(+) + +Index: git/util.cxx +=================================================================== +--- git.orig/util.cxx ++++ git/util.cxx +@@ -441,6 +441,64 @@ split_lines(const char *buf, size_t n) + return lines; + } + ++static string ++follow_link(const string& name, const string& sysroot) ++{ ++ char *linkname; ++ ssize_t r; ++ string retpath; ++ struct stat st; ++ ++ const char *f = name.c_str(); ++ ++ lstat(f, &st); ++ ++ linkname = (char *) malloc(st.st_size + 1); ++ ++ if (linkname) ++ { ++ r = readlink(f, linkname, st.st_size + 1); ++ linkname[st.st_size] = '\0'; ++ /* ++ * If we have non-empty sysroot and we got link that ++ * points to absolute path name, we need to look at ++ * this path relative to sysroot itself. access and ++ * stat will follow symbolic links correctly only in ++ * case with empty sysroot. ++ */ ++ while (r != -1 && linkname && linkname[0] == '/') ++ { ++ string fname1 = sysroot + linkname; ++ const char *f1 = fname1.c_str(); ++ if (access(f1, X_OK) == 0 ++ && stat(f1, &st) == 0 ++ && S_ISREG(st.st_mode)) ++ { ++ retpath = fname1; ++ break; ++ } ++ else if (lstat(f1, &st) == 0 ++ && S_ISLNK(st.st_mode)) ++ { ++ free(linkname); ++ linkname = (char *) malloc(st.st_size + 1); ++ if (linkname) ++ { ++ r = readlink(f1, linkname, st.st_size + 1); ++ linkname[st.st_size] = '\0'; ++ } ++ } ++ else ++ { ++ break; ++ } ++ } ++ } ++ free(linkname); ++ ++ return retpath; ++} ++ + // Resolve an executable name to a canonical full path name, with the + // same policy as execvp(). A program name not containing a slash + // will be searched along the $PATH. +@@ -465,6 +523,14 @@ string find_executable(const string& nam + if (name.find('/') != string::npos) // slash in the path already? + { + retpath = sysroot + name; ++ ++ const char *f = retpath.c_str(); ++ if (sysroot != "" ++ && lstat(f, &st) == 0 ++ && S_ISLNK(st.st_mode)) ++ { ++ retpath = follow_link(f, sysroot); ++ } + } + else // Nope, search $PATH. + { +@@ -493,6 +559,16 @@ string find_executable(const string& nam + retpath = fname; + break; + } ++ else if (sysroot != "" ++ && lstat(f, &st) == 0 ++ && S_ISLNK(st.st_mode)) ++ { ++ retpath = follow_link(f, sysroot); ++ if (retpath != "") ++ { ++ break; ++ } ++ } + } + } + } diff --git a/meta/recipes-kernel/systemtap/systemtap_git.inc b/meta/recipes-kernel/systemtap/systemtap_git.inc index eef0c9c..e1b7789 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 \ file://0001-staprun-stapbpf-don-t-support-installing-a-non-root.patch \ file://0001-Fix-PR22551-by-updating-the-use-of-timers-for-the-4..patch \ file://0001-Fixes-for-gcc-8.patch \ + file://0001-Use-sysroot-when-looking-for-the-System.map-file.patch \ + file://0001-debuginfo-lookup-with-sysroot-case-do-not-remove-sys.patch \ + file://0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch \ + file://0001-sysroot-fix-short-release-r-option-handling.patch \ + file://0001-Delay-adding-sysroot-path-to-module-name-in-case-of-.patch \ + file://0001-Added-a-couple-of-small-sysroot-fixes.patch \ + file://0001-_stp_umodule_relocate-needs-target-file-path-not-hos.patch \ + file://0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch \ + file://0001-sysroot-fix-short-release-r-option-handling-follow-u.patch \ " COMPATIBLE_HOST = '(x86_64|i.86|powerpc|arm|aarch64|microblazeel|mips).*-linux'