Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1606020pxb; Fri, 26 Feb 2021 15:50:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbMGOc6Dwl9TUeWr8UwkXmrsHiMW62iVw+1P1hThztbPEBHoBbWjqmnxDGY72ebMEbZqIC X-Received: by 2002:a17:906:be9:: with SMTP id z9mr5791401ejg.35.1614383418353; Fri, 26 Feb 2021 15:50:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614383418; cv=none; d=google.com; s=arc-20160816; b=VFzqh0Ggp9WXOcZIE52a5fazgcss4YQrY6MXrKGGSLNf0KgNfGDlFi4PkNl6zM/+Sv f13olt18w2/K61bOP6GOyb5LlZC0Ju9Z0ZRuRziz6Yx65uTOZxpEFns9fDQTADJasRy2 aGx2GAnXgsetLGSoCfl12H6CLt7Zk23Fpe1nwm3yEvaFKth3AHi8bzm9e54W7cUEsEv/ 5s+wi6Vf4VWuPLi/ZQjWFUmwZGRsrA2wbKpwxaQbjCsDyhmXzKyBWBH7wnfoiPsuhtQC qSmzFEO/a0yUlhJtmFjJfsinxeFbfUEc4WLq4FkVQl5W1v9o0Y22S3tZS0k4ydvGl8q6 Bfvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QHi1xsuZCzSzX7P5c4o5OXhgrfD+EpOBiUIInIMEwfw=; b=H5ZVpH7LVt6UWclh2tVzfSYT86smMbYWD0UOZGQocr1vNMW8FRmscLAROLImvjEZGC BfQTuDiL/DOaAtZoiTj4x5V8lf07eYcZQDyX4oe2XX6MonMG44I2cxZpMbKUGbwCbmw1 xKtgr2Cy8RK/ld5j1WtpZ2MTr672R8cNQHbDZSCEhtrf8RJjWA0SXIEbqDY7m5f1h3w/ 2XcgiSch0ZZqaAu9XohJTXe4ZnMu4nS+osrXW3r4Gw3qcgRLBcAIn2pkHHb2AV4MNv02 Wnsj6r3kdTpC5n14E2UG7HSp35DdnmWqoX+o26xpYzVQoBR+AFXNhggE9MeYWG2r/IJJ rZ9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LZj63Tk2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p22si6903609ejj.57.2021.02.26.15.49.55; Fri, 26 Feb 2021 15:50:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LZj63Tk2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbhBZXsW (ORCPT + 99 others); Fri, 26 Feb 2021 18:48:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:52730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbhBZXsU (ORCPT ); Fri, 26 Feb 2021 18:48:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 23C7564EFA; Fri, 26 Feb 2021 23:47:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614383259; bh=mJmhgb1ENqSPoT/kdRZ1i3I2jcWdAdpEDiJifCHL+fI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LZj63Tk2majjXEHT+i49RbEISRXJCWinGPKuLwCAIgeNYDwhMYGnMJghBtzmTBMFy k7Y9ukwLVUPcIIsX+Rq9p1KBcW75fmPnMznI/iJXPkpFw7na/i69+dkjfc8+hYzhSM gC/HLxuLYK+IAWlKNSxv3BP3UhdRVHk9/herSTicLvj6B+/1wORwkXBb8ua/9T1A/C 0GnPAWXzmvwAu08DOpLNG9PT9v8elCSW/5WQ7Yr9L68S+Wwz3OaPbZqKFdV8t0n4mv nBaQ3+cDN9kRLkgZGKcAAY/sSfFw0Nj80AUYGz3qjo+OLSP7gmWfDLrcqhgmGp2lhC flPvHyrH+9A8A== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id CF0F140CD9; Fri, 26 Feb 2021 20:47:36 -0300 (-03) Date: Fri, 26 Feb 2021 20:47:36 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Nicholas Fraser , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, Ulrich Czekalla , Huw Davies Subject: Re: [PATCH] perf buildid-cache: Add test for PE executable Message-ID: References: <790bfe67-2155-a426-7130-ae7c45cb055b@codeweavers.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Feb 25, 2021 at 09:35:04PM +0100, Jiri Olsa escreveu: > On Wed, Feb 24, 2021 at 02:59:16PM -0500, Nicholas Fraser wrote: > > From 9fd0b3889f00ad13662879767d833309d8a035b6 Mon Sep 17 00:00:00 2001 > > From: Nicholas Fraser > > Date: Thu, 18 Feb 2021 13:24:03 -0500 > > Subject: [PATCH] perf buildid-cache: Add test for PE executable > > > > This builds on the previous changes to tests/shell/buildid.sh, adding > > tests for a PE file. It adds it to the build-id cache manually and, if > > Wine is available, runs it under "perf record" and verifies that it was > > added automatically. > > > > If wine is not installed, only warnings are printed; the test can still > > exit 0. > > > > Signed-off-by: Nicholas Fraser > > works nicely now, thanks > > Acked-by: Jiri Olsa Thanks for checking it, but if you did a review, i.e. if you looked at the code, made suggestions, the submitter acted upon those changes, you looked again, etc, shouldn't this be a more appropriate: Reviewed-by: Jiri Olsa ? I think we need to make these tags reflect more what really happened, i.e. if you just glanced over and thought, quickly, that it seems okayish, then Acked-by is what we should use, but if you gone thru the trouble of actually _looking hard_ at it, sometimes multiple times, then we should really use Reviewed-by and not take that lightly. - Arnaldo > jirka > > > --- > > tools/perf/tests/shell/buildid.sh | 65 +++++++++++++++++++++++++++---- > > 1 file changed, 58 insertions(+), 7 deletions(-) > > > > diff --git a/tools/perf/tests/shell/buildid.sh b/tools/perf/tests/shell/buildid.sh > > index 416af614bbe0..f05670d1e39e 100755 > > --- a/tools/perf/tests/shell/buildid.sh > > +++ b/tools/perf/tests/shell/buildid.sh > > @@ -14,18 +14,56 @@ if ! [ -x "$(command -v cc)" ]; then > > exit 2 > > fi > > > > +# check what we need to test windows binaries > > +add_pe=1 > > +run_pe=1 > > +if ! perf version --build-options | grep -q 'libbfd: .* on '; then > > + echo "WARNING: perf not built with libbfd. PE binaries will not be tested." > > + add_pe=0 > > + run_pe=0 > > +fi > > +if ! which wine > /dev/null; then > > + echo "WARNING: wine not found. PE binaries will not be run." > > + run_pe=0 > > +fi > > + > > +# set up wine > > +if [ ${run_pe} -eq 1 ]; then > > + wineprefix=$(mktemp -d /tmp/perf.wineprefix.XXX) > > + export WINEPREFIX=${wineprefix} > > + # clear display variables to prevent wine from popping up dialogs > > + unset DISPLAY > > + unset WAYLAND_DISPLAY > > +fi > > + > > ex_md5=$(mktemp /tmp/perf.ex.MD5.XXX) > > ex_sha1=$(mktemp /tmp/perf.ex.SHA1.XXX) > > +ex_pe=$(dirname $0)/../pe-file.exe > > > > echo 'int main(void) { return 0; }' | cc -Wl,--build-id=sha1 -o ${ex_sha1} -x c - > > echo 'int main(void) { return 0; }' | cc -Wl,--build-id=md5 -o ${ex_md5} -x c - > > > > -echo "test binaries: ${ex_sha1} ${ex_md5}" > > +echo "test binaries: ${ex_sha1} ${ex_md5} ${ex_pe}" > > > > check() > > { > > - id=`readelf -n ${1} 2>/dev/null | grep 'Build ID' | awk '{print $3}'` > > - > > + case $1 in > > + *.exe) > > + # We don't have a tool that can pull a nicely formatted build-id out of > > + # a PE file, but we can extract the whole section with objcopy and > > + # format it ourselves. The .buildid section is a Debug Directory > > + # containing a CodeView entry: > > + # https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#debug-directory-image-only > > + # https://github.com/dotnet/runtime/blob/da94c022576a5c3bbc0e896f006565905eb137f9/docs/design/specs/PE-COFF.md > > + # The build-id starts at byte 33 and must be rearranged into a GUID. > > + id=`objcopy -O binary --only-section=.buildid $1 /dev/stdout | \ > > + cut -c 33-48 | hexdump -ve '/1 "%02x"' | \ > > + sed 's@^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)\(.*\)0a$@\4\3\2\1\6\5\8\7\9@'` > > + ;; > > + *) > > + id=`readelf -n ${1} 2>/dev/null | grep 'Build ID' | awk '{print $3}'` > > + ;; > > + esac > > echo "build id: ${id}" > > > > link=${build_id_dir}/.build-id/${id:0:2}/${id:2} > > @@ -50,7 +88,7 @@ check() > > exit 1 > > fi > > > > - ${perf} buildid-cache -l | grep $id > > + ${perf} buildid-cache -l | grep ${id} > > if [ $? -ne 0 ]; then > > echo "failed: ${id} is not reported by \"perf buildid-cache -l\"" > > exit 1 > > @@ -79,16 +117,20 @@ test_record() > > { > > data=$(mktemp /tmp/perf.data.XXX) > > build_id_dir=$(mktemp -d /tmp/perf.debug.XXX) > > + log=$(mktemp /tmp/perf.log.XXX) > > perf="perf --buildid-dir ${build_id_dir}" > > > > - ${perf} record --buildid-all -o ${data} ${1} > > + echo "running: perf record $@" > > + ${perf} record --buildid-all -o ${data} $@ &> ${log} > > if [ $? -ne 0 ]; then > > - echo "failed: record ${1}" > > + echo "failed: record $@" > > + echo "see log: ${log}" > > exit 1 > > fi > > > > - check ${1} > > + check ${@: -1} > > > > + rm -f ${log} > > rm -rf ${build_id_dir} > > rm -rf ${data} > > } > > @@ -96,12 +138,21 @@ test_record() > > # add binaries manual via perf buildid-cache -a > > test_add ${ex_sha1} > > test_add ${ex_md5} > > +if [ ${add_pe} -eq 1 ]; then > > + test_add ${ex_pe} > > +fi > > > > # add binaries via perf record post processing > > test_record ${ex_sha1} > > test_record ${ex_md5} > > +if [ ${run_pe} -eq 1 ]; then > > + test_record wine ${ex_pe} > > +fi > > > > # cleanup > > rm ${ex_sha1} ${ex_md5} > > +if [ ${run_pe} -eq 1 ]; then > > + rm -r ${wineprefix} > > +fi > > > > exit ${err} > > -- > > 2.30.1 > > > > > -- - Arnaldo