Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1036139rwb; Wed, 26 Jul 2023 06:46:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlFT2xaEbyjVN7LNs1kznyEm1IMlP8iWczFqjun3xyDH9Y98ujCyd/lBot5cIgqeQnIN+Rwt X-Received: by 2002:aa7:c1d6:0:b0:522:2af1:1ffe with SMTP id d22-20020aa7c1d6000000b005222af11ffemr1796170edp.9.1690379201541; Wed, 26 Jul 2023 06:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690379201; cv=none; d=google.com; s=arc-20160816; b=ZBJRRGLcIxh9tgLCw6Lwak4Szr9vzGsv+WuDyl+DpsU1UjhWI8SsXTFesNzhBiHuBY jm3vXMsLInNBd7ls0+RXp2Q+PzfR2fn/7iqD3bUcasiZBYKh26e1TzKl62XvbbAGvHwt fAsgrV/GBE0xOM8DJZ2F2cOzY5nOiJ+PJqcGxnPYp2qmUak0HWyLyXZafeTCRWZQzTZ9 3CI+6KTuxx1OyiNrkiBvN6W17GvQOsxw5L7yvLfFuBWhjmNh1pvhXsPUg0Z5liVIIskB +c/xl2dKQpALxMmajfQys7j7s/cD5NgZjctX1U9n/0WRs/ynNkz1VqGGZN1c+ZBfhDZG BsnQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b4-20020aa7cd04000000b0051bec40640bsi9046338edw.603.2023.07.26.06.46.16; Wed, 26 Jul 2023 06:46:41 -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 S233710AbjGZNBp (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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 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