From patchwork Tue Jun 13 03:39:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 107059 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp282764vqr; Mon, 12 Jun 2023 20:44:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4GU+qA9amluBkWSYPCTe1O7yDGQMFo4F3pKCzaVHpVsisoINSbC+aaaacMgxKS6R7DibSy X-Received: by 2002:a17:906:58cf:b0:978:8685:71cd with SMTP id e15-20020a17090658cf00b00978868571cdmr14454368ejs.71.1686627845917; Mon, 12 Jun 2023 20:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686627845; cv=none; d=google.com; s=arc-20160816; b=RdntjPdcEjXpssZmsBrIUWCJMdtiGTo20LOaQIG6yzc2uWKpm3lxCrBQWG49hPCg18 VPauf6QUSp7mozKO4NgxggP/4q3kctaBa60prBlthZxIG0nNG0DsEPWr2TN51t/YGl45 wvddZE2qbgPOrmFIHia45l76ie1fngD7hvPhzMMfuy3WIBsqKZ4WCmMNjs9/t5ZURnxI o7WTDnjWghJ2jJOlEcNAj3J9AwksB3eug+XmwSM+XZ4B0l+v3iLjeaSOD7qwPQBMYyh8 tTrcL9OQNK1p/0COJC8IcCWsA2Bub5BW+6RwDWKFiMZ+Fcqzp78BA8za33k/JxrdvblT PFsA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=t0oY6ZLb0sYige39ET4vNyKuPmpsycdY7XxiZLEGOsE=; b=ta3WZBurmoe8Nz/F6mkeLh2MIHH+W43uKSaJLgY1R/tYz3ZaZDJA37I3VkLRKjtlSA brr7I5H+hL4Kgwju5s/69lJZZXBDNOXM12OlPXUL68AHJNsdDFYQt9sdEwd3Bh+CJKf4 4FYpGARRO041kqEiNTcfg8AjMFspHx5z+VArSM69ZkXjrK+BrX8v26WOUyPVKft2urnO 7WbV08XY9tzTA1X7q54ovbMloBpo5Cc2vJSUdtqjgJwYdcCGdUNlOagOlJrkYfUPN+Xc mtWiqNtMPQm/NSWBRTwVwa5j/ryg7utpCXE/J7FJRr1JpCMaHRvsLpn2a3QvAlWcZjCG E7BQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s18-20020a170906169200b00978993e0d2esi6146238ejd.127.2023.06.12.20.43.41; Mon, 12 Jun 2023 20:44:05 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237583AbjFMDle (ORCPT + 99 others); Mon, 12 Jun 2023 23:41:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbjFMDlb (ORCPT ); Mon, 12 Jun 2023 23:41:31 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 131391B0; Mon, 12 Jun 2023 20:41:30 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QgDqH0jdrzTl3B; Tue, 13 Jun 2023 11:40:59 +0800 (CST) Received: from localhost.localdomain (10.67.174.95) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 13 Jun 2023 11:41:27 +0800 From: Yang Jihong To: , , , , , , , , , , , , CC: Subject: [PATCH RESEND v4 1/4] perf trace-event-info: Add tracepoint_id_to_name() helper Date: Tue, 13 Jun 2023 03:39:43 +0000 Message-ID: <20230613033946.103515-2-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230613033946.103515-1-yangjihong1@huawei.com> References: <20230613033946.103515-1-yangjihong1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.95] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768557480341471474?= X-GMAIL-MSGID: =?utf-8?q?1768557480341471474?= Add tracepoint_id_to_name() helper to search for the trace events directory by given event id and return the corresponding tracepoint. Signed-off-by: Yang Jihong Acked-by: Adrian Hunter --- tools/perf/util/trace-event-info.c | 11 +++++++++++ tools/perf/util/trace-event.h | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index c24b3a15e319..a7901f4a6654 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c @@ -466,6 +466,17 @@ static struct tracepoint_path *tracepoint_id_to_path(u64 config) return NULL; } +char *tracepoint_id_to_name(u64 config) +{ + struct tracepoint_path *path = tracepoint_id_to_path(config); + char *buf = NULL; + + if (path && asprintf(&buf, "%s:%s", path->system, path->name) > 0) + return buf; + + return NULL; +} + static struct tracepoint_path *tracepoint_name_to_path(const char *name) { struct tracepoint_path *path = zalloc(sizeof(*path)); diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index a0cff184b1cd..a69ee29419f3 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h @@ -62,6 +62,12 @@ unsigned long long eval_flag(const char *flag); int read_tracing_data(int fd, struct list_head *pattrs); +/* + * Return the tracepoint name in the format "subsystem:event_name", + * callers should free the returned string. + */ +char *tracepoint_id_to_name(u64 config); + struct tracing_data { /* size is only valid if temp is 'true' */ ssize_t size;