From patchwork Fri Jun 23 05:44:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 111941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5567357vqr; Thu, 22 Jun 2023 23:26:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6QDCb5E2K/PzNL0I48U89PREM38zp/TzD0YrfknqNegFEwuPdVL8fBgJmgVS5RbB6MOzaX X-Received: by 2002:a17:90a:fb52:b0:25b:b4c6:d13e with SMTP id iq18-20020a17090afb5200b0025bb4c6d13emr14312106pjb.8.1687501578658; Thu, 22 Jun 2023 23:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687501578; cv=none; d=google.com; s=arc-20160816; b=Ab4IFk+5R48debz9cbCk6pjvOCovN7p/Otq0OdrcvGPf3NoQo2Bn1JA3OaeHaGTMo4 Kcyrk27s6RWf3FnxYSlpZvjD0DQ8SH5wQFSnoqpOQXIJjgqn6/+imkz/yaiX6/ESGdd2 ycqrSDqYmdbq06a0J4mB3dkQ2vTvow3eN2+m/MBbqf4LCQlwWLhXLLVM7l447vHu9af0 i7YzY1DJrJ2G5ALDdEQlXX9TL1OVt3xsGDL/o48H2+e7wgf5Ht95rdpa2s+b/0+eZzj+ VReycjyODvHzJWQidVX2QAqcPOxeF/ryVQLM0NI8KvF61cI9bvyjLc3Sw0V+/u9umr5L 5Q+Q== 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=; fh=AtKtIzx4MADo1dp8HWRmKE0KbJISQR2HW/uywfEvV2Y=; b=ac50YLhrxkE95P23V2w4QzuMIedhTafwVVKdXVYI5/uJfbXPUmlQgvAIS1+6bRTlxi dEsqaUJ8hsSt6bKUS+2mr82Ej2EFv3NKbQAYeWsmnqlVq/P1NTCrZbbF692/HfKfg6gQ uFFskPm6C5y2E6agppdsdMDFN8uqVUF/tSir32Oah+qYsmPnnJdYFXtDRtrLKuFtLcxW VAgofic3zdmeW/tDokmQWGBU5Jc+4YjBzdXPooQDWz3vxx26VOnju+rOjx+7R0VVjS3W NCm2ZIr6r2nBZNitae/mfPgnGS+X7O0kT0JMbLhO2F1i7q3naocX2eXH0+OaxMWS/on0 WlAw== 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 ml16-20020a17090b361000b0025bd695c39dsi1230883pjb.66.2023.06.22.23.26.06; Thu, 22 Jun 2023 23:26:18 -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 S231515AbjFWFrA (ORCPT + 99 others); Fri, 23 Jun 2023 01:47:00 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769473655224977275?= X-GMAIL-MSGID: =?utf-8?q?1769473655224977275?= 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;