From patchwork Thu Apr 5 18:25:26 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: 132881 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6606105ljb; Thu, 5 Apr 2018 11:26:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/2k1sKmUTkB/BERQGwvDsUCCmtyq0j8hoXAdZOoysRuLn9Z2fVu0ids2yI+GlwIDRySbpn X-Received: by 10.167.131.147 with SMTP id u19mr17692241pfm.99.1522952775173; Thu, 05 Apr 2018 11:26:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522952775; cv=none; d=google.com; s=arc-20160816; b=LosWV4Lr9QPTC8sx/IqgzHtS3uHVaLxoil+QHwKNbqecPtrM/yUA7jKvTBz+GV3TLI LvzPqRH9qD1llBYlVNCXd1TWmOYy0xr/xVc8z+WfYdTqJMDI0eZtQrMYwLC8Q/iiWr8L 26ZNiKEIgQ6Az9+YiGi2Af0DcPEsBaRPVGwiTANGlr+H5hU3XECmiU3bGDoGtbqrCpPU cX7gV7EX8HqZbL+RObeDWxMmHGqBe67DN/wVipz55B32xbieIwmvrn1RG/5S3mFq1jJV LjXBP+JaleknmBzrDHfFff0kLebc+g9RNVmMi40YizKsM5MU0aU7i6ZXF0F8H9/5/zE1 1O1g== 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=WPxAEJTIc6ZyxXWdfqGxSRamPn/tu2sW33vgEAr1C6o=; b=AvwppUOTmDnsNmisNwL9oJ3zvGHYeFhUjOdeT5KvTeoBd8FVeRv8kKPP3+Le/0nieJ drM3Ry7eYZJxUl+/i2I30UiUaOHnhXjcqH6uBffetBNSjfYm2mNTx/rLiRj7z8ENzk12 C40lgwanLgI0aYkWbZoxd0uznneWM8+JeEP3pnbn6qVsMP5Syo8JQSRAJd6otzMeU2g+ UPF+RvrGRVq94xnKUOP6DbW8ncYuI+Cu4oRzR0EeDdJ7nFhPq6KIgDqhWelycs6hQ3zX QNH/W4n2HFOGZHfK4FTSDe4dGDRC/zHMsvF88Sa7F4azR8kePzRaGQYIKzogDHTzmiGa wJmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cisco.com header.s=iport header.b=RdpmI4bu; 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 q2si5816513pga.198.2018.04.05.11.26.14; Thu, 05 Apr 2018 11:26:15 -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=RdpmI4bu; 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 D69277506C; Thu, 5 Apr 2018 18:26:08 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from rcdn-iport-9.cisco.com (rcdn-iport-9.cisco.com [173.37.86.80]) by mail.openembedded.org (Postfix) with ESMTP id 7BC6674F1E for ; Thu, 5 Apr 2018 18:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1608; q=dns/txt; s=iport; t=1522952741; x=1524162341; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=0XkiMuSFI44IcA07WbWmGrCmlEg8oj/0P1YaUOAssiU=; b=RdpmI4buWdtA1vNMSr5I0egH56G9l2Di614y0GGRZ7m9rtvyzR9jioV3 /BL2CB/wYquuYHCBx/gz5FyOy6ZN3Ha9cuSLkA3LL4BR7EVAidnAhsIGW Xu9C+GZrPvrGjgph8BkKFRiMF0GweEGfijUQYKq3SPdfrYyPkm0Qoff8N o=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DHAABYacZa/5tdJa1cGQEBAQEBAQEBAQEBAQcBAQEBAYNCgVAoi1+NCYMDklWBeguFAwKCPiE0GAECAQEBAQEBAmwohSMGeRBRVxmFDa5ciEOCJYdqghODXIVvhGggAoxWimoIjjECjDuPXAIREwGBJRw4gVJNIxWCfZBuHzCNGwEB X-IronPort-AV: E=Sophos;i="5.48,411,1517875200"; d="scan'208";a="370205795" Received: from rcdn-core-4.cisco.com ([173.37.93.155]) by rcdn-iport-9.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2018 18:25:41 +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 w35IPUvi013347 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Thu, 5 Apr 2018 18:25:40 GMT From: Victor Kamensky To: openembedded-core@lists.openembedded.org Date: Thu, 5 Apr 2018 11:25:26 -0700 Message-Id: <1522952730-5967-2-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 1/5] image: add image-combined-dbg helper class 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 There is IMAGE_GEN_DEBUGFS="1" variable that enables build of additional rootfs-dbg and additional archive that contains complimentary symbols files for a given image. But the issue with this resulting directory and tarball that before use it has to be combined with original image content. It is required since all cross debugging tools like gdb, perf, and systemtap need file system that contains both target executables/libraries and their symbols. Those tools need to find executable/library first and through it debuglink note find corresponding symbols file. image-combined-dbg when added to USER_CLASSES just copies final resulting rootfs back into rootfs-dbg creating combined target and debug symbols rootfs that can be used for debugging directly. Signed-off-by: Victor Kamensky --- meta/classes/image-combined-dbg.bbclass | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 meta/classes/image-combined-dbg.bbclass -- 2.7.4 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core diff --git a/meta/classes/image-combined-dbg.bbclass b/meta/classes/image-combined-dbg.bbclass new file mode 100644 index 0000000..f4772f7 --- /dev/null +++ b/meta/classes/image-combined-dbg.bbclass @@ -0,0 +1,9 @@ +IMAGE_PREPROCESS_COMMAND_append = " combine_dbg_image; " + +combine_dbg_image () { + if [ "${IMAGE_GEN_DEBUGFS}" = "1" -a -e ${IMAGE_ROOTFS}-dbg ]; then + # copy target files into -dbg rootfs, so it can be used for + # debug purposes directly + tar -C ${IMAGE_ROOTFS} -cf - . | tar -C ${IMAGE_ROOTFS}-dbg -xf - + fi +} From patchwork Thu Apr 5 18:25:27 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: 132880 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6606033ljb; Thu, 5 Apr 2018 11:26:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx49jX3XABK3AKX9BGnaQooSFhID7b+sG0Pq9D5nJ4yYBrSjQa3q4aIFznNyDfUbLuHe3DpsE X-Received: by 10.99.95.214 with SMTP id t205mr15756485pgb.145.1522952769825; Thu, 05 Apr 2018 11:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522952769; cv=none; d=google.com; s=arc-20160816; b=XD+UxYEku3Fb3BVzAd+2/M4EHU8Sr9a6sUQIZuybUKqA3L4S4IX/kd0bTP3kCnXtZk aXWM5FegdKUIaoZMVMHT6BMW5/Cb6purxfRUP+Q3DPGYXUVHyS1HV6cwuO9l6Hl1wni9 KnUG/+CZ0FtKAOYfyPMkXjVa97yYwur/GX+EHaVZro2/D/gmhDxhOERDHd7HG5gYb/qx ffZTyMUj4y9FK76TXHPTQHz2eNZaa3Xd26IoAB/aUYvx1iyRcOTi0nnMhkCjHNjOALGv g9PGOGFguKiDL7KpqCeNXWbbhB5xA9eAG/P9YVhGvDH9HfBd+nA8dmvL2aPT6ajK1eEA PaGA== 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=+BYOHQpT++jf4gBxxyRmQ6A3NcxnOI3ac0Ihiw3ZhcM=; b=YNgAwTeUTkaECvfUBpAHXzQsLC6nsWUNvALp0T4/0gF9jGrD6j5+rTbR+qk/Pp0i5U iqxDTv9EhjH1mzJPnmAJWsz+8dwBMx7Ah+JqqTbAt13YcGBxTBpz9U7Ff8Gotnc8cmV/ XzGNdmzLPvMVLh39QQnQwukaANjDoB9QAN3TcqhvRnYwXB6VcttdO5J8RnSkwxpuYGCM SnNES9XZKYTDpOKrnOl8MaTY21LYqsrTJLwNYCV8PDy4+M7J0YDclrLKCaicM3elvMB8 jHtl/oKM2Vow0EVrjn4P26+gZtMMUGmJAdaOfiQ6qhODJBEQl9Sc35ElNvSzHNCXC2qG Ulzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cisco.com header.s=iport header.b=Li4SYfoB; 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 k8si6381469pfi.243.2018.04.05.11.26.09; Thu, 05 Apr 2018 11:26:09 -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=Li4SYfoB; 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 5BED774FB8; Thu, 5 Apr 2018 18:26:07 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from rcdn-iport-4.cisco.com (rcdn-iport-4.cisco.com [173.37.86.75]) by mail.openembedded.org (Postfix) with ESMTP id 7A7CC74C5E for ; Thu, 5 Apr 2018 18:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2242; q=dns/txt; s=iport; t=1522952742; x=1524162342; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=33bCibs251DhTwCR/r+oasZFLczgmqrT/DMkhN399xc=; b=Li4SYfoBZZoVLqatZixLEUzrrFEBx7BuI1ggxs25sY52NPOMEwlKfk7Q hdbnBO44B9GrbGfRDFMGITY4UcazDACPR28B7bkVjtiuI+PwTgbBIFquG kGZh1Rhq7YAQkq21JA5dJh/O8VO8/LmIDsrNwZXVK68z9qFP3A/nhg5li w=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DHAABYacZa/5tdJa1cGQEBAQEBAQEBAQEBAQcBAQEBAYNCYW8oi1+NCYMDixKHQ4F6CxuEaAKCPiE0GAECAQEBAQEBAmwcDIUjBnkQUVcZhQ2uXIhDgiWHaoITg1yFb4UIAoclhTGKagiFU4heAoFqilGPXAIREwGBJRw4gVJNIxWCfQmLB4VeHzCNGwEB X-IronPort-AV: E=Sophos;i="5.48,411,1517875200"; d="scan'208";a="376983089" Received: from rcdn-core-4.cisco.com ([173.37.93.155]) by rcdn-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2018 18:25:41 +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 w35IPUvj013347 (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:27 -0700 Message-Id: <1522952730-5967-3-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 2/5] Revert "systemtap: Cross compilation fix" 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 This reverts commit 787bed708676fc04aee2850825e803273152f657. Signed-off-by: Victor Kamensky --- .../systemtap/systemtap/system_map_location.patch | 23 ---------------------- meta/recipes-kernel/systemtap/systemtap_git.inc | 1 - 2 files changed, 24 deletions(-) delete mode 100644 meta/recipes-kernel/systemtap/systemtap/system_map_location.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/system_map_location.patch b/meta/recipes-kernel/systemtap/systemtap/system_map_location.patch deleted file mode 100644 index 013af5c..0000000 --- a/meta/recipes-kernel/systemtap/systemtap/system_map_location.patch +++ /dev/null @@ -1,23 +0,0 @@ -systemtap: Cross compilation fix - -This is a cross compilation fix. It allows systemtap to find -the kernel map file in the right place, i.e. in the kernel build tree. -Without this fix it takes a map file from the build host, if available. - -Upstream-Status: Pending - -Signed-off-by: Mikhail Durnev - -Index: git/session.cxx -=================================================================== ---- git.orig/session.cxx -+++ git/session.cxx -@@ -1634,7 +1634,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 = kernel_build_tree + "/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_git.inc b/meta/recipes-kernel/systemtap/systemtap_git.inc index 4d887ed..eef0c9c 100644 --- a/meta/recipes-kernel/systemtap/systemtap_git.inc +++ b/meta/recipes-kernel/systemtap/systemtap_git.inc @@ -4,7 +4,6 @@ SRCREV = "4051c70c9318c837981384cbb23f3e9eb1bd0892" PV = "3.2" SRC_URI = "git://sourceware.org/git/systemtap.git \ - file://system_map_location.patch \ file://configure-allow-to-disable-libvirt.patch \ file://x32_abi_time.patch \ file://monitor-option.patch \ 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' From patchwork Thu Apr 5 18:25:29 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: 132882 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6606231ljb; Thu, 5 Apr 2018 11:26:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+qvu/3kS4Pj8wxApeReAQ017QwSt/pMkWSFSSGCu5l4MDMPca1qTiVMcH1au3QPfVu5zZ1 X-Received: by 2002:a17:902:7b96:: with SMTP id w22-v6mr22370005pll.116.1522952781790; Thu, 05 Apr 2018 11:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522952781; cv=none; d=google.com; s=arc-20160816; b=PcC66+wSFxM74EFeljID1MFYQHJEXHNHe5ybR7PNczhLTyhksoQWPiR1XPCM7Iq09B K/tS6DtlBJPuaUBeDKrKbcMwXblmrCavU7MF1dQWQMgOhUaycOe546USJVS2rSgpvxJ2 XOIyeXVq0woMe+ksyg87PoRRG5Mep/mN/JrRCI5wDdy/IHYl+Y58aWhFv38U5V0hASr7 5tOI1vSkd4IdKlTL8o3/6mJRbKcgXmJrKRCRuZy+/GeUhSFr5rnNxYkW2nJlYQtEVd+O Ka/Sv4cpOxDghuAgB65ZRjhiquSTUQCYbRda2Nw0//drEvbL2sxYexQ32pDhjhXf3CG3 2lYA== 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=F5C/xqqZrpGjeMeouOJOPztAfCD/FHAP7ixHsgA1SoM=; b=s20469/5oqaSnJSVqm0XR9WL0I4lGOnZ70P8I1QcE/5YQXgkXCTfgR7D47bNDM19hH 1MtxMBrEdoNsX3bfhj7b3vRu5tlqaVDs4dz7B/VLqGDsvp62ZQpPRDuaPy6AX+XXptwU ZPYgEGlvx+YjMnYs+zv9o5kuyLxPJZY7Ccy0bQ+GRoSI8RL3u2Lx2HQUJ8OGX3orjeZv 91AXYvI6BZ9xSiQ0rR/AaeGgd+QikKyIaKPTbeHrS1+dHCvhGSKCiK7aM6Y32BrmDeXe SlxkzBeUlAF5EI+USC4+64iptAnjaWB2rduL/9PbDSKV9dFv1hHMbK+uhejfjE4H+W9F M6Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cisco.com header.s=iport header.b=O7ZQsdme; 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 v12-v6si6622064plz.487.2018.04.05.11.26.21; Thu, 05 Apr 2018 11:26:21 -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=O7ZQsdme; 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 0888D75073; Thu, 5 Apr 2018 18:26:10 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from rcdn-iport-4.cisco.com (rcdn-iport-4.cisco.com [173.37.86.75]) by mail.openembedded.org (Postfix) with ESMTP id D76AB74FD9 for ; Thu, 5 Apr 2018 18:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2349; q=dns/txt; s=iport; t=1522952743; x=1524162343; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Ci96IzX/ViY8ZrFku40t0ovC6txGMWKd1gTZhY8dukY=; b=O7ZQsdme6HsUmj2GUhPGoNd7EIYfm8c4hLoA4HgkfcKzvSklT88BK6Of pUp6LVtXfQ/G6UioyF+vsc5ezKB6XFdN8aeidBDTH1LVk9Kpv2nMf8WWO X/xPGLsafbdBDrpZ78gcTu2zoOZc5/7xBOrBPWiB8X3A7aGOxXRWWYB9i c=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AGAgBYacZa/5tdJa1cGQEBAQEBAQEBAQEBAQcBAQEBAYNCYW8omGiDA5JVgXoLH4RkAoI+ITYWAQIBAQEBAQECbBwMhSMGeRBRVxmFDa5ciEOCJYdqghODXIVvhQgCjFaKagiFU4heAow7iRqGQgIREwGBJSMDLoFSTSMVgn0JiweFXh8wjRsBAQ X-IronPort-AV: E=Sophos;i="5.48,411,1517875200"; d="scan'208";a="376983092" Received: from rcdn-core-4.cisco.com ([173.37.93.155]) by rcdn-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2018 18:25:43 +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 w35IPUvl013347 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Thu, 5 Apr 2018 18:25:42 GMT From: Victor Kamensky To: openembedded-core@lists.openembedded.org Date: Thu, 5 Apr 2018 11:25:29 -0700 Message-Id: <1522952730-5967-5-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 4/5] systemtap: create translator packageconfig 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 cases when systemap module compilation happens on host in cross-compilation mode, and it is desirable to minimize systemtap presense on target we need to have just smallest possible set of utilties that are required to run compiled modules. Introduce new "translator" PACKAGECONFIG, if it is not set it would mean that just minimal set of run-time utilities will be included in the package. For run-time only systemtap build variant use PACKAGECONFIG_pn-systemtap = "" or PACKAGECONFIG_pn-systemtap = "monitor" Suggested-by: Taras Kondratiuk Signed-off-by: Victor Kamensky --- meta/recipes-kernel/systemtap/systemtap_git.bb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) -- 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_git.bb b/meta/recipes-kernel/systemtap/systemtap_git.bb index 475b207..b280f58 100644 --- a/meta/recipes-kernel/systemtap/systemtap_git.bb +++ b/meta/recipes-kernel/systemtap/systemtap_git.bb @@ -3,9 +3,7 @@ HOMEPAGE = "https://sourceware.org/systemtap/" require systemtap_git.inc -DEPENDS = "boost elfutils" - -RDEPENDS_${PN} += "python3-core bash perl" +DEPENDS = "elfutils" EXTRA_OECONF += "--with-libelf=${STAGING_DIR_TARGET} --without-rpm \ --without-nss --without-avahi --without-dyninst \ @@ -18,7 +16,8 @@ STAP_DOCS ?= "--disable-docs --disable-publican --disable-refdocs" EXTRA_OECONF += "${STAP_DOCS} " -PACKAGECONFIG ??= "sqlite monitor python3-probes" +PACKAGECONFIG ??= "translator sqlite monitor python3-probes" +PACKAGECONFIG[translator] = "--enable-translator,--disable-translator,boost,python3-core bash perl" PACKAGECONFIG[libvirt] = "--enable-libvirt,--disable-libvirt,libvirt" PACKAGECONFIG[sqlite] = "--enable-sqlite,--disable-sqlite,sqlite3" PACKAGECONFIG[monitor] = "--enable-monitor,--disable-monitor,ncurses json-c" @@ -26,4 +25,12 @@ PACKAGECONFIG[python3-probes] = "--with-python3-probes,--without-python3-probes, inherit autotools gettext pkgconfig distutils3-base +do_install_append () { + if [ ! -f ${D}${bindir}/stap ]; then + # translator disabled case, need to leave only minimal runtime + rm -rf ${D}${datadir}/${PN} + rm ${D}${libexecdir}/${PN}/stap-env + fi +} + BBCLASSEXTEND = "nativesdk" From patchwork Thu Apr 5 18:25:30 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: 132884 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6606415ljb; Thu, 5 Apr 2018 11:26:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx49sFZ9ty1N06yBb3+vm+k1ZjW7xJL4IeqCk5TotgP/YvNoKOu/WlNs9zZn2JRkiN/v3SJwP X-Received: by 2002:a17:902:b10c:: with SMTP id q12-v6mr23675141plr.399.1522952795936; Thu, 05 Apr 2018 11:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522952795; cv=none; d=google.com; s=arc-20160816; b=v83ZOkLKcQ3bo1oAA2l53v97BRKFPu8GCndjYGKQRZ3Q30WHadCnCPuwIgN1ALMUWG 0hMt3v9GMzJkds+pmMgIIgEA3p1gRUBYBpSF0qh4ewZCaHIfY7OkIM944/+CHId9Pvsw K4/QHONpZovV+NYFvbLyXOPPruQY1GQNvUVuELQaGFZgfsQWU/rSl/tVz/kUfMfifJ+h bG6M/6YFQc4NbCfS3/CQCBBSK/maZKVHhZPLIBYSxaUwGPNPLLBXqCFjRYI4ackgWfg2 kLLt2foNQipy6lGhbafmZ7d24XrKZhYTWis5vDNjPHooZPv26fVTA08KK0sRUCbtu3Fi UTBQ== 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=MZkFNI2OffVPWkH4tnjBRXfjTZexGqgJFakXo7TWsxY=; b=eu5rvFxUXE05V1JiHPLKv8BpS7pT6pkm2KfOv+ve7h6ZQ5QZmH4AFQARZMwUo6eNHK s20XgrkhuYKcLmshmy/mNV0UxeZauA73KxlNWWdaIZSA0T2CZoEBUxQ3kUgcGVwbj5N5 3rzrd3ih7hCkkMmM5omlVw37qyTAWgY8iAhfwDbGMp/qhy7e/mzqCHXa0ybug0UifO1u F1px/1Ew6JQog9fxHC1Txq5r3FvEsfn6fuiFuAa5vT0M4ajr/jXBwUxIlPhZCL9WQucH 46gdr88QlbLwBYemcYHW7C/Ujrpu6APKeLkbEJMtUZsnel87phWke0gmcrxFY3CfqmVF nYlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cisco.com header.s=iport header.b=YAP75iBz; 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 j2si4537452pff.214.2018.04.05.11.26.35; Thu, 05 Apr 2018 11:26:35 -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=YAP75iBz; 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 CDEB97507E; Thu, 5 Apr 2018 18:26:15 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from rcdn-iport-2.cisco.com (rcdn-iport-2.cisco.com [173.37.86.73]) by mail.openembedded.org (Postfix) with ESMTP id 8DED074F1E for ; Thu, 5 Apr 2018 18:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=22876; q=dns/txt; s=iport; t=1522952745; x=1524162345; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=EKH07yMyZaNly7iel5DrG9+kz3OsJJi/zU7n3eNPuJo=; b=YAP75iBzXEmy/W/c3ZXeNW8JgsO03lnUps6T17bfVMug3IWM9v5uLrWE hryAF0QH7immgQab+UlVnBIWt5fHUc8dpVRYlrb5FaeFTKmb2ERVBn5tT 9/JC55sKWmjAvBvKORF+I3dJBWiyotbz79Q+h73r6DPzG5JTFtWEQW+/d 0=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AIAQBYacZa/5tdJa1cGQEBAQEBAQEBAQEBAQcBAQEBAYNCgVAoi1+NCYJpGpJVFIFmC4FYASGDCQKCPiE0GAECAQEBAQEBAmwohSMGeRBRVxmFDasPEYM8iEOCJYdqghOBDIJQhFwMhg8ChyWETwELVoopQQiIIIYRAow7hkKJGgIREwGBJRw4gVJNIxU6gkOCIBeONx8wAS+MawEB X-IronPort-AV: E=Sophos;i="5.48,411,1517875200"; d="scan'208";a="380131697" Received: from rcdn-core-4.cisco.com ([173.37.93.155]) by rcdn-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2018 18:25:43 +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 w35IPUvm013347 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Thu, 5 Apr 2018 18:25:43 GMT From: Victor Kamensky To: openembedded-core@lists.openembedded.org Date: Thu, 5 Apr 2018 11:25:30 -0700 Message-Id: <1522952730-5967-6-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 5/5] crosstap: replace script with new python based implementation 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 New crosstap python implementation is total replacement for crosstap shell script, that has superseding capabilities. New script support cross compiling of SystemTap scripts for user-land, by using supplied image rootfs. Whereas old script could only deal with scripts against kernel. New script has more complex logic and additional capabilities. As invocation interface new script support old "legacy" mode and provides alternative new regular options interface to access additional functionality. Signed-off-by: Victor Kamensky --- scripts/crosstap | 586 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 450 insertions(+), 136 deletions(-) -- 2.7.4 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core diff --git a/scripts/crosstap b/scripts/crosstap index 39739bb..e33fa4a 100755 --- a/scripts/crosstap +++ b/scripts/crosstap @@ -1,15 +1,22 @@ -#!/bin/bash +#!/usr/bin/env python3 # -# Run a systemtap script on remote target +# Build a systemtap script for a given image, kernel # -# Examples (run on build host, target is 192.168.1.xxx): -# $ source oe-init-build-env" -# $ cd ~/my/systemtap/scripts" +# Effectively script extracts needed information from set of +# 'bitbake -e' commands and contructs proper invocation of stap on +# host to build systemtap script for a given target. # -# $ crosstap root@192.168.1.xxx myscript.stp" -# $ crosstap root@192.168.1.xxx myscript-with-args.stp 99 ninetynine" +# By default script will compile scriptname.ko that could be copied +# to taget and activated with 'staprun scriptname.ko' command. Or if +# --remote user@hostname option is specified script will build, load +# execute script on target. # -# Copyright (c) 2012, Intel Corporation. +# This script is very similar and inspired by crosstap shell script. +# The major difference that this script supports user-land related +# systemtap script, whereas crosstap could deal only with scripts +# related to kernel. +# +# Copyright (c) 2018, Cisco Systems. # All rights reserved. # # This program is free software; you can redistribute it and/or modify @@ -25,131 +32,438 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -function usage() { - echo "Usage: $0 [additional systemtap-script args]" -} - -function setup_usage() { - echo "" - echo "'crosstap' requires a local sdk build of the target system" - echo "(or a build that includes 'tools-profile') in order to build" - echo "kernel modules that can probe the target system." - echo "" - echo "Practically speaking, that means you need to do the following:" - echo " - If you're running a pre-built image, download the release" - echo " and/or BSP tarballs used to build the image." - echo " - If you're working from git sources, just clone the metadata" - echo " and BSP layers needed to build the image you'll be booting." - echo " - Make sure you're properly set up to build a new image (see" - echo " the BSP README and/or the widely available basic documentation" - echo " that discusses how to build images)." - echo " - Build an -sdk version of the image e.g.:" - echo " $ bitbake core-image-sato-sdk" - echo " OR" - echo " - Build a non-sdk image but include the profiling tools:" - echo " [ edit local.conf and add 'tools-profile' to the end of" - echo " the EXTRA_IMAGE_FEATURES variable ]" - echo " $ bitbake core-image-sato" - echo "" - echo " [ NOTE that 'crosstap' needs to be able to ssh into the target" - echo " system, which isn't enabled by default in -minimal images. ]" - echo "" - echo "Once you've build the image on the host system, you're ready to" - echo "boot it (or the equivalent pre-built image) and use 'crosstap'" - echo "to probe it (you need to source the environment as usual first):" - echo "" - echo " $ source oe-init-build-env" - echo " $ cd ~/my/systemtap/scripts" - echo " $ crosstap root@192.168.1.xxx myscript.stp" - echo "" -} - -function systemtap_target_arch() { - SYSTEMTAP_TARGET_ARCH=$1 - case $SYSTEMTAP_TARGET_ARCH in - i?86) - SYSTEMTAP_TARGET_ARCH="i386" - ;; - x86?64*) - SYSTEMTAP_TARGET_ARCH="x86_64" - ;; - arm*) - SYSTEMTAP_TARGET_ARCH="arm" - ;; - powerpc*) - SYSTEMTAP_TARGET_ARCH="powerpc" - ;; - *) - ;; - esac -} - -if [ $# -lt 2 ]; then - usage - exit 1 -fi - -if [ -z "$BUILDDIR" ]; then - echo "Error: Unable to find the BUILDDIR environment variable." - echo "Did you forget to source your build system environment setup script?" - exit 1 -fi - -pushd $PWD -cd $BUILDDIR -BITBAKE_VARS=`bitbake -e virtual/kernel` -popd - -STAGING_BINDIR_TOOLCHAIN=$(echo "$BITBAKE_VARS" | grep ^STAGING_BINDIR_TOOLCHAIN \ - | cut -d '=' -f2 | cut -d '"' -f2) -STAGING_BINDIR_TOOLPREFIX=$(echo "$BITBAKE_VARS" | grep ^TARGET_PREFIX \ - | cut -d '=' -f2 | cut -d '"' -f2) -TARGET_ARCH=$(echo "$BITBAKE_VARS" | grep ^TRANSLATED_TARGET_ARCH \ - | cut -d '=' -f2 | cut -d '"' -f2) -TARGET_KERNEL_BUILDDIR=$(echo "$BITBAKE_VARS" | grep ^B= \ - | cut -d '=' -f2 | cut -d '"' -f2) - -# Build and populate the recipe-sysroot-native with systemtap-native -pushd $PWD -cd $BUILDDIR -BITBAKE_VARS=`bitbake -e systemtap-native` -popd -SYSTEMTAP_HOST_INSTALLDIR=$(echo "$BITBAKE_VARS" | grep ^STAGING_DIR_NATIVE \ - | cut -d '=' -f2 | cut -d '"' -f2) - -systemtap_target_arch "$TARGET_ARCH" - -if [ ! -d $TARGET_KERNEL_BUILDDIR ] || - [ ! -f $TARGET_KERNEL_BUILDDIR/vmlinux ]; then - echo -e "\nError: No target kernel build found." - echo -e "Did you forget to create a local build of your image?" - setup_usage - exit 1 -fi - -if [ ! -f $SYSTEMTAP_HOST_INSTALLDIR/usr/bin/stap ]; then - echo -e "\nError: Native (host) systemtap not found." - echo -e "Did you accidentally build a local non-sdk image? (or forget to" - echo -e "add 'tools-profile' to EXTRA_IMAGE_FEATURES in your local.conf)?" - echo -e "You can also: bitbake -c addto_recipe_sysroot systemtap-native" - setup_usage - exit 1 -fi - -target_user_hostname="$1" -full_script_name="$2" -script_name=$(basename "$2") -script_base=${script_name%.*} -shift 2 - -${SYSTEMTAP_HOST_INSTALLDIR}/usr/bin/stap \ - -a ${SYSTEMTAP_TARGET_ARCH} \ - -B CROSS_COMPILE="${STAGING_BINDIR_TOOLCHAIN}/${STAGING_BINDIR_TOOLPREFIX}" \ - -r ${TARGET_KERNEL_BUILDDIR} \ - -I ${SYSTEMTAP_HOST_INSTALLDIR}/usr/share/systemtap/tapset \ - -R ${SYSTEMTAP_HOST_INSTALLDIR}/usr/share/systemtap/runtime \ - --remote=$target_user_hostname \ - -m $script_base \ - $full_script_name "$@" - -exit 0 +import sys +import re +import subprocess +import os +import optparse + +class Stap(object): + def __init__(self, script, module, remote): + self.script = script + self.module = module + self.remote = remote + self.stap = None + self.sysroot = None + self.runtime = None + self.tapset = None + self.arch = None + self.cross_compile = None + self.kernel_release = None + self.target_path = None + self.target_ld_library_path = None + + if not self.remote: + if not self.module: + # derive module name from script + self.module = os.path.basename(self.script) + if self.module[-4:] == ".stp": + self.module = self.module[:-4] + # replace - if any with _ + self.module = self.module.replace("-", "_") + + def command(self, args): + ret = [] + ret.append(self.stap) + + if self.remote: + ret.append("--remote") + ret.append(self.remote) + else: + ret.append("-p4") + ret.append("-m") + ret.append(self.module) + + ret.append("-a") + ret.append(self.arch) + + ret.append("-B") + ret.append("CROSS_COMPILE=" + self.cross_compile) + + ret.append("-r") + ret.append(self.kernel_release) + + ret.append("-I") + ret.append(self.tapset) + + ret.append("-R") + ret.append(self.runtime) + + if self.sysroot: + ret.append("--sysroot") + ret.append(self.sysroot) + + ret.append("--sysenv=PATH=" + self.target_path) + ret.append("--sysenv=LD_LIBRARY_PATH=" + self.target_ld_library_path) + + ret = ret + args + + ret.append(self.script) + return ret + + def additional_environment(self): + ret = {} + ret["SYSTEMTAP_DEBUGINFO_PATH"] = "+:.debug:build" + return ret + + def environment(self): + ret = os.environ.copy() + additional = self.additional_environment() + for e in additional: + ret[e] = additional[e] + return ret + + def display_command(self, args): + additional_env = self.additional_environment() + command = self.command(args) + + print("#!/bin/sh") + for e in additional_env: + print("export %s=\"%s\"" % (e, additional_env[e])) + print(" ".join(command)) + +class BitbakeEnvInvocationException(Exception): + def __init__(self, message): + self.message = message + +class BitbakeEnv(object): + BITBAKE="bitbake" + + def __init__(self, package): + self.package = package + self.cmd = BitbakeEnv.BITBAKE + " -e " + self.package + self.popen = subprocess.Popen(self.cmd, shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + self.__lines = self.popen.stdout.readlines() + self.popen.wait() + + self.lines = [] + for line in self.__lines: + self.lines.append(line.decode('utf-8')) + + def get_vars(self, vars): + if self.popen.returncode: + raise BitbakeEnvInvocationException( + "\nFailed to execute '" + self.cmd + + "' with the following message:\n" + + ''.join(self.lines)) + + search_patterns = [] + retdict = {} + for var in vars: + # regular not exported variable + rexpr = "^" + var + "=\"(.*)\"" + re_compiled = re.compile(rexpr) + search_patterns.append((var, re_compiled)) + + # exported variable + rexpr = "^export " + var + "=\"(.*)\"" + re_compiled = re.compile(rexpr) + search_patterns.append((var, re_compiled)) + + for line in self.lines: + for var, rexpr in search_patterns: + m = rexpr.match(line) + if m: + value = m.group(1) + retdict[var] = value + + # fill variables values in order how they were requested + ret = [] + for var in vars: + ret.append(retdict.get(var)) + + # if it is single value list return it as scalar, not the list + if len(ret) == 1: + ret = ret[0] + + return ret + +class ParamDiscovery(object): + SYMBOLS_CHECK_MESSAGE = """ +WARNING: image '%s' does not have dbg-pkgs IMAGE_FEATURES enabled and no +"image-combined-dbg" in inherited classes is specified. As result the image +does not have symbols for user-land processes DWARF based probes. Consider +adding 'dbg-pkgs' to EXTRA_IMAGE_FEATURES or adding "image-combined-dbg" to +USER_CLASSES. I.e add this line 'USER_CLASSES += "image-combined-dbg"' to +local.conf file. + +Or you may use IMAGE_GEN_DEBUGFS="1" option, and then after build you need +recombine/unpack image and image-dbg tarballs and pass resulting dir location +with --sysroot option. +""" + + def __init__(self, image): + self.image = image + + self.image_rootfs = None + self.image_features = None + self.image_gen_debugfs = None + self.inherit = None + self.base_bindir = None + self.base_sbindir = None + self.base_libdir = None + self.bindir = None + self.sbindir = None + self.libdir = None + + self.staging_bindir_toolchain = None + self.target_prefix = None + self.target_arch = None + self.target_kernel_builddir = None + + self.staging_dir_native = None + + self.image_combined_dbg = False + + def discover(self): + if self.image: + benv_image = BitbakeEnv(self.image) + (self.image_rootfs, + self.image_features, + self.image_gen_debugfs, + self.inherit, + self.base_bindir, + self.base_sbindir, + self.base_libdir, + self.bindir, + self.sbindir, + self.libdir + ) = benv_image.get_vars( + ("IMAGE_ROOTFS", + "IMAGE_FEATURES", + "IMAGE_GEN_DEBUGFS", + "INHERIT", + "base_bindir", + "base_sbindir", + "base_libdir", + "bindir", + "sbindir", + "libdir" + )) + + benv_kernel = BitbakeEnv("virtual/kernel") + (self.staging_bindir_toolchain, + self.target_prefix, + self.target_arch, + self.target_kernel_builddir + ) = benv_kernel.get_vars( + ("STAGING_BINDIR_TOOLCHAIN", + "TARGET_PREFIX", + "TRANSLATED_TARGET_ARCH", + "B" + )) + + benv_systemtap = BitbakeEnv("systemtap-native") + (self.staging_dir_native + ) = benv_systemtap.get_vars(["STAGING_DIR_NATIVE"]) + + if self.inherit: + if "image-combined-dbg" in self.inherit.split(): + self.image_combined_dbg = True + + def check(self, sysroot_option): + ret = True + if self.image_rootfs: + sysroot = self.image_rootfs + if not os.path.isdir(self.image_rootfs): + print("ERROR: Cannot find '" + sysroot + + "' directory. Was '" + self.image + "' image built?") + ret = False + + stap = self.staging_dir_native + "/usr/bin/stap" + if not os.path.isfile(stap): + print("ERROR: Cannot find '" + stap + + "'. Was 'systemtap-native' built?") + ret = False + + if not os.path.isdir(self.target_kernel_builddir): + print("ERROR: Cannot find '" + self.target_kernel_builddir + + "' directory. Was 'kernel/virtual' built?") + ret = False + + if not sysroot_option and self.image_rootfs: + dbg_pkgs_found = False + + if self.image_features: + image_features = self.image_features.split() + if "dbg-pkgs" in image_features: + dbg_pkgs_found = True + + if not dbg_pkgs_found \ + and not self.image_combined_dbg: + print(ParamDiscovery.SYMBOLS_CHECK_MESSAGE % (self.image)) + + if not ret: + print("") + + return ret + + def __map_systemtap_arch(self): + a = self.target_arch + ret = a + if re.match('(athlon|x86.64)$', a): + ret = 'x86_64' + elif re.match('i.86$', a): + ret = 'i386' + elif re.match('arm$', a): + ret = 'arm' + elif re.match('aarch64$', a): + ret = 'arm64' + elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): + ret = 'mips' + elif re.match('p(pc|owerpc)(|64)', a): + ret = 'powerpc' + return ret + + def fill_stap(self, stap): + stap.stap = self.staging_dir_native + "/usr/bin/stap" + if not stap.sysroot: + if self.image_rootfs: + if self.image_combined_dbg: + stap.sysroot = self.image_rootfs + "-dbg" + else: + stap.sysroot = self.image_rootfs + stap.runtime = self.staging_dir_native + "/usr/share/systemtap/runtime" + stap.tapset = self.staging_dir_native + "/usr/share/systemtap/tapset" + stap.arch = self.__map_systemtap_arch() + stap.cross_compile = self.staging_bindir_toolchain + "/" + \ + self.target_prefix + stap.kernel_release = self.target_kernel_builddir + + # do we have standard that tells in which order these need to appear + target_path = [] + if self.sbindir: + target_path.append(self.sbindir) + if self.bindir: + target_path.append(self.bindir) + if self.base_sbindir: + target_path.append(self.base_sbindir) + if self.base_bindir: + target_path.append(self.base_bindir) + stap.target_path = ":".join(target_path) + + target_ld_library_path = [] + if self.libdir: + target_ld_library_path.append(self.libdir) + if self.base_libdir: + target_ld_library_path.append(self.base_libdir) + stap.target_ld_library_path = ":".join(target_ld_library_path) + + +def main(): + usage = """usage: %prog -s [options] [-- [systemtap options]] + +%prog cross compile given SystemTap script against given image, kernel + +It needs to run in environtment set for bitbake - it uses bitbake -e +invocations to retrieve information to construct proper stap cross build +invocation arguments. It assumes that systemtap-native is built in given +bitbake workspace. + +Anything after -- option is passed directly to stap. + +Legacy script invocation style supported but depreciated: + %prog [systemtap options] + +To enable most out of systemtap the following site.conf or local.conf +configuration is recommended: + +# enables symbol + target binaries rootfs-dbg in workspace +IMAGE_GEN_DEBUGFS = "1" +IMAGE_FSTYPES_DEBUGFS = "tar.bz2" +USER_CLASSES += "image-combined-dbg" + +# enables kernel debug symbols +KERNEL_EXTRA_FEATURES_append = " features/debug/debug-kernel.scc" + +# minimal, just run-time systemtap configuration in target image +PACKAGECONFIG_pn-systemtap = "monitor" + +# add systemtap run-time into target image if it is not there yet +IMAGE_INSTALL_append = " systemtap" +""" + option_parser = optparse.OptionParser(usage=usage) + + option_parser.add_option("-s", "--script", dest="script", + help="specify input script FILE name", + metavar="FILE") + + option_parser.add_option("-i", "--image", dest="image", + help="specify image name for which script should be compiled") + + option_parser.add_option("-r", "--remote", dest="remote", + help="specify username@hostname of remote target to run script " + "optional, it assumes that remote target can be accessed through ssh") + + option_parser.add_option("-m", "--module", dest="module", + help="specify module name, optional, has effect only if --remote is not used, " + "if not specified module name will be derived from passed script name") + + option_parser.add_option("-y", "--sysroot", dest="sysroot", + help="explicitely specify image sysroot location. May need to use it in case " + "when IMAGE_GEN_DEBUGFS=\"1\" option is used and recombined with symbols " + "in different location", + metavar="DIR") + + option_parser.add_option("-o", "--out", dest="out", + action="store_true", + help="output shell script that equvivalent invocation of this script with " + "given set of arguments, in given bitbake environment. It could be stored in " + "separate shell script and could be repeated without incuring bitbake -e " + "invocation overhead", + default=False) + + option_parser.add_option("-d", "--debug", dest="debug", + action="store_true", + help="enable debug output. Use this option to see resulting stap invocation", + default=False) + + # is invocation follow syntax from orignal crosstap shell script + legacy_args = False + + # check if we called the legacy way + if len(sys.argv) >= 3: + if sys.argv[1].find("@") != -1 and os.path.exists(sys.argv[2]): + legacy_args = True + + # fill options values for legacy invocation case + options = optparse.Values + options.script = sys.argv[2] + options.remote = sys.argv[1] + options.image = None + options.module = None + options.sysroot = None + options.out = None + options.debug = None + remaining_args = sys.argv[3:] + + if not legacy_args: + (options, remaining_args) = option_parser.parse_args() + + if not options.script or not os.path.exists(options.script): + print("'-s FILE' option is missing\n") + option_parser.print_help() + else: + stap = Stap(options.script, options.module, options.remote) + discovery = ParamDiscovery(options.image) + discovery.discover() + if not discovery.check(options.sysroot): + option_parser.print_help() + else: + stap.sysroot = options.sysroot + discovery.fill_stap(stap) + + if options.out: + stap.display_command(remaining_args) + else: + cmd = stap.command(remaining_args) + env = stap.environment() + + if options.debug: + print(" ".join(cmd)) + + os.execve(cmd[0], cmd, env) + +main()