From patchwork Tue Mar 6 17:50:37 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: 130825 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp4220958lja; Tue, 6 Mar 2018 09:51:06 -0800 (PST) X-Google-Smtp-Source: AG47ELvD0b1yqojGK5xjKu2GoGgOD9325VhUZwGKdEPgziIIZST6S4QowCafc7MJCi/kVFfuPCKA X-Received: by 2002:a17:902:d81:: with SMTP id 1-v6mr17829086plv.324.1520358665892; Tue, 06 Mar 2018 09:51:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520358665; cv=none; d=google.com; s=arc-20160816; b=SR+G2XxtYcRYDCRlHebRPiuJq/ZnDEuoP5ewIx7qQnn5HnEvxpfwkof4vz6CpbWn+L Y8sLxYfKJ+o71PaaDKiVqapdIotaGXV/mUD6y6PJGp9u6zF9VVOHEkZ7fRDn7QU3y4aU OnFzWBkorXPFjbhtiQmAnZ+pE6JbJHt51RhojlN8m/QUKdAMa0w3P2PzYOO+SQwkdrmC J3SZpHvX/R/mokdnvm2/uVRZqelVGlWycsihn/MW8o/nXBh30YizATQVntXSOQyNSaEK 4J8uM8i5qlIav/O2nlK86k71Ve07Qnk+LM9Z05GrrwfDXhXw03x0kpS/oxSymvZHdvQq 5MvQ== 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=68EZaFu5/dvaIG2fO1ETxs/cNKbJUUE2mkOfLDjm5lU=; b=VVivFFsdpwt/CHQTASg/MXQNrJkec9j+MSPzYvDzm2ng3BvJpT40PzT56G6gEoi6Gy SlcryZZ8RDOdstjBx5koQLOZaiKiybA411j1fOZXnPfb96Viz5NoI26CfzXYAYg42DRU YtXlqDt8bx0A5eFPWu7DdAqVzu3rsybPIaTfCHNqCP8i8TfYYGotCIlgYFkFwdbLTSir hdxb4uevxmlH//k0zT+hW9VHodUW5nYMbtCZ/zgEFII2DFeXPCdss6pgrOe54HHkoveh yEh/55PdMBJ0M9hiONDcaARgCfvxy6vkSH8SJslsuamd131ewhAJUI72AXDR97fQ17x2 4XyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cisco.com header.s=iport header.b=Vaj9aVt+; 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 k24si12401965pfh.151.2018.03.06.09.51.05; Tue, 06 Mar 2018 09:51:05 -0800 (PST) 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=Vaj9aVt+; 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 C1C0078AA6; Tue, 6 Mar 2018 17:51:02 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from rcdn-iport-3.cisco.com (rcdn-iport-3.cisco.com [173.37.86.74]) by mail.openembedded.org (Postfix) with ESMTP id C22E278A83 for ; Tue, 6 Mar 2018 17:50:49 +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=1520358651; x=1521568251; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=wZFLZHTnZeNK0kAU+BNJayfrit59KnU1+CuG+kQf66I=; b=Vaj9aVt+ADTfc2gHGFwS2B5ZmAQ5gj9AuzgFupG1EvGpRzomQ8M9JZjU fNQ7k7cYBFGC78zdaph62f5rulZ6RpETNLV3X7Grr6ElylMVQ+ZQ5SqhD wl1q5XwlLv7+Y9HsXCMU/HcbXGrcB9FoI8E162BCkOLJbxC3fybigfg4r Q=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BKAgCk055a/5xdJa1dGQEBAQEBAQEBAQEBAQcBAQEBAYNQZnAom3GDGIwYijEKG4UVAoMDITcVAQIBAQEBAQECayeFJAZ5EFFXGYUbqzqEcoN0giaFMYIuhjSGI4UhBIgjhk6LdgmGVIorAoIzjEORKQIRGQGBLjQigVJNIxWCfQmEYB83jCUBAQE X-IronPort-AV: E=Sophos;i="5.47,432,1515456000"; d="scan'208";a="353773035" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2018 17:50:50 +0000 Received: from kamensky-w541.cisco.com ([10.24.22.184]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.14.5/8.14.5) with ESMTP id w26HofYm007528 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Tue, 6 Mar 2018 17:50:50 GMT From: Victor Kamensky To: openembedded-core@lists.openembedded.org Date: Tue, 6 Mar 2018 09:50:37 -0800 Message-Id: <1520358641-7062-2-git-send-email-kamensky@cisco.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520358641-7062-1-git-send-email-kamensky@cisco.com> References: <1520358641-7062-1-git-send-email-kamensky@cisco.com> X-Authenticated-User: kamensky@cisco.com Cc: Alexander Kanavin Subject: [OE-core] [RFC PATCH 1/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 f51bd28..af5b004 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 Tue Mar 6 17:50:38 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: 130828 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp4221300lja; Tue, 6 Mar 2018 09:51:26 -0800 (PST) X-Google-Smtp-Source: AG47ELvcamXTC+TdokyftcBqf5MNL+Tmiv2lsNij/wcqHyi9Vb9KqT2Mc1dq4p+8oel8WvJkiNOq X-Received: by 10.101.68.82 with SMTP id e18mr15665473pgq.329.1520358686265; Tue, 06 Mar 2018 09:51:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520358686; cv=none; d=google.com; s=arc-20160816; b=k8nLriPz/tNOOKggp2DhyaoIADj7ccDrsVSucr83KHqKDa1CtVJpRmBM0W0KfC7IQf J+Vr2sI9N5pzAMriEItB/f3AD2XuJSvjtpkozKPVUXh8Xo3d9nbeGdpUzlfzVwKei3+l 2RW6CIrdnS3D6sCCY6Xky6KTDnDpoODQioUNEDmw5ChRW31sHQ8KRaGVfUluwOYekCu3 yZC/eqN9NTSmjiPw/kGrsyDXGE510aKjyiR7rzzuDhmTrAgr0WOH5rrou3IpYFxTu5QB xn57SfJl2gp6l0ZUYkeAcNTSq+xe+PY84Tz0wusvukuZyw+gKiou5WvU+fIdne8Ff0yF iCtQ== 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=ubp9YQbcOroap+XU0TlsWrWj0HXMoq5eY9cOq5j6BvA=; b=HwWJ3wcA0qDA+yNdZAIQO5Dso4ehyjyktjEnEhYPSN9ojpuV8inwMW4jEJDyuCK4sc meJn/lo6HZrwBWmUZc5w19l0mLuvKMp87/xF4GD+0nEf/j8u/Dkx6aoboRKyxF8A0s25 ygjh7C1oafTGJdqPXwTlI0m48xGEaMGZh2FBioYJrXkrPfJHxVjBZvB/itbDGCIahgKV tGUIu/oOUzcsffx/sWsRP8tFn+8FCV8ElORWY7HL2x4F8HeS9MZhk+ZJJ0rwcxQJAPta JnT7ZrvGgaDdiKtJa2YQIwQdnVEK7oU/7fD0rDZ0kX1yusu/n5cCT3yH4Weo3Pth2yx1 /7Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cisco.com header.s=iport header.b=Cm0NetgK; 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 27si12374189pft.376.2018.03.06.09.51.25; Tue, 06 Mar 2018 09:51:26 -0800 (PST) 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=Cm0NetgK; 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 885F978AB8; Tue, 6 Mar 2018 17:51:09 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from rcdn-iport-6.cisco.com (rcdn-iport-6.cisco.com [173.37.86.77]) by mail.openembedded.org (Postfix) with ESMTP id 9BC3C78AA5 for ; Tue, 6 Mar 2018 17:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=32755; q=dns/txt; s=iport; t=1520358653; x=1521568253; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ms9bTzpzbx8USAl1yiYkc2uGvQ+vGVxCrU8fIdeH21o=; b=Cm0NetgKpLYl/keOnPK1fyVLq952A8ayx0/eEBTvQl2/gO4yJzGsO4eF zKt/kfVAvnRgJBMcojXWDxQYbf+eHfsfgrLxbxP7wlMJseKE3L/EjEXJz yMtcSv8nMpQeLSjheTgNYFNzeNr1M6dzFIlAKy7umSGkDHCaaxf53jnC8 E=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BLAgCN1J5a/5xdJa1dGQEBAQEBAQEBAQEBAQcBAQEBAYNQZnAom3GCAoEWjBiIHBSCAQobgWSDMQKDAyE1FwECAQEBAQEBAmsnhSMBBhoBDFIQHAMBAhYZTwgZhRurCDqEcoN0giaFMYIuhjSFEgoEdoUuBIgcB4VZdUaLMAmGVIorAoFlToNngx6FPpEpAhEZAYEuIAMzgVJNIxWCfQmCWoIGHzeJXCuCHgEBAQ X-IronPort-AV: E=Sophos;i="5.47,432,1515456000"; d="scan'208";a="364343556" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-6.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2018 17:50:51 +0000 Received: from kamensky-w541.cisco.com ([10.24.22.184]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.14.5/8.14.5) with ESMTP id w26HofYn007528 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Tue, 6 Mar 2018 17:50:50 GMT From: Victor Kamensky To: openembedded-core@lists.openembedded.org Date: Tue, 6 Mar 2018 09:50:38 -0800 Message-Id: <1520358641-7062-3-git-send-email-kamensky@cisco.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520358641-7062-1-git-send-email-kamensky@cisco.com> References: <1520358641-7062-1-git-send-email-kamensky@cisco.com> X-Authenticated-User: kamensky@cisco.com Cc: Alexander Kanavin Subject: [OE-core] [RFC PATCH 2/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: Submitted [systemtap@sourceware.org] Change-Id: Id2fd0fbddb33e4a4387b732005a6e902a5c6129c Signed-off-by: Victor Kamensky --- ...-short-release-r-option-handling-in-case-.patch | 61 ++++++++ ...-short-release-r-option-handling-in-case-.patch | 68 +++++++++ ...uginfo-lookup-with-sysroot-case-do-not-re.patch | 97 +++++++++++++ ...ay-adding-sysroot-path-to-module-name-in-.patch | 124 ++++++++++++++++ ...dle-symbolic-links-with-absolute-name-rel.patch | 159 +++++++++++++++++++++ ...p_umodule_relocate-needs-receive-target-f.patch | 58 ++++++++ meta/recipes-kernel/systemtap/systemtap_git.inc | 6 + 7 files changed, 573 insertions(+) create mode 100644 meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling-in-case-.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0002-sysroot-fix-short-release-r-option-handling-in-case-.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0003-sysroot-debuginfo-lookup-with-sysroot-case-do-not-re.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0004-sysroot-delay-adding-sysroot-path-to-module-name-in-.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0005-sysroot-handle-symbolic-links-with-absolute-name-rel.patch create mode 100644 meta/recipes-kernel/systemtap/systemtap/0006-sysroot-_stp_umodule_relocate-needs-receive-target-f.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-sysroot-fix-short-release-r-option-handling-in-case-.patch b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling-in-case-.patch new file mode 100644 index 0000000..607c2cd --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-fix-short-release-r-option-handling-in-case-.patch @@ -0,0 +1,61 @@ +From 8fccac2483354a8a3e2419c36c867c81045dbe7f Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Thu, 8 Feb 2018 20:00:46 -0800 +Subject: [PATCH 1/6] sysroot: fix short release -r option handling in case of + sysroot read System.map symbols + +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) + +Here are steps to reproduce the issue. Note is produced by yocto +poky build. Under /lib/modules/4.9.78-yocto-standard/build there +is no System.map file; instead it is installed under /boot directory. + +[kamensky@coreos-lnx2 tests]$ cat meminfo.stp +probe kernel.function("meminfo_proc_show") { + println("meminfo_proc_show called") +} +[kamensky@coreos-lnx2 tests]$ export SYSTEMTAP_DEBUGINFO_PATH=+:.debug:build +[kamensky@coreos-lnx2 tests]$ /home/wd8/systemtap/20180208_2/packages/bin/stap --sysroot=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs -a x86_64 -r 4.9.78-yocto-standard -B CROSS_COMPILE=x86_64-poky-linux- --sysenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --sysenv=LD_LIBRARY_PATH=/lib:/usr/lib -p4 -v -v -m meminfo meminfo.stp +Systemtap translator/driver (version 3.3/0.170, commit release-3.2-92-g26c5e3c03c94 + changes) +Copyright (C) 2005-2017 Red Hat, Inc. and others +This is free software; see the source for copying conditions. +tested kernel versions: 2.6.18 ... 4.14-rc4 +enabled features: BPF PYTHON2 PYTHON3 LIBXML2 NLS +Created temporary directory "/tmp/staprq4IGE" +Session arch: x86_64 release: 4.9.78-yocto-standard +Kernel symbol table /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs//lib/modules/4.9.78-yocto-standard/build/System.map unavailable, (No such file or directory) +Kernel symbol table /boot/System.map-4.9.78-yocto-standard unavailable, (No such file or directory) +WARNING: Kernel function symbol table missing [man warning::symbols] + +semantic error: while resolving probe point: identifier 'kernel' at meminfo.stp:1:7 + thrown from: ../systemtap/elaborate.cxx:1080 + source: probe kernel.function("meminfo_proc_show") { + ^ + +semantic error: missing x86_64 kernel/module debuginfo [man warning::debuginfo] under '/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs//lib/modules/4.9.78-yocto-standard/build' + thrown from: ../systemtap/dwflpp.cxx:340 + +Signed-off-by: Victor Kamensky +--- + session.cxx | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/session.cxx b/session.cxx +index c7eaf6f..37caf3f 100644 +--- a/session.cxx ++++ b/session.cxx +@@ -2038,7 +2038,7 @@ systemtap_session::parse_kernel_functions () + 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()) +-- +2.7.4 + diff --git a/meta/recipes-kernel/systemtap/systemtap/0002-sysroot-fix-short-release-r-option-handling-in-case-.patch b/meta/recipes-kernel/systemtap/systemtap/0002-sysroot-fix-short-release-r-option-handling-in-case-.patch new file mode 100644 index 0000000..5a71b14 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0002-sysroot-fix-short-release-r-option-handling-in-case-.patch @@ -0,0 +1,68 @@ +From 0edd8b2c5d122c8b8c1b6a44b16bd05ce36f1616 Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Thu, 8 Feb 2018 20:13:40 -0800 +Subject: [PATCH 2/6] sysroot: fix short release -r option handling in case of + sysroot pass proper kernel modules + +In case of -r option getting short release (opposite to full path of +kernel build tree) stap passes short release name to +dwfl_linux_kernel_report_offline function and this function tries to +look up symbols in the host file system ignoring sysroot setting. + +Fix: in case of non empty, non "/" sysroot construct full path to +kernel modules directory and store it into elfutils_kernel_path variable. + +Here are steps how to reproduce the issue. Note is produced by +yocto poky build. + +[kamensky@coreos-lnx2 tests]$ cat meminfo.stp +probe kernel.function("meminfo_proc_show") { + println("meminfo_proc_show called") +} +[kamensky@coreos-lnx2 tests]$ /home/wd8/systemtap/20180208_2/packages/bin/stap --sysroot=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs -a x86_64 -r 4.9.78-yocto-standard -B CROSS_COMPILE=x86_64-poky-linux- --sysenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --sysenv=LD_LIBRARY_PATH=/lib:/usr/lib -p4 -v -m meminfo meminfo.stp +Pass 1: parsed user script and 480 library scripts using 230196virt/93452res/5364shr/88624data kb, in 340usr/30sys/375real ms. +semantic error: while resolving probe point: identifier 'kernel' at meminfo.stp:1:7 + source: probe kernel.function("meminfo_proc_show") { + ^ + +Running command under strace shows that stap is trying to open linux symbol file +on host file system, instead of looking at sysroot location: + +19517 openat(AT_FDCWD, "/boot/vmlinux-4.9.78-yocto-standard.debug", O_RDONLY) = -1 ENOENT (No such file or directory) +19517 openat(AT_FDCWD, "/boot/vmlinux-4.9.78-yocto-standard", O_RDONLY) = -1 ENOENT (No such file or directory) + +Signed-off-by: Victor Kamensky +--- + setupdwfl.cxx | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/setupdwfl.cxx b/setupdwfl.cxx +index 11e0bb2..f00cf75 100644 +--- a/setupdwfl.cxx ++++ b/setupdwfl.cxx +@@ -359,9 +359,19 @@ setup_dwfl_kernel (unsigned *modules_found, systemtap_session &s) + // 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 == "/")) ++ if (s.kernel_build_tree == string(s.sysroot + lib_path)) ++ { ++ // 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. ++ if (s.sysroot != "" && s.sysroot != "/") ++ elfutils_kernel_path = string(s.sysroot + "/lib/modules/" + s.kernel_release); ++ else ++ elfutils_kernel_path = s.kernel_release; ++ } ++ else ++ if (s.kernel_build_tree == lib_path ++ && s.sysroot == "/") + elfutils_kernel_path = s.kernel_release; + else + elfutils_kernel_path = s.kernel_build_tree; +-- +2.7.4 + diff --git a/meta/recipes-kernel/systemtap/systemtap/0003-sysroot-debuginfo-lookup-with-sysroot-case-do-not-re.patch b/meta/recipes-kernel/systemtap/systemtap/0003-sysroot-debuginfo-lookup-with-sysroot-case-do-not-re.patch new file mode 100644 index 0000000..a3f23fb --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0003-sysroot-debuginfo-lookup-with-sysroot-case-do-not-re.patch @@ -0,0 +1,97 @@ +From 6a873f2bd03c76b18b7d6ad2187b00d6a3e2a8d0 Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Thu, 8 Feb 2018 20:09:19 -0800 +Subject: [PATCH 3/6] sysroot: 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/. + +Note in cross compile environment, it is good idea to set and export +proper SYSTEMTAP_DEBUGINFO_PATH variable because usual built defaults that +work for native distros very often not applicable to cross sysroot +based environment. For example for yocto poky/OE build the following +setting seems proper "+:.debug:build". + +Here are steps how to reproduce the issue. Note is produced by +yocto poky build. + +[kamensky@coreos-lnx2 tests]$ ls /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/mkdir.coreutils +/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/mkdir.coreutils +[kamensky@coreos-lnx2 tests]$ ls /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/.debug/mkdir.coreutils +/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/.debug/mkdir.coreutils +[kamensky@coreos-lnx2 tests]$ /home/wd8/systemtap/20180208_2/packages/bin/stap --sysroot=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs -a x86_64 -r 4.9.78-yocto-standard -B CROSS_COMPILE=x86_64-poky-linux- --sysenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --sysenv=LD_LIBRARY_PATH=/lib:/usr/lib -v -l 'process("/bin/mkdir.coreutils").function("*")' +Pass 1: parsed user script and 480 library scripts using 230184virt/93416res/5344shr/88612data kb, in 350usr/30sys/378real ms. +process("/bin/mkdir.coreutils").function("_fini") +process("/bin/mkdir.coreutils").function("_init") +process("/bin/mkdir.coreutils").function("fts_children") +process("/bin/mkdir.coreutils").function("fts_close") +process("/bin/mkdir.coreutils").function("fts_open") +process("/bin/mkdir.coreutils").function("fts_read") +process("/bin/mkdir.coreutils").function("fts_set") +Pass 2: analyzed script: 7 probes, 0 functions, 0 embeds, 0 globals using 233484virt/97928res/6212shr/91912data kb, in 20usr/0sys/26real ms. + +running above example under strace shows that stap tries to access +/bin/.debug/mkdir.coreutils on host, rather then sysroot + +13064 openat(AT_FDCWD, "/bin/mkdir.coreutils", O_RDONLY) = -1 ENOENT (No such file or directory) +13064 openat(AT_FDCWD, "/bin/.debug/mkdir.coreutils", O_RDONLY) = -1 ENOENT (No such file or directory) +13064 openat(AT_FDCWD, "/bin/mkdir.coreutils", O_RDONLY) = -1 ENOENT (No such file or directory) +13064 openat(AT_FDCWD, "/bin/build/mkdir.coreutils", O_RDONLY) = -1 ENOENT (No such file or directory) +13064 openat(AT_FDCWD, "/bin/mkdir.coreutils", O_RDONLY) = -1 ENOENT (No such file or directory) + +After fix applied stap is able to find /bin/.debug/mkdir.coreutils under +sysroot: + +[kamensky@coreos-lnx2 tests]$ /home/wd8/systemtap/20180208_2/packages/bin/stap --sysroot=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs -a x86_64 -r 4.9.78-yocto-standard -B CROSS_COMPILE=x86_64-poky-linux- --sysenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --sysenv=LD_LIBRARY_PATH=/lib:/usr/lib -v -l 'process("/bin/mkdir.coreutils").function("*")' | wc +Pass 1: parsed user script and 480 library scripts using 230184virt/93440res/5368shr/88612data kb, in 330usr/40sys/371real ms. +Pass 2: analyzed script: 401 probes, 0 functions, 0 embeds, 0 globals using 235092virt/99484res/6256shr/93520data kb, in 30usr/0sys/35real ms. + 249 249 29671 + +Also verified on target that script like example below, once compiled +against sysroot on host and copied back on target can trace 'mkdir' +invocation functions: + +[kamensky@coreos-lnx2 tests]$ cat mkdir1.stp +probe process("/bin/mkdir.coreutils").function("*").call { + printf ("%s -> %s\n", thread_indent(1), ppfunc()) +} +probe process("/bin/mkdir.coreutils").function("*").return { + printf ("%s <- %s\n", thread_indent(-1), ppfunc()) +} + +Signed-off-by: Victor Kamensky +--- + setupdwfl.cxx | 12 ------------ + 1 file changed, 12 deletions(-) + +diff --git a/setupdwfl.cxx b/setupdwfl.cxx +index f00cf75..e5bfa28 100644 +--- a/setupdwfl.cxx ++++ b/setupdwfl.cxx +@@ -637,18 +637,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, +-- +2.7.4 + diff --git a/meta/recipes-kernel/systemtap/systemtap/0004-sysroot-delay-adding-sysroot-path-to-module-name-in-.patch b/meta/recipes-kernel/systemtap/systemtap/0004-sysroot-delay-adding-sysroot-path-to-module-name-in-.patch new file mode 100644 index 0000000..629d5a5 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0004-sysroot-delay-adding-sysroot-path-to-module-name-in-.patch @@ -0,0 +1,124 @@ +From 03b84b2ca963ec4c4c0a2949063f3f2d0c19a4e9 Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Thu, 8 Feb 2018 20:05:39 -0800 +Subject: [PATCH 4/6] sysroot: 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. + +Note in case of sysroot cross compile environment it is highly recommended +to pass --sysenv=PATH=xxx:yyy and --sysenv=LD_LIBRARY_PATH=zzz to use +search path appropriate for target system, rather then host setting on +system where stap runs. + +Here are steps how to reproduce the issue. Note is produced by +yocto poky build. + +[kamensky@coreos-lnx2 tests]$ cat mkdir2.stp +probe process("mkdir.coreutils").function("*").call { + printf ("%s -> %s\n", thread_indent(1), ppfunc()) +} +probe process("mkdir.coreutils").function("*").return { + printf ("%s <- %s\n", thread_indent(-1), ppfunc()) +} +[kamensky@coreos-lnx2 tests]$ ls /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/mkdir.coreutils +/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/mkdir.coreutils +[kamensky@coreos-lnx2 tests]$ ls /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/.debug/mkdir.coreutils +/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/.debug/mkdir.coreutils +[kamensky@coreos-lnx2 tests]$ /home/wd8/systemtap/20180208_2/packages/bin/stap --sysroot=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs -a x86_64 -r 4.9.78-yocto-standard -B CROSS_COMPILE=x86_64-poky-linux- --sysenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --sysenv=LD_LIBRARY_PATH=/lib:/usr/lib -v -p4 -m mkdir2 mkdir2.stp +Pass 1: parsed user script and 480 library scripts using 230196virt/93536res/5448shr/88624data kb, in 330usr/30sys/364real ms. +semantic error: resolution failed in DWARF builder + +semantic error: while resolving probe point: identifier 'process' at mkdir2.stp:1:7 + source: probe process("mkdir.coreutils").function("*").call { + ^ + +semantic error: no match + +semantic error: resolution failed in DWARF builder + +semantic error: while resolving probe point: identifier 'process' at :4:7 + source: probe process("mkdir.coreutils").function("*").return { + ^ + +semantic error: no match + +Pass 2: analyzed script: 0 probes, 0 functions, 0 embeds, 0 globals using 233496virt/97032res/5520shr/91924data kb, in 20usr/0sys/25real ms. +Pass 2: analysis failed. [man error::pass2] + +Under strace it shows that stap is not trying to lookup mkdir.coreutils +inside of sysroot accoring to PATH that was passed through --sysenv: + +16048 openat(AT_FDCWD, "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/mkdir.coreutils", O_RDONLY) = -1 ENOENT (No such file or directory) + +i.e it rather just tries + "mkdir.coreutils" + +After the fix veried that that above example able to find mkdir.coreutils +executable in sysroot and corresponding symbols + +Also verified that glob matching in sysroot works too for example for +this test case: + +[kamensky@coreos-lnx2 tests]$ cat mkdir3.stp +probe process("/bin/mkdi*").function("*").call { + printf ("%s -> %s\n", thread_indent(1), ppfunc()) +} +probe process("/bin/mkdi*").function("*").return { + printf ("%s <- %s\n", thread_indent(-1), ppfunc()) +} + +Signed-off-by: Victor Kamensky +--- + tapsets.cxx | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/tapsets.cxx b/tapsets.cxx +index 28296b1..c664df0 100644 +--- a/tapsets.cxx ++++ b/tapsets.cxx +@@ -746,7 +746,7 @@ base_query::base_query(dwflpp & dw, literal_map_t const & params): + 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())); +@@ -8293,7 +8293,6 @@ dwarf_builder::build(systemtap_session & sess, + } + else + { +- module_name = (string)sess.sysroot + (string)module_name; + filled_parameters[TOK_PROCESS] = new literal_string(module_name); + } + } +@@ -8327,7 +8326,7 @@ dwarf_builder::build(systemtap_session & sess, + 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) + { +@@ -8418,7 +8417,8 @@ dwarf_builder::build(systemtap_session & sess, + + // PR13338: unquote glob results + module_name = unescape_glob_chars (module_name); +- user_path = find_executable (module_name, "", sess.sysenv); // canonicalize it ++ user_path = find_executable (module_name, sess.sysroot, ++ sess.sysenv); // canonicalize it + if (!is_fully_resolved(user_path, "", sess.sysenv)) + throw SEMANTIC_ERROR(_F("cannot find executable '%s'", + user_path.to_string().c_str())); +-- +2.7.4 + diff --git a/meta/recipes-kernel/systemtap/systemtap/0005-sysroot-handle-symbolic-links-with-absolute-name-rel.patch b/meta/recipes-kernel/systemtap/systemtap/0005-sysroot-handle-symbolic-links-with-absolute-name-rel.patch new file mode 100644 index 0000000..bd2b731 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0005-sysroot-handle-symbolic-links-with-absolute-name-rel.patch @@ -0,0 +1,159 @@ +From b9edb57fb3e8e1cb1b8a9d20350bfc7cb3b1a4a7 Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Thu, 8 Feb 2018 20:27:55 -0800 +Subject: [PATCH 5/6] 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. + +Here are steps how to reproduce the issue. Note is produced by +yocto poky build. + +kamensky@coreos-lnx2 tests]$ ls -l /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/mkdir +lrwxrwxrwx. 1 kamensky kamensky 20 Jan 30 18:29 /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/mkdir -> /bin/mkdir.coreutils +[kamensky@coreos-lnx2 tests]$ ls -l /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/mkdir.coreutils +-rwxr-xr-x. 1 kamensky kamensky 88232 Jan 29 09:58 /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/mkdir.coreutils +[kamensky@coreos-lnx2 tests]$ ls -l /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/.debug/mkdir.coreutils +-rwxr-xr-x. 1 kamensky kamensky 383456 Jan 29 09:58 /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/.debug/mkdir.coreutils +[kamensky@coreos-lnx2 tests]$ cat mkdir4.stp +probe process("/bin/mkdir").function("*").call { + printf ("%s -> %s\n", thread_indent(1), ppfunc()) +} +probe process("/bin/mkdir").function("*").return { + printf ("%s <- %s\n", thread_indent(-1), ppfunc()) +} +[kamensky@coreos-lnx2 tests]$ /home/wd8/systemtap/20180208_2/packages/bin/stap --sysroot=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs -a x86_64 -r 4.9.78-yocto-standard -B CROSS_COMPILE=x86_64-poky-linux- --sysenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --sysenv=LD_LIBRARY_PATH=/lib:/usr/lib -v -p4 -m mkdir4 mkdir4.stp +Pass 1: parsed user script and 480 library scripts using 230196virt/93484res/5396shr/88624data kb, in 340usr/30sys/370real ms. +semantic error: resolution failed in DWARF builder + +semantic error: while resolving probe point: identifier 'process' at mkdir4.stp:1:7 + source: probe process("/bin/mkdir").function("*").call { + ^ + +semantic error: no match + +semantic error: resolution failed in DWARF builder + +semantic error: while resolving probe point: identifier 'process' at :4:7 + source: probe process("/bin/mkdir").function("*").return { + ^ + +semantic error: no match + +Pass 2: analyzed script: 0 probes, 0 functions, 0 embeds, 0 globals using 233496virt/96980res/5468shr/91924data kb, in 20usr/0sys/25real ms. +Pass 2: analysis failed. [man error::pass2] + +After the fix above sript works fine verified that it traces mkdir +functions on target. + +Signed-off-by: Victor Kamensky +--- + util.cxx | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 76 insertions(+) + +diff --git a/util.cxx b/util.cxx +index dd87b38..237cb0f 100644 +--- a/util.cxx ++++ b/util.cxx +@@ -443,6 +443,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. +@@ -467,6 +525,14 @@ string find_executable(const string& name, const string& sysroot, + 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. + { +@@ -495,6 +561,16 @@ string find_executable(const string& name, const string& sysroot, + retpath = fname; + break; + } ++ else if (sysroot != "" ++ && lstat(f, &st) == 0 ++ && S_ISLNK(st.st_mode)) ++ { ++ retpath = follow_link(f, sysroot); ++ if (retpath != "") ++ { ++ break; ++ } ++ } + } + } + } +-- +2.7.4 + diff --git a/meta/recipes-kernel/systemtap/systemtap/0006-sysroot-_stp_umodule_relocate-needs-receive-target-f.patch b/meta/recipes-kernel/systemtap/systemtap/0006-sysroot-_stp_umodule_relocate-needs-receive-target-f.patch new file mode 100644 index 0000000..f2e5c71 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0006-sysroot-_stp_umodule_relocate-needs-receive-target-f.patch @@ -0,0 +1,58 @@ +From 8d6e3b078167e892501242b6cd47ee6726d31170 Mon Sep 17 00:00:00 2001 +From: Victor Kamensky +Date: Tue, 20 Feb 2018 08:38:27 -0800 +Subject: [PATCH 6/6] sysroot: _stp_umodule_relocate needs receive target 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. Note in another place in tapsets.cxx where +_stp_umodule_relocate is emitted path_remove_sysroot is already +applied. + +Here are steps how to reproduce the issue. Note is produced by +yocto poky build. + +[kamensky@coreos-lnx2 tests]$ cat od.stp +probe process("/usr/bin/od.coreutils").function("main").call { + printf ("%s: flag_dump_strings=0x%x\n", ppfunc(), $flag_dump_strings) +} +[kamensky@coreos-lnx2 tests]$ /home/wd8/systemtap/20180208_2/packages/bin/stap --sysroot=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs -a x86_64 -r 4.9.78-yocto-standard -B CROSS_COMPILE=x86_64-poky-linux- --sysenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --sysenv=LD_LIBRARY_PATH=/lib:/usr/lib -p4 -k -m od od.stp +od.ko +Keeping temporary directory "/tmp/stapdnaaGF" +[kamensky@coreos-lnx2 tests]$ grep _stp_umodule_relocate /tmp/stapdnaaGF/od_src.c + l->__retvalue = uderef(1, ((((int64_t) (/* pragma:vma */ ({ unsigned long addr = 0; addr = _stp_umodule_relocate ("/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/usr/bin/od.coreutils", 0x212212, current); addr; })))))); + +Note above _stp_umodule_relocate call was emitted with file path +on the host, it will fail once executed on target. + +Signed-off-by: Victor Kamensky +--- + loc2stap.cxx | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/loc2stap.cxx b/loc2stap.cxx +index 4818ee0..e2339a4 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,7 @@ 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; })"; + } +-- +2.7.4 + diff --git a/meta/recipes-kernel/systemtap/systemtap_git.inc b/meta/recipes-kernel/systemtap/systemtap_git.inc index af5b004..f774bbc 100644 --- a/meta/recipes-kernel/systemtap/systemtap_git.inc +++ b/meta/recipes-kernel/systemtap/systemtap_git.inc @@ -13,6 +13,12 @@ SRC_URI = "git://sourceware.org/git/systemtap.git \ file://0001-buildrun-remove-quotes-around-I-include-line.patch \ 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-sysroot-fix-short-release-r-option-handling-in-case-.patch \ + file://0002-sysroot-fix-short-release-r-option-handling-in-case-.patch \ + file://0003-sysroot-debuginfo-lookup-with-sysroot-case-do-not-re.patch \ + file://0004-sysroot-delay-adding-sysroot-path-to-module-name-in-.patch \ + file://0005-sysroot-handle-symbolic-links-with-absolute-name-rel.patch \ + file://0006-sysroot-_stp_umodule_relocate-needs-receive-target-f.patch \ " COMPATIBLE_HOST = '(x86_64|i.86|powerpc|arm|aarch64|microblazeel|mips).*-linux' From patchwork Tue Mar 6 17:50:39 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: 130829 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp4221443lja; Tue, 6 Mar 2018 09:51:35 -0800 (PST) X-Google-Smtp-Source: AG47ELsSLFL7/eGOggyZNnEkSnKGQtMn/93z6wwcJ+hjS3mSzxfdHH7V0jlhcWNxtv33wStfveel X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr17496565ple.0.1520358694947; Tue, 06 Mar 2018 09:51:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520358694; cv=none; d=google.com; s=arc-20160816; b=yTy52nHZO+aopC5jsU6CM3SwUaL2UHPj6JQKHqOFp3L/34OfDzzbI0BOeTvjh5cB0c diqmh2PeeP5zqXjl5TfcEN+9cG9H/k/JcGCHSo7xzQaWgJ+7YJgrFeqBFuiYoIkMynVF IsHuIq3y0YCB1E5fYwVXedaLLmQIyWPUgff+uHck7hk18ehajZxDcZZp5JLG/V5ExsR2 XqodCnpvgrYSoT3IzgCZd1zpS62e7FF+XXXsaIZCBIxjUHilNS+RHqnqb8G5/BckR1G3 2MQcDEM8Fm5w+6+VZEYQIpA9RhBPyCumRlJ9QdqjRI6468g5OGKASUIuUkzvzX5VouPQ 0vlw== 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=SUUb+51T1bInhItN2mjNa8kHb32pZsFZV5jGqvbBmS0=; b=GTcM23mnznEeM0SLmyViWBmEdOsL2TPAQqX5fu2qbCFwtZDtteVQpAzKNeaTBgHW61 RLaWJ7MuRimKtTmlKSgJfUgXmRlvurHKYFt+ZHSPvU0U5OyJHUs/k8MMkVYrKb0xpL6U Pxiyvbb7RmMSUZZn8G8DUq1KrK7L9RXUZ3wr7cpeqIuW4ViZaYCt2egiKwJwlwUsneQl LDm7jauVocsscyynWbOmo205OlLHRDKwuNZuajx8JX8yojFrwrCtzCNKneeZ/fdgpLes 3LvYJyF5uJVm3R/rdcGAB6O0ZD+eZc5UGq7X4hOFqHo6X6fASLFB5a707WEHWSnrMm+b JEiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cisco.com header.s=iport header.b=HZlrgFdV; 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 y2-v6si11529505pli.321.2018.03.06.09.51.34; Tue, 06 Mar 2018 09:51:34 -0800 (PST) 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=HZlrgFdV; 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 BCD5C78A96; Tue, 6 Mar 2018 17:51:15 +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 9F28E78A83 for ; Tue, 6 Mar 2018 17:51:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=9786; q=dns/txt; s=iport; t=1520358676; x=1521568276; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ApLmlhzPGJ+3OEyEFHOwOnIYcJFu2vweZpt9Y/fIE/8=; b=HZlrgFdVxfdMq+l97DuRdQlaJsLtx8enW/p+3yP70bJQVHiB2D8eIinL q12nXPqXeAIS6RCMdzoJIy29RdDwtyhNt+egsJRw+WodsmltzkR3+eyLa ruRtkCoe8a3HD+wYccWmqW5w40MRAxupoC7ZlmmYlFEBetMzQ5pSYte11 Y=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BKAgCN1J5a/5xdJa1dGQEBAQEBAQEBAQEBAQcBAQEBAYNQZnAom3GDGIwYg0yEUIIVChuFFQKDAyE1FwECAQEBAQEBAmsnhSQGeRA7FlcZhRurQoRyg3SCJoUxgi6GNIVDYoR/IASII4ZOi3YJhlSKKwKBZU6HBYU+MJB5AhEZAYEuHwE2QIESTSMVgn0JhGAfN4ldJIIkAQEB X-IronPort-AV: E=Sophos;i="5.47,432,1515456000"; d="scan'208";a="364094102" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2018 17:50:51 +0000 Received: from kamensky-w541.cisco.com ([10.24.22.184]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.14.5/8.14.5) with ESMTP id w26HofYo007528 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Tue, 6 Mar 2018 17:50:51 GMT From: Victor Kamensky To: openembedded-core@lists.openembedded.org Date: Tue, 6 Mar 2018 09:50:39 -0800 Message-Id: <1520358641-7062-4-git-send-email-kamensky@cisco.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520358641-7062-1-git-send-email-kamensky@cisco.com> References: <1520358641-7062-1-git-send-email-kamensky@cisco.com> X-Authenticated-User: kamensky@cisco.com Cc: Alexander Kanavin Subject: [OE-core] [RFC PATCH 3/5] image: add IMAGE_GEN_COMBINED_DEBUGFS build option 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_GEN_DEBUGFS="1" variable as storage strategy may have some sense it removes duplicate content, but from engineer work flow point of view it requires extra steps of recombining, unpacking two tarball archives. I.e there is no directory in image build workspace that can be used to run gdb, perf, and systemtap. In addition to IMAGE_GEN_DEBUGFS variable new variant of the same functionality IMAGE_GEN_COMBINED_DEBUGFS is introduced. Unlike IMAGE_GEN_DEBUGFS additional rootfs-dbg and additional tarball would contain both all target material plus symbols. Resulting rootfs-dbg directory in build workspace can be directly used by all cross debugging tools like gdb, perf, and systemtap. Signed-off-by: Victor Kamensky --- meta/classes/image-prelink.bbclass | 13 +++++++++ meta/classes/image.bbclass | 11 +++++-- meta/lib/oe/rootfs.py | 59 +++++++++++++++++++++----------------- 3 files changed, 55 insertions(+), 28 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/classes/image-prelink.bbclass b/meta/classes/image-prelink.bbclass index f3bb68b..5470e63 100644 --- a/meta/classes/image-prelink.bbclass +++ b/meta/classes/image-prelink.bbclass @@ -35,6 +35,11 @@ prelink_image () { dynamic_loader=$(linuxloader) + if [ "$IMAGE_GEN_COMBINED_DEBUGFS" = "1" ]; then + cp ${IMAGE_ROOTFS}${sysconfdir}/prelink.conf ${IMAGE_ROOTFS}-dbg${sysconfdir}/prelink.conf + cp ${IMAGE_ROOTFS}${sysconfdir}/ld.so.conf ${IMAGE_ROOTFS}-dbg${sysconfdir}/ld.so.conf + fi + # prelink! if [ "$BUILD_REPRODUCIBLE_BINARIES" = "1" ]; then bbnote " prelink: BUILD_REPRODUCIBLE_BINARIES..." @@ -44,8 +49,16 @@ prelink_image () { export PRELINK_TIMESTAMP=$REPRODUCIBLE_TIMESTAMP_ROOTFS fi ${STAGING_SBINDIR_NATIVE}/prelink --root ${IMAGE_ROOTFS} -am -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader + if [ "$IMAGE_GEN_COMBINED_DEBUGFS" = "1" ]; then + bbnote " prelink: IMAGE_GEN_COMBINED_DEBUGFS..." + ${STAGING_SBINDIR_NATIVE}/prelink --root ${IMAGE_ROOTFS}-dbg -am -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader + fi else ${STAGING_SBINDIR_NATIVE}/prelink --root ${IMAGE_ROOTFS} -amR -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader + if [ "$IMAGE_GEN_COMBINED_DEBUGFS" = "1" ]; then + bbnote " prelink: IMAGE_GEN_COMBINED_DEBUGFS..." + ${STAGING_SBINDIR_NATIVE}/prelink --root ${IMAGE_ROOTFS}-dbg -amR -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader + fi fi # Remove the prelink.conf if we had to add it. diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 23ed53d..3d1b9e4 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -28,6 +28,12 @@ IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs empty-root-password # Generate companion debugfs? IMAGE_GEN_DEBUGFS ?= "0" +# Generate companion combined debugfs? The difference from IMAGE_GEN_DEBUGFS +# is that in case of IMAGE_GEN_COMBINED_DEBUGFS resulting debufs contains full +# copy of original symbols plus -dbg packages, whereas in case of IMAGE_GEN_DEBUGFS +# it contains only -dbg packages +IMAGE_GEN_COMBINED_DEBUGFS ?= "0" + # rootfs bootstrap install ROOTFS_BOOTSTRAP_INSTALL = "run-postinsts" @@ -117,7 +123,7 @@ def rootfs_variables(d): 'IMAGE_ROOTFS_MAXSIZE','IMAGE_NAME','IMAGE_LINK_NAME','IMAGE_MANIFEST','DEPLOY_DIR_IMAGE','IMAGE_FSTYPES','IMAGE_INSTALL_COMPLEMENTARY','IMAGE_LINGUAS', 'MULTILIBRE_ALLOW_REP','MULTILIB_TEMP_ROOTFS','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS', 'PACKAGE_ARCHS','PACKAGE_CLASSES','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','OVERRIDES','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI','INTERCEPT_DIR','USE_DEVFS', - 'CONVERSIONTYPES', 'IMAGE_GEN_DEBUGFS', 'ROOTFS_RO_UNNEEDED', 'IMGDEPLOYDIR', 'PACKAGE_EXCLUDE_COMPLEMENTARY', 'REPRODUCIBLE_TIMESTAMP_ROOTFS'] + 'CONVERSIONTYPES', 'IMAGE_GEN_DEBUGFS', 'IMAGE_GEN_COMBINED_DEBUGFS', 'ROOTFS_RO_UNNEEDED', 'IMGDEPLOYDIR', 'PACKAGE_EXCLUDE_COMPLEMENTARY', 'REPRODUCIBLE_TIMESTAMP_ROOTFS'] variables.extend(rootfs_command_variables(d)) variables.extend(variable_depends(d)) return " ".join(variables) @@ -268,6 +274,7 @@ fakeroot python do_image () { from oe.utils import execute_pre_post_process d.setVarFlag('REPRODUCIBLE_TIMESTAMP_ROOTFS', 'export', '1') + d.setVarFlag('IMAGE_GEN_COMBINED_DEBUGFS', 'export', '1') pre_process_cmds = d.getVar("IMAGE_PREPROCESS_COMMAND") execute_pre_post_process(d, pre_process_cmds) @@ -381,7 +388,7 @@ python () { alltypes = d.getVar('IMAGE_FSTYPES').split() typedeps = {} - if d.getVar('IMAGE_GEN_DEBUGFS') == "1": + if d.getVar('IMAGE_GEN_DEBUGFS') == "1" or d.getVar('IMAGE_GEN_COMBINED_DEBUGFS') == "1" : debugfs_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS').split() for t in debugfs_fstypes: alltypes.append("debugfs_" + t) diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py index bf2aea2..a2e809a 100644 --- a/meta/lib/oe/rootfs.py +++ b/meta/lib/oe/rootfs.py @@ -107,7 +107,9 @@ class Rootfs(object, metaclass=ABCMeta): def _setup_dbg_rootfs(self, dirs): gen_debugfs = self.d.getVar('IMAGE_GEN_DEBUGFS') or '0' - if gen_debugfs != '1': + gen_combined_debugfs = self.d.getVar('IMAGE_GEN_COMBINED_DEBUGFS') or '0' + + if gen_debugfs != '1' and gen_combined_debugfs != '1': return bb.note(" Renaming the original rootfs...") @@ -118,32 +120,37 @@ class Rootfs(object, metaclass=ABCMeta): os.rename(self.image_rootfs, self.image_rootfs + '-orig') bb.note(" Creating debug rootfs...") - bb.utils.mkdirhier(self.image_rootfs) - bb.note(" Copying back package database...") - for dir in dirs: - if not os.path.isdir(self.image_rootfs + '-orig' + dir): - continue - bb.utils.mkdirhier(self.image_rootfs + os.path.dirname(dir)) - shutil.copytree(self.image_rootfs + '-orig' + dir, self.image_rootfs + dir, symlinks=True) - - cpath = oe.cachedpath.CachedPath() - # Copy files located in /usr/lib/debug or /usr/src/debug - for dir in ["/usr/lib/debug", "/usr/src/debug"]: - src = self.image_rootfs + '-orig' + dir - if cpath.exists(src): - dst = self.image_rootfs + dir - bb.utils.mkdirhier(os.path.dirname(dst)) - shutil.copytree(src, dst) - - # Copy files with suffix '.debug' or located in '.debug' dir. - for root, dirs, files in cpath.walk(self.image_rootfs + '-orig'): - relative_dir = root[len(self.image_rootfs + '-orig'):] - for f in files: - if f.endswith('.debug') or '/.debug' in relative_dir: - bb.utils.mkdirhier(self.image_rootfs + relative_dir) - shutil.copy(os.path.join(root, f), - self.image_rootfs + relative_dir) + if gen_combined_debugfs != '1': + bb.utils.mkdirhier(self.image_rootfs) + + bb.note(" Copying back package database...") + for dir in dirs: + if not os.path.isdir(self.image_rootfs + '-orig' + dir): + continue + bb.utils.mkdirhier(self.image_rootfs + os.path.dirname(dir)) + shutil.copytree(self.image_rootfs + '-orig' + dir, self.image_rootfs + dir, symlinks=True) + + cpath = oe.cachedpath.CachedPath() + # Copy files located in /usr/lib/debug or /usr/src/debug + for dir in ["/usr/lib/debug", "/usr/src/debug"]: + src = self.image_rootfs + '-orig' + dir + if cpath.exists(src): + dst = self.image_rootfs + dir + bb.utils.mkdirhier(os.path.dirname(dst)) + shutil.copytree(src, dst) + + # Copy files with suffix '.debug' or located in '.debug' dir. + for root, dirs, files in cpath.walk(self.image_rootfs + '-orig'): + relative_dir = root[len(self.image_rootfs + '-orig'):] + for f in files: + if f.endswith('.debug') or '/.debug' in relative_dir: + bb.utils.mkdirhier(self.image_rootfs + relative_dir) + shutil.copy(os.path.join(root, f), + self.image_rootfs + relative_dir) + else: + bb.note(" Copying back original image...") + shutil.copytree(self.image_rootfs + '-orig', self.image_rootfs, symlinks=True) bb.note(" Install complementary '*-dbg' packages...") self.pm.install_complementary('*-dbg') From patchwork Tue Mar 6 17:50:40 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: 130826 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp4221060lja; Tue, 6 Mar 2018 09:51:12 -0800 (PST) X-Google-Smtp-Source: AG47ELvSptJW14bU5XEkBInaVBQ3TMdLyvZXofRuiw7AgHdt16UGqZIAJiKwy1517zp/1hAVI82D X-Received: by 10.98.180.13 with SMTP id h13mr19625576pfn.139.1520358672051; Tue, 06 Mar 2018 09:51:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520358672; cv=none; d=google.com; s=arc-20160816; b=eVs+dhwMK1vjb59XH6FKnT6z0uJcmQy6MKLSP1zorpDbSrefeUKFkm6q5TRI8+lniF /E8vZvaAP9Rh7Kv1+9cuih/T1XW+Xkx5fko2UeKsbCexQ+YEWm4EI2Es167hOrKTaB8v aXfG1HGZ3DxDMpypoRK1+hcMxHxzyMQbpDuUcXLL02sjnEdzgswZyos6/vZzJL4NA6yZ q/lQax+8oZB1SLAtIFmYBA7nUyPwWQWdLglC5o3p603ACqMXULFtj0Jr/3ZNNdMbhT/h bp3p0ktXvUGCI4NW5uEwU6FXT+ngXh8w7GacUcqcAx6UsJ9E2rZcxoWI5/YQ873Cke9B 2IjQ== 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=i94uJLJ7QQBoPm03H/Z24SNlwWV6nR4ypLuf44dZhc4=; b=hl0eXv501L+bKd4loU2IaYe14ih/ea8BB15jxov2C5TR3C75445ZEnWInEqporWdTf cvUn7G7wPew57yI1rLRKUCwmAsygjhixjSnvHFuZ/f5fnlGYI0Dg7y9wMg6eFAK2jqio wB3YfQFX7Hn7BMNm/+ipZGNhPWWDTPtFAjxy5PS10Y36c5/F6pr/VHsHayinf5kYb0Uj x1GHp6vrRzmI/f9MsUdunNUpvU/D9ND7WpIqfh9/sfenbb8XKCyl2voUmZVgbV3I6UNM gXCFiirGLsvYCibHueFEUN3tWHEXp1iZtkP5aEtHJbvqhAbjrdOrEeYB9TvQ+NVzvypX YHvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cisco.com header.s=iport header.b=YkNUAtVG; 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 f7-v6si11799450pln.211.2018.03.06.09.51.11; Tue, 06 Mar 2018 09:51:12 -0800 (PST) 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=YkNUAtVG; 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 7C20978AA1; Tue, 6 Mar 2018 17:51:07 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from rcdn-iport-5.cisco.com (rcdn-iport-5.cisco.com [173.37.86.76]) by mail.openembedded.org (Postfix) with ESMTP id 8120578A97 for ; Tue, 6 Mar 2018 17:50:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2352; q=dns/txt; s=iport; t=1520358653; x=1521568253; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=txmjxN6J8upIiZqMwT55qqOjzoG5ZK5xQntw6ci5kK4=; b=YkNUAtVGPEIUOlKD+TDzwq0siQ3ZIdRDQ0tkzUKZ/rsWmul8lEVY4YBF bL8ZsQHXhib+vgw6W+LxWSTxYhYkRUJSwVKziQMj4KWkCEEpye0POpPnB NbKDZFS5CS4CT/kpp1Zz/w72n0yqgdJ9IpwcPJvbLpX4e2UrO19+i5JMC I=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BJAgCk055a/5xdJa1dGQEBAQEBAQEBAQEBAQcBAQEBAYNQZnAom3GDGJZJCh+FEQKDAyE3FQECAQEBAQEBAmsnhSQGeRBRVxmFG6s6hHKDdIImhTGCLoY0hUFihSEEjnGLdgmGVIMSAQWHEwKOdol9hywCERkBgS40IoFSTSMVgn0JhGAfN4wlAQEB X-IronPort-AV: E=Sophos;i="5.47,432,1515456000"; d="scan'208";a="146325668" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-5.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2018 17:50:52 +0000 Received: from kamensky-w541.cisco.com ([10.24.22.184]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.14.5/8.14.5) with ESMTP id w26HofYp007528 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Tue, 6 Mar 2018 17:50:51 GMT From: Victor Kamensky To: openembedded-core@lists.openembedded.org Date: Tue, 6 Mar 2018 09:50:40 -0800 Message-Id: <1520358641-7062-5-git-send-email-kamensky@cisco.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520358641-7062-1-git-send-email-kamensky@cisco.com> References: <1520358641-7062-1-git-send-email-kamensky@cisco.com> X-Authenticated-User: kamensky@cisco.com Cc: Alexander Kanavin Subject: [OE-core] [RFC PATCH 4/5] systemtap: introduce utils variant of systemtap package 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 In case of small target images it is too expensive to include full stap package into the image. Because default systemtap package include SystemTap translater and have very deep dependencies on variety of libraries. And in cross compiling environment compilation of SystemTap kernel modules can happen on host for a given target using --sysroot and other proper options. In order to deploy resulting SystemTap .ko module, one need small set of SystemTap runtime tools like staprun and stapio. systemtap-utils introduces special "small" variant of systemtap build where only SystemTap run-time utilties are built. As result addition on target is quite small. Signed-off-by: Victor Kamensky --- .../systemtap/systemtap-utils_git.bb | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 meta/recipes-kernel/systemtap/systemtap-utils_git.bb -- 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-utils_git.bb b/meta/recipes-kernel/systemtap/systemtap-utils_git.bb new file mode 100644 index 0000000..3359257 --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap-utils_git.bb @@ -0,0 +1,31 @@ +SUMMARY = "Small set only runtime utilities for SystemTap" +HOMEPAGE = "https://sourceware.org/systemtap/" + +require systemtap_git.inc + +FILESEXTRAPATHS =. "${FILE_DIRNAME}/systemtap:" + +DEPENDS = "elfutils" + +# should not be used along with complete systemtap +RCONFLICTS_${PN} = "systemtap" + +EXTRA_OECONF += "--with-libelf=${STAGING_DIR_TARGET} --without-rpm \ + --without-nss --without-avahi --without-dyninst \ + --disable-server --disable-grapher --enable-prologues \ + --with-python3 --without-python2-probes \ + --disable-sdt-probes --disable-translator \ + --disable-libvirt --disable-sqlite --disable-monitor \ + --without-python3-probes \ + --disable-docs --disable-publican --disable-refdocs \ + ac_cv_prog_have_javac=no \ + ac_cv_prog_have_jar=no " + +do_install_append () { + rm -rf ${D}${datadir}/systemtap + rm -rf ${D}${includedir} + # remove bash dependency we don't need it anyway + rm ${D}${libexecdir}/systemtap/stap-env +} + +inherit autotools gettext From patchwork Tue Mar 6 17:50:41 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: 130827 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp4221188lja; Tue, 6 Mar 2018 09:51:19 -0800 (PST) X-Google-Smtp-Source: AG47ELvTfWTFoDJl4u3kegb8MbH90X8UmFrzelv1yXw2gDtMOYbfP1cbdEHSWQKovAjlHKtMTLrb X-Received: by 2002:a17:902:b7cc:: with SMTP id v12-v6mr17463820plz.249.1520358679272; Tue, 06 Mar 2018 09:51:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520358679; cv=none; d=google.com; s=arc-20160816; b=nl6ZQ/VZDEBgjL5KFYUxTBd47uJyDjUs1Meiy3IwQB12x8aFoM3+zl06nKKF7LJ+EQ nEVoHmNKLVEQX1H/Tv92wJG8raN42UZxmd5keuWqeFFt+PCUl3JqXXSoBjrBDOslsDMK cahSb7Zt/X9OZlHMwmkcFrRI6g1199xqEbpyXivigG0yCaTnBQZbWCUgrANrbh+5u8D7 JS4laErPXR/zFW5tTmd4fIlgNdeUWxSfGCq8MjOMQPwbJpsm0jKKO12pJVsCO3Feg22u kFif9eN0mAPmcxvXGc7e44WW+Ptn3xH/E3wF25+CGl62QcQE5aXBZrzl7xQhwJSPf4PX RUnQ== 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=vdhQQ02drx/0fzJ8Yi3KsIPeJzpTj7i7AE1up4874NY=; b=FW8m++rwbSPOX/QHPlMWO1JOeRytSq4kqMAM0pIkPsLX3iJbEQunO80x7aontS/bzn 1aGrLmK9azFxZXpzeBY22dt0TcKv0UfsiND5bqYga4FAgQJz5JWmkJTiAdLCc8DdzHa6 eAmMXsGZ6/ckiSWxzTgrSqshxwJYmDUQj1B0f/yAliG+lE8Bch5Fo8xcwvLipsnB5eDa clBz+IcK3Y0f/fb+fxznLpJP4Tfym/iD0eBJ9pIVzUBkqrsVetttGJ9W1cFdcyrJ8FOA X+czr4eozmjZmpwwFw/tHi+xWr6k9h7707T/ggMaAxMBM5Wuuz98/iB9x1FePzCdyj2l 7AYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cisco.com header.s=iport header.b=OO+whdFF; 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 s16si12364929pfe.375.2018.03.06.09.51.18; Tue, 06 Mar 2018 09:51:19 -0800 (PST) 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=OO+whdFF; 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 843D278AB1; Tue, 6 Mar 2018 17:51:08 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from rcdn-iport-7.cisco.com (rcdn-iport-7.cisco.com [173.37.86.78]) by mail.openembedded.org (Postfix) with ESMTP id 8381C78A9F for ; Tue, 6 Mar 2018 17:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=16407; q=dns/txt; s=iport; t=1520358653; x=1521568253; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=/XDdm5cE5dokPAT3/yjSYedvuS0lm7cXEJraM5xhmkU=; b=OO+whdFFrpOZmeBi8gC2RTztOPSMVEYt5XdYH8kN0w1ZKzYnKFZyReUB cbZiSbNr23lyDAtVzDq5iTwk5CqzNthwWqJLVVEYWU60JvEODYfPp3FBK MFqIS5XXS9GsDOLBvnl5kahN07d6ypHtFOM+RFq3xH7mK8R26V9rNjekT A=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AeAQBY1J5a/5xdJa1dGQEBAQEBAQEBAQEBAQcBAQEBAYNQgVYojXiNeYJ9G5Q0FIIBCoFbASODMQKDAyE0GAECAQEBAQEBAmsnhSQGeRBRVxmFG6s/hHKDdIImhTGCLoM9gneFHIYoBI17AXWLL0cJiWaHGQKOdoZmikMCERkBgS4eOIFSTSMVOoJDgmOCBh83M4tyAQEB X-IronPort-AV: E=Sophos;i="5.47,432,1515456000"; d="scan'208";a="362500300" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-7.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2018 17:50:52 +0000 Received: from kamensky-w541.cisco.com ([10.24.22.184]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.14.5/8.14.5) with ESMTP id w26HofYq007528 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Tue, 6 Mar 2018 17:50:52 GMT From: Victor Kamensky To: openembedded-core@lists.openembedded.org Date: Tue, 6 Mar 2018 09:50:41 -0800 Message-Id: <1520358641-7062-6-git-send-email-kamensky@cisco.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520358641-7062-1-git-send-email-kamensky@cisco.com> References: <1520358641-7062-1-git-send-email-kamensky@cisco.com> X-Authenticated-User: kamensky@cisco.com Cc: Alexander Kanavin Subject: [OE-core] [RFC PATCH 5/5] crosstap2: wrapper to build systemtap script on host against given target 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 crosstap2 is similar to existing crosstap shell script, but unlike crosstap script that can handle only kernel SystemTap scripts, crosstap2 can also deal with user land related SystemTap scripts. It discovers and set up proper --sysroot arguments for stap invocation. The logic of handling of user-land related cross build arguments is a bit more complicated. It seemed that to implement it in existing crosstap script would be a stretch, so crosstap2 is written in python. Signed-off-by: Victor Kamensky --- scripts/crosstap2 | 422 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 422 insertions(+) create mode 100755 scripts/crosstap2 -- 2.7.4 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core diff --git a/scripts/crosstap2 b/scripts/crosstap2 new file mode 100755 index 0000000..c5209d2 --- /dev/null +++ b/scripts/crosstap2 @@ -0,0 +1,422 @@ +#!/usr/bin/env python3 +# +# Build a systemtap script for a given image. +# +# 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. +# +# 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. +# +# 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 +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import sys +import re +import subprocess +import os + +from optparse import OptionParser + +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("--sysroot") + ret.append(self.sysroot) + + 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) + + 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_GEN_COMBINED_DEBUGFS="1" options 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 set IMAGE_GEN_COMBINED_DEBUGFS="1". +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.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 + + def discover(self): + benv_image = BitbakeEnv(self.image) + (self.image_rootfs, + self.image_features, + self.image_gen_debugfs, + self.image_gen_combined_debugfs, + 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", + "IMAGE_GEN_COMBINED_DEBUGFS", + "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"]) + + def check(self, sysroot_option): + ret = True + 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: + 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 self.image_gen_combined_debugfs != "1": + 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_gen_combined_debugfs == "1": + 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 [script options] [-- [systemtap options]] + +%prog cross compile given SystemTap script against given image + +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. + +Script name '-s' and image name '-i' are only mandatory options.""" + + option_parser = 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 derived from passed script name") + + option_parser.add_option("-y", "--sysroot", dest="sysroot", + help="explicitely specify image sysroot location. May need to use 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) + + + + (options, remaining_args) = option_parser.parse_args() + if not options.script or not options.image: + if not options.script: + print("'-s FILE' option is missing\n") + if not options.image: + print("'-i IMAGE' 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()