Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1734566rwd; Mon, 15 May 2023 02:11:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5msj20FfpwO96NG9J7touojQ62nT/EYqV10NbURn3JvGQyvZSKPhNNs7VOwn7expT62wPZ X-Received: by 2002:a05:6a20:8f10:b0:102:345f:593b with SMTP id b16-20020a056a208f1000b00102345f593bmr24413198pzk.4.1684141867434; Mon, 15 May 2023 02:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684141867; cv=none; d=google.com; s=arc-20160816; b=jEMNd9IwrjPQ7mBZTYI3HmKUxuBe0ZxYmJ/nxJInkLZ9PPFOMWNsBRtKjdCC6ZIcpu bzXZvpc9D1Xbd2wubAOxlx+lppkcCwGO7VJqFIkfaDLC38TQgyA+bFnsPiYI+F9RSFN1 OQGS/Sp49oRGjvrT7Gw61GhS9Ai1l8uQBlXoaWFR69BEZbWhIid9IaXmi4+jMXcxt2fm 2b1fVhvbJ6wQPoZaRFOl/A24FlYGZjKBkzP46YM0U6GZOuso4k5qvk/KxRkngF050pPb MYIZlrZxm6zt8DVkkSNv/IEZRSwV0ZXgWUajwjxd87yuWHemHqMhLiCz0GtMWfRzatV1 3Rsg== 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=XEOcZagM5tZHuST3GqtrR9nwHCymKFUhNJ9KdlsNijY=; b=dqvjjAF7bSty7r3yQvGOw2AlHJp3RlKZPwX4jfd9IbNssLtHEv3twAO7J4w+JAEcX4 KxnOftfEI/9aRr5AkseLwN6sclpcMrq5o/YYXme9gFmLYUSmCfyf7oA/pFyu34Mdqgjz de3kKHCr8ufROpcgQLKuzzFFCfK2nGKS3SKOnU/WmZ9RsyXy907ngZehjan15JdlA0Tg LRAPbrgjQHVkfEp2r9F0FSpawHF2B1TD941HmZOCYzXashmfx6Aot2Xet6E/Am0kv1Fh FcAYsImtRpkHhMSyyD8dFM2778iIx1B9iaS9Tf4YHZWYozZz+4pJD/i0yRlvUBQLJFuQ HbtA== 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 w1-20020a637b01000000b00502d825633asi14976729pgc.639.2023.05.15.02.10.55; Mon, 15 May 2023 02:11:07 -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 S238840AbjEOI6z (ORCPT + 99 others); Mon, 15 May 2023 04:58:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238648AbjEOI6t (ORCPT ); Mon, 15 May 2023 04:58:49 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F04211985; Mon, 15 May 2023 01:58:45 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QKY8J4x5mzqSNr; Mon, 15 May 2023 16:54:24 +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; Mon, 15 May 2023 16:58:42 +0800 From: Yang Jihong To: , , , , , , , , , , , , CC: Subject: [PATCH v3 1/4] perf trace-event-info: Add tracepoint_id_to_name() helper Date: Mon, 15 May 2023 08:57:04 +0000 Message-ID: <20230515085707.124549-2-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230515085707.124549-1-yangjihong1@huawei.com> References: <20230515085707.124549-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: dggems706-chm.china.huawei.com (10.3.19.183) 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 | 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; -- 2.30.GIT