From patchwork Mon Jul 31 07:31:22 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: 128439 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1869304vqg; Mon, 31 Jul 2023 01:19:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlGDHeuuwMYpmymXRnCexXOpXp5Lo8DzS28WgamqbHU5XvmFTSKQbVkvNN40vtuJJPDP4vWF X-Received: by 2002:a17:907:2c4d:b0:99b:d2a9:99f5 with SMTP id hf13-20020a1709072c4d00b0099bd2a999f5mr6536987ejc.6.1690791574229; Mon, 31 Jul 2023 01:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690791574; cv=none; d=google.com; s=arc-20160816; b=Ak4Rlx8rEriGInn1IjAGNvn6GUOBTGgfz3S9HXOWi5+u2clMro0MZCkkSvpssXsgxC 8kc4BIfIYF6gfgu1vw6oBRN9PWUVsWGeBO1Se1PANejrWSt0CA25oOzD7UvGjuGqJXMp 1pWE0sFoszjA0dihAgLOdZrfX2MqKGVa+7X420u2hX8ASX9sktBnyZZ4CVuo7/30vyJB cKntTicSIFNOCl/xJ3IhS382X+AhgnV7hrDbhZJwzVUsi8glBuEoqhGHEGoCJM1qIAaT RV5/aBOtvhxzYFGT0+9SBrc4X1m1YUGOzOn++Xxjo4DB43UW0xGbQbi+tNdFbcQzGFls cCsA== 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=VEtR8jAgQVcyUg8st/WV1lkMbKTTOGaf4dvRsa0v9NEDd+hYt7FULHkR5DB/qCOVwh 6s6aCLKYSYoHoZ4a5dw8q3bOl9+SNplt2emIQMhXvZMvEfGYA/tLY3SbEquod4HOWSsx 4XY11sVsloTj20+ksOIQqFWbxNyECxgDhgu0uTA7j20hRKSlG7Rvmr1r6idxnnE/YPnb 6PehDe0F4laaFslH8XEuoijCABAQERl+2+73gyiJozIqfXdbqAJOAbD5F0xAx9VHc/+3 2JGOKWfzKhLCYacnNgSgJCS5p8gVvhVRZLgdnird7w3vviuVEgmqQhUwGf05sBTJDnUk 3l8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a1G1qgfT; 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 k6-20020a17090646c600b00992d0de8763si6810705ejs.910.2023.07.31.01.19.09; Mon, 31 Jul 2023 01:19:34 -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=a1G1qgfT; 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 S230311AbjGaHcv (ORCPT + 99 others); Mon, 31 Jul 2023 03:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230309AbjGaHcO (ORCPT ); Mon, 31 Jul 2023 03:32:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 522481BC9; Mon, 31 Jul 2023 00:31:28 -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 DB0DE60DF0; Mon, 31 Jul 2023 07:31:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B722C433C7; Mon, 31 Jul 2023 07:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690788687; bh=KGJEEq13A9go4Yhd3XiG1sdw1r30ps972RCgI6Rs1/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a1G1qgfTsdvrtkIT3v662J7BXCoWxQlHFUC+VqEihQx14Afq1GzMqwKHyLylUK9Va aTP0YEozlL+xyyAp939Gq+RAou0Bqv5Ggs7biyQBxzUMjnHIofUjXlz9AJI5n3ol9J qUXxIZygZlW3xMn78IJei09bMJ/SzuUIyF81XRNHrclxT59OUuSo6FID0I5WRG//TR /Sm1R432P4Gg/IUBkDyltRHrxLyfTT2oWty0HT6L2JbuvPSzi0cPTzFS7w/zkKp3GP LPNx5dOcTj+D/MG6RDXTr9PNz7F1GUbxNr5usRv11lp2S9R+Cc+77SJXMX8UMOyHV9 GMHJ+XmVAaesg== 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 v4 8/9] selftests/ftrace: Add BTF fields access testcases Date: Mon, 31 Jul 2023 16:31:22 +0900 Message-Id: <169078868262.173706.15416052542086569996.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <169078860386.173706.3091034523220945605.stgit@devnote2> References: <169078860386.173706.3091034523220945605.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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: 1772923465686567048 X-GMAIL-MSGID: 1772923465686567048 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