Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8446185rwr; Thu, 11 May 2023 01:04:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5mEbYqHMu3wzSGkPrJ9vDCT6uIM8divASSJLXuyU0o2vad5IjUmIW1WiBmLTeL+PJGFL7E X-Received: by 2002:a17:903:1208:b0:1aa:d235:6dd4 with SMTP id l8-20020a170903120800b001aad2356dd4mr30306956plh.19.1683792290377; Thu, 11 May 2023 01:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683792290; cv=none; d=google.com; s=arc-20160816; b=CIIpOrjTHdcnxiwySZIimoAALomWgvMNxLsr7An21vzQaU6JhgRa3yjCz6HvoV6goG SSp0j8RnW9A1PiOnc86hl2egiUENUcwjVw5PQzK/pxP2Vb2uWxoERmu6FzLEOGGa9u1N 35DHfVHj41JYKN0tYiV6Rh1KgwmzxDDtrmbwEnT/33aLHoObthzBB7M+jnqzQLR4D0NG y19uD1mOZ9DS2m81Z8dmdwMgXNUAUd7ADJXuJW17bHhW/71fGmMgC6yrxAa5nHtgWRhp R7C+alikI5Ra7mytB9wxryPdlBp60lKiW04XIGIsqVu/qqEB6UJ+B7nJ3uofyaaetsev +9jA== 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=bC7Q4BwWI9FE8bCZ49L8HLyVpfOXUxjwleMH1KUGLmc=; b=Smv4bxb2RJ6s4wBOsv4ANT2cetnMeIJsDLr0CDC5/7SdAyZirIXQaaMEFs7x903Q6S jb7gUzeYJzqUdTPOvMCbi3o2P/k5otITUXreCrjiQSn3n1v75LRoNtNRVLAVcbc3aUq4 jM5EZJPf2Drh7yV6fbn792C0JZSW6Uvp/Nx2vkNCcdo9yfm+z8qtKlgkvj+/2CrWR4qU suS5OLppsdsmPO0/eIiztDQXRPvG+pX/CrxjmQyGf54qCuAqwdLNPvqae21PCKljrojg Sj7GD+3e8mdcHdTa3HivAOf5UgvR93AqiwqhjEk+SAgWhzfWdZNQzjRlXqQMbzS9x3J8 SLTA== 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 be1-20020a170902aa0100b001a645e63b73si3436366plb.566.2023.05.11.01.04.37; Thu, 11 May 2023 01:04:50 -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 S237664AbjEKHxf (ORCPT + 99 others); Thu, 11 May 2023 03:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237092AbjEKHxb (ORCPT ); Thu, 11 May 2023 03:53:31 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07B9926A5; Thu, 11 May 2023 00:53:28 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QH3tR2B5bzTkD6; Thu, 11 May 2023 15:48:47 +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; Thu, 11 May 2023 15:53:26 +0800 From: Yang Jihong To: , , , , , , , , , , , , CC: Subject: [PATCH v2 1/4] perf trace-event-info: Add tracepoint_id_to_name() helper Date: Thu, 11 May 2023 07:51:51 +0000 Message-ID: <20230511075154.240163-2-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230511075154.240163-1-yangjihong1@huawei.com> References: <20230511075154.240163-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: dggems702-chm.china.huawei.com (10.3.19.179) 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..a5c65cb02a28 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) +{ + char *buf = NULL; + struct tracepoint_path *path = tracepoint_id_to_path(config); + + if ((path != NULL) && (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