Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12000169rwd; Thu, 22 Jun 2023 23:21:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5D7dtCz5foY7zTytXAxSvKIboKl+6lfbkJab2k0InJmmgLIx4ABzQBHih9d3Y+4rXVxIQe X-Received: by 2002:a17:902:d512:b0:1b6:6c32:59a8 with SMTP id b18-20020a170902d51200b001b66c3259a8mr12068842plg.36.1687501276234; Thu, 22 Jun 2023 23:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687501276; cv=none; d=google.com; s=arc-20160816; b=OGr9ONV/Sy3B7ZZfiT1gZ5o4ZH+52e28Ug+Y5ZQAPM85etkuavXL25lcQBU/kK/e+1 9aUL9tsjEpxaRPCqd11tAO47EG+yt+QI4SJ57/SK3beSuDttMC4jii5DsdHqNgsDLY4k IIQIcHaPuQH8HooZKFdpTyFTKCYV04CLFGHuFQl/yzdh1e647fuvrU4k0Q1W6iKWImHz jSOXSXn/aHlLRzQIWLIENQ2zJ98Yjss7hhNGecsm6moG9L17N+suUViftfUH/BILqzm4 WZG+M6oKcMWaObSfKweLTdqrCkT2fRhjh4LT7x0dlnE2/Lb6LkYswIM3DR86ATe03Glm +Liw== 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=MH3p8LPQaHyyR7Q7R4gDTsoXeEiBhZ2GeRZhkcyNIAM=; b=ykLg74DSpZkzOzYC2cuPYbo/OmTeysocPLkZcq2MPvXb6ToxrqDUnxRofFs2CzGtUV ZrJ9tjyvNEebuvXxQyp6jRUIqEQYma1Ba7oGVccJXqxlrpszq42ngqnWc/xaZap53CBI rnTgr2ZwoY7IhqmZe09aiFT/GttCSmu45/CTu0JaeP/yQ1y0tr4SSgsAyVFgNTJh0DcZ uabM0QVL2wBs00h8u6pbpMZWFYo9GYwW5p+VgB/2CMq38FWUybnzTtd52DvnqkextLpF jNi8XfsLyI7fg4yTIclTTGSK2KQVBmWpz5IiS/jAwXLdoyCLND2AZbZ0xJ3NVWFjyxW9 FptQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a170903018500b001b3da77c1f1si8579743plg.194.2023.06.22.23.21.04; Thu, 22 Jun 2023 23:21:16 -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 S231556AbjFWFq7 (ORCPT + 99 others); Fri, 23 Jun 2023 01:46:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbjFWFqw (ORCPT ); Fri, 23 Jun 2023 01:46:52 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F047226B5; Thu, 22 Jun 2023 22:46:16 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QnR6t6tPvzqTpB; Fri, 23 Jun 2023 13:45:58 +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.27; Fri, 23 Jun 2023 13:46:08 +0800 From: Yang Jihong To: , , , , , , , , , , , , CC: Subject: [PATCH v5 1/4] perf trace-event-info: Add tracepoint_id_to_name() helper Date: Fri, 23 Jun 2023 05:44:13 +0000 Message-ID: <20230623054416.160858-2-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230623054416.160858-1-yangjihong1@huawei.com> References: <20230623054416.160858-1-yangjihong1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.95] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 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 | 12 ++++++++++++ tools/perf/util/trace-event.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index c24b3a15e319..319ccf09a435 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c @@ -466,6 +466,18 @@ 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) + buf = NULL; + + put_tracepoints_path(path); + return buf; +} + 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; -- 2.30.GIT