From patchwork Wed Jul 26 13:01:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 126383 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp415240vqo; Wed, 26 Jul 2023 06:48:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlFlui7OYQolWHEw6aGb+ZlGSgztb1hHoEMiOZ49qr3N3tMRt8isouRMRryM/j8845H8H+Vk X-Received: by 2002:a17:907:7808:b0:994:56db:cb8d with SMTP id la8-20020a170907780800b0099456dbcb8dmr1684749ejc.14.1690379320442; Wed, 26 Jul 2023 06:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690379320; cv=none; d=google.com; s=arc-20160816; b=zsZO2VF0RdwbpWb0kJdIbSnD5jM7zNk5A1+swesvFQmPbvUoxm1OmjMWGqQ9u2DNPP vlOWiF4Yke4AHIarxrAI+yQOpxVAKq5xo2YBb7/PBeedCI145MpC/R5g4r2z78pKBn8i 5TGnFv9ImkAnu63fidCsMMvW1xzHJjFcwdBUlrAyf/pbWH2MEJFjON28o2ryekyGaMoB U5y4Y1FW72wuwMQ/5R87mbVRwSccJF2tBGI0vgPYWP2JPobzAv/WNUDzM54ndRkwZ6nw fNLbXtdLRtI5+eDbN1LCj1MsoBr9hclexqxUcQEU07bDLbFNN3BHXTcqaxrbigByfLzu ItDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xxRs3BjVlLT/9+COVbQzeVags52U/8tzEQAcUJrjoSc=; fh=raxTTJvC+dSJYbgfX5JG5gvrVjxTZXczN0HF8iDayLY=; b=qLQJlutN9XLEOnH//3rYhl6ym8eEMpD8+C/NL28gPy8YiqR2+/V8VmbaWC2jhZWuyX kF6ejjCoy7l/IF35DRtyvGduzoAscbEDFx/MrVZAbMQJslGvUHs8GE/dd0OcmUT7hyhZ HSZ4X7CANBFbNrZ0+x6S9VqX1fbKu2/0DFdZUrqF4Pxs7asDEAT9pLTTbLYXXclCh0hg jP1gnm7xyiaq832OV4AtWBkR+4oOTK5hWAWhXs4KKpdp5IB/4PYqnF9K2LJV0HcMTYXj AV8RjPHnTVrOXkWpEw9V2nn+/NaeEwBEjj4d1ChidHJPB13x8+cDMuJyU4RMwjajXGSI EZjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hLtG+6zV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020a170906c31000b00991f4e7f49asi9001749ejz.215.2023.07.26.06.48.15; Wed, 26 Jul 2023 06:48:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hLtG+6zV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233751AbjGZNBp (ORCPT + 99 others); Wed, 26 Jul 2023 09:01:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233726AbjGZNBa (ORCPT ); Wed, 26 Jul 2023 09:01:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9E112689; Wed, 26 Jul 2023 06:01:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4E3B6617A0; Wed, 26 Jul 2023 13:01:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CEBF4C433C8; Wed, 26 Jul 2023 13:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690376475; bh=KGJEEq13A9go4Yhd3XiG1sdw1r30ps972RCgI6Rs1/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hLtG+6zVJFvWeSUaYKZadVKdntgfcrrog6jSXxIKWqkPk1S2ukerb1CcomtuIQNb3 gmLsCCtW9lpiMpW/7SzbkVeVGmjVdECwlXNriH7acx8jplPEK3BzEBGynJaLJWxcUZ +euWgPGhCflOdMl5sxqXbeTrWfJ/hHM2O/l57ELU60f9yqazpOsYXNj852RrDPlXMJ fwm9KRMFe6pulQmqOscoFh1WOqa5LOkLWfiSg9z7ta0yaqlVxne414OXI8tME66quK 5Wx0re1TKdRgJpkgFqbxpqlcqQFhr14K2LD84kPoGx64Z6I5CQFTZY/rNsEL/sVoEt 9bh2KAH2bAeKQ== From: "Masami Hiramatsu (Google)" To: linux-trace-kernel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Steven Rostedt , mhiramat@kernel.org, Martin KaFai Lau , bpf@vger.kernel.org, Sven Schnelle , Alexei Starovoitov Subject: [PATCH v3 8/9] selftests/ftrace: Add BTF fields access testcases Date: Wed, 26 Jul 2023 22:01:11 +0900 Message-Id: <169037647132.607919.15889838982085210322.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <169037639315.607919.2613476171148037242.stgit@devnote2> References: <169037639315.607919.2613476171148037242.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772491186427151580 X-GMAIL-MSGID: 1772491186427151580 From: Masami Hiramatsu (Google) Add test cases for accessing the data structure fields using BTF info. This includes the field access from parameters and retval, and accessing string information. Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Alan Maguire --- Changes in v2: - Use '$retval' instead of 'retval'. - Add a test that use both '$retval' and '$arg1' for fprobe. Changes in v3: - Change a test case with a numeric value. - Add a test case with mixed '.' and '->' operators. --- .../ftrace/test.d/dynevent/add_remove_btfarg.tc | 14 ++++++++++++++ .../ftrace/test.d/dynevent/fprobe_syntax_errors.tc | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc index f34b14ef9781..4bfd2f45db42 100644 --- a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc +++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc @@ -21,6 +21,9 @@ echo 0 > events/enable echo > dynamic_events TP=kfree +TP2=kmem_cache_alloc +TP3=getname_flags +TP4=sched_wakeup if [ "$FPROBES" ] ; then echo "f:fpevent $TP object" >> dynamic_events @@ -33,6 +36,7 @@ echo > dynamic_events echo "f:fpevent $TP "'$arg1' >> dynamic_events grep -q "fpevent.*object=object" dynamic_events + echo > dynamic_events echo "f:fpevent $TP "'$arg*' >> dynamic_events @@ -45,6 +49,16 @@ fi echo > dynamic_events +echo "t:tpevent ${TP2} obj_size=s->object_size" >> dynamic_events +echo "f:fpevent ${TP3}%return path=\$retval->name:string" >> dynamic_events +echo "t:tpevent2 ${TP4} p->se.group_node.next->prev" >> dynamic_events + +grep -q "tpevent .*obj_size=s->object_size" dynamic_events +grep -q "fpevent.*path=\$retval->name:string" dynamic_events +grep -q 'tpevent2 .*p->se.group_node.next->prev' dynamic_events + +echo > dynamic_events + if [ "$KPROBES" ] ; then echo "p:kpevent $TP object" >> dynamic_events grep -q "kpevent.*object=object" dynamic_events diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/fprobe_syntax_errors.tc b/tools/testing/selftests/ftrace/test.d/dynevent/fprobe_syntax_errors.tc index 72563b2e0812..49758f77c923 100644 --- a/tools/testing/selftests/ftrace/test.d/dynevent/fprobe_syntax_errors.tc +++ b/tools/testing/selftests/ftrace/test.d/dynevent/fprobe_syntax_errors.tc @@ -103,6 +103,10 @@ check_error 'f vfs_read%return ^$arg*' # NOFENTRY_ARGS check_error 'f vfs_read ^hoge' # NO_BTFARG check_error 'f kfree ^$arg10' # NO_BTFARG (exceed the number of parameters) check_error 'f kfree%return ^$retval' # NO_RETVAL +check_error 'f vfs_read%return $retval->^foo' # NO_PTR_STRCT +check_error 'f vfs_read file->^foo' # NO_BTF_FIELD +check_error 'f vfs_read file^-.foo' # BAD_HYPHEN +check_error 'f vfs_read ^file:string' # BAD_TYPE4STR else check_error 'f vfs_read ^$arg*' # NOSUP_BTFARG check_error 't kfree ^$arg*' # NOSUP_BTFARG