Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp200392rwr; Wed, 19 Apr 2023 05:32:49 -0700 (PDT) X-Google-Smtp-Source: AKy350ZTbTJd65l8JI2atxuWc2HQngzK2S1URh8kgsxF6YolkmWiqRLe2PS2fIRJECYTfYpPyyue X-Received: by 2002:a05:6a00:188f:b0:637:3234:4e22 with SMTP id x15-20020a056a00188f00b0063732344e22mr4231140pfh.23.1681907569292; Wed, 19 Apr 2023 05:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681907569; cv=none; d=google.com; s=arc-20160816; b=IdDx0RwxlI/UFx1XSo/fCFVe27c7t/0Kd/Z+u1cMlZ6FWTPUYwAxZd14ma2y/v/y2C b1rFqA9idy+bciW19qQLL20uBFlMB9sCzdUU9EieMGoS37y0HNBZc7RaETo5ORuHwM2z WtpwZ+1H+lKERYXrzD4/bKCdeCVlkY9e7QM9TNxf4J7K0c8jl3+MPGeBjQNOyNy1sgqb QTrkCJ7UCdLfIFUsk9bhDXrU+OY6oG3K1N+Am3Y5Lzw0l83XKT5k8IBQQgjzulNBospI 99SHUXWNJd/LMtacHEM/K4A9Twhssd1YIEb+XoPPNgxrqx5YQfWVUFTe4zczgza4FV76 sS6A== 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=t1+6OXf1UeFbr6goJqIHll9ahDMBafnbKuGdVP8eD20=; b=VX3l+ituCLjGE2HhAK34a9wPdh9vwcQKtls0fTQEpA6BzqqxSzSWdCoug8fKq1dkUd Ru74LDdoxJmtV0PoGP2L9TSyQt2EvJYkWlIXSjtUSbBGXFaHb9qMb2P7WeIwacGsTQWL pKpMHCrc7VoKdIJWGuwaok1OWVYZIKZ9as2L/sSwsDM1dxXSMQXgrgXmNGdA962GkuYu nvS61jh8skBqlotAzP/MoP6hAdRHrMNloJnfISLx7bgife9dU8jyAaIdFr6zRrDhbvhL Sg98NTsr3KZXyJca8m+1wluGdgwUlsKoGcSlNKeSIdGIuCD2PLgnUr7Vg8gvZ8WV5LNy F9KQ== 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 d9-20020a631d09000000b00520d737cf49si1480700pgd.271.2023.04.19.05.32.37; Wed, 19 Apr 2023 05:32:49 -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 S232769AbjDSMbV (ORCPT + 99 others); Wed, 19 Apr 2023 08:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232459AbjDSMbQ (ORCPT ); Wed, 19 Apr 2023 08:31:16 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F16717685; Wed, 19 Apr 2023 05:31:13 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Q1g5j1dYgzStCN; Wed, 19 Apr 2023 20:27:05 +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; Wed, 19 Apr 2023 20:31:11 +0800 From: Yang Jihong To: , , , , , , , , , , , , CC: Subject: [PATCH 1/4] perf trace-event-info: Add tracepoint_id_to_name() helper Date: Wed, 19 Apr 2023 12:29:09 +0000 Message-ID: <20230419122912.73746-2-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230419122912.73746-1-yangjihong1@huawei.com> References: <20230419122912.73746-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: dggems703-chm.china.huawei.com (10.3.19.180) 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 --- tools/perf/util/trace-event-info.c | 13 +++++++++++++ tools/perf/util/trace-event.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index c24b3a15e319..79907caaf0ca 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c @@ -466,6 +466,19 @@ static struct tracepoint_path *tracepoint_id_to_path(u64 config) return NULL; } +char *tracepoint_id_to_name(u64 config) +{ + char buf[MAX_EVENT_LENGTH]; + struct tracepoint_path *path = NULL; + + path = tracepoint_id_to_path(config); + if (path == NULL) + return NULL; + + snprintf(buf, sizeof(buf), "%s:%s", path->system, path->name); + return strdup(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