Received: by 10.223.185.116 with SMTP id b49csp6062052wrg; Thu, 8 Mar 2018 00:53:10 -0800 (PST) X-Google-Smtp-Source: AG47ELuwpyjmAVedlC9p6NU5WAECukNQqtY9UGUYYG3qbBNA45BcXHpdimm1ZK/3ApKr7D3/bHT9 X-Received: by 10.99.8.4 with SMTP id 4mr20639290pgi.289.1520499190129; Thu, 08 Mar 2018 00:53:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520499190; cv=none; d=google.com; s=arc-20160816; b=qlQEX/mk5VbYeppbWysjdBMuXHjse2XSWeIVturXg0ut00sy2t1s1F/27fXj0fGDYg KLBs1n6A/LeC+dK2xZMWs/O+ClBR+PTX9HMtMDQZbjUivtgv0WW1YbtVP3PQGjj0R10b DORl9F9gE7ydEfY9B8t/LvCugycf0ojwIFO3UXBPPavh6ui8LATG+glYg5pI5h6It9Ch l7FRgeXTvrxQOSj2TnHu+6wRlClIzsLtLgBrInt+0lym/2etNWuIRkgIfIdeEgr7AwAK TUmsnLv7vsvX1p7BoWLSBr9rivXYGyedkWhzmNA0eFZyszcXWw0SemcA/+iKlWSz4tzY V49w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dmarc-filter:arc-authentication-results; bh=IjER91/ziVZNGxiqyE9AIgi48bpBn1BGWI1ZeYySogo=; b=JaAIAOALug8EGATIEwYGd6bXWcToNdsuC9EJei8a593ellokVS9fxz2N+wtzTcXlTD Fj0FuTpg0/wAI4nQlkI6w8hzufKSZibshg3tn4rgkuLpI/V1o6ckR1DqhANjGaYfLmTJ uOnPpk/doEGymBtrxAssgUwywh/XGu2Qk4O3wJ9a4AV8uL+jnNRhn/fLrbhyjyl6nroj ZhXWbojH0VuFY4s2BGwe1VDkFRpbz/TdH4GpGzR7V392tZj4F49LhvwQHxF2y1Q+xa/v ixOb6izJ6qV4mPplvR0Tai0lyLw1CG/abVqtStyCaylI0K8aVApu9+JxAtcomP4dFO/h HMfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si12736891pgq.608.2018.03.08.00.52.55; Thu, 08 Mar 2018 00:53:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965313AbeCHIvq (ORCPT + 99 others); Thu, 8 Mar 2018 03:51:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:51094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755224AbeCHIvo (ORCPT ); Thu, 8 Mar 2018 03:51:44 -0500 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 69AA52133D; Thu, 8 Mar 2018 08:51:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69AA52133D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mhiramat@kernel.org From: Masami Hiramatsu To: Steven Rostedt , linux-kernel@vger.kernel.org Cc: mhiramat@kernel.org, Ingo Molnar , Namhyung Kim , Tom Zanussi , Arnaldo Carvalho de Melo , linux-trace-users@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org Subject: [PATCH v5 17/19] selftests: ftrace: Add a testcase for symbol type Date: Thu, 8 Mar 2018 17:51:20 +0900 Message-Id: <152049908037.7289.10781368517931604646.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <152049860385.7289.14079393589900496424.stgit@devbox> References: <152049860385.7289.14079393589900496424.stgit@devbox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a testcase for symbol type with kprobe event. This tests good/bad syntax combinations and also the traced data. If the kernel doesn't support symbol type, it skips the test as UNSUPPORTED. Signed-off-by: Masami Hiramatsu --- Changes in v3: - Use IP/PC register to test the symbol type --- .../ftrace/test.d/kprobe/kprobe_args_symbol.tc | 77 ++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc new file mode 100644 index 000000000000..20a8664a838b --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc @@ -0,0 +1,77 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe event argument symbol type + +[ -f kprobe_events ] || exit_unsupported # this is configurable + +grep -qe "type:.* symbol" README || exit_unsupported # version issue + +echo 0 > events/enable +echo > kprobe_events + +PROBEFUNC="vfs_read" +GOODREG= +BADREG= +REG= +GOODSYM="_sdata" +if ! grep -qw ${GOODSYM} /proc/kallsyms ; then + GOODSYM=$PROBEFUNC +fi + +case `uname -m` in +x86_64|i[3456]86) + GOODREG=%ax + BADREG=%ex + REG=%ip +;; +aarch64) + GOODREG=%x0 + BADREG=%ax + REG=%pc +;; +arm*) + GOODREG=%r0 + BADREG=%ax + REG=%pc +;; +*) + echo "Please implement other architecture here" + exit_untested +esac + +test_goodarg() # Good-args +{ + while [ "$1" ]; do + echo "p ${PROBEFUNC} $1" > kprobe_events + shift 1 + done; +} + +test_badarg() # Bad-args +{ + while [ "$1" ]; do + ! echo "p ${PROBEFUNC} $1" > kprobe_events + shift 1 + done; +} + +echo > kprobe_events + +: "Symbol type" +test_goodarg "${GOODREG}:symbol" "@${GOODSYM}:symbol" "@${GOODSYM}+10:symbol" \ + "\$stack0:symbol" "+0(\$stack):symbol" +test_badarg "\$comm:symbol" + +: "Retval with symbol type" +echo "r ${PROBEFUNC} \$retval:symbol" > kprobe_events + +echo > kprobe_events + +: "Test get symbol" +echo "p:testprobe create_trace_kprobe ${REG}:symbol" > kprobe_events +echo 1 > events/kprobes/testprobe/enable +! echo test >> kprobe_events +tail -n 1 trace | grep -q "arg1=create_trace_kprobe" + +echo 0 > events/enable +echo > kprobe_events