mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yang Jihong <yangjihong1@huawei.com>
To: <peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>,
	<mark.rutland@arm.com>, <alexander.shishkin@linux.intel.com>,
	<jolsa@kernel.org>, <namhyung@kernel.org>, <irogers@google.com>,
	<adrian.hunter@intel.com>, <anshuman.khandual@arm.com>,
	<jesussanp@google.com>, <linux-perf-users@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: <yangjihong1@huawei.com>
Subject: [PATCH v4 1/4] perf trace-event-info: Add tracepoint_id_to_name() helper
Date: Tue, 16 May 2023 06:55:35 +0000	[thread overview]
Message-ID: <20230516065538.83021-2-yangjihong1@huawei.com> (raw)
In-Reply-To: <20230516065538.83021-1-yangjihong1@huawei.com>

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 <yangjihong1@huawei.com>
---
 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


  reply	other threads:[~2023-05-16  6:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16  6:55 [PATCH v4 0/4] perf tools: Add printing perf_event_attr `config` and `id` symbol in perf_event_attr__fprintf() Yang Jihong
2023-05-16  6:55 ` Yang Jihong [this message]
2023-05-16  6:55 ` [PATCH v4 2/4] perf tools: Extend PRINT_ATTRf to support printing of members with a value of 0 Yang Jihong
2023-05-16  6:55 ` [PATCH v4 3/4] perf tools: Add printing perf_event_attr type symbol in perf_event_attr__fprintf() Yang Jihong
2023-05-16  6:55 ` [PATCH v4 4/4] perf tools: Add printing perf_event_attr config " Yang Jihong
2023-05-16  9:49 ` [PATCH v4 0/4] perf tools: Add printing perf_event_attr `config` and `id` " Adrian Hunter
2023-05-19  1:19   ` Yang Jihong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230516065538.83021-2-yangjihong1@huawei.com \
    --to=yangjihong1@huawei.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=anshuman.khandual@arm.com \
    --cc=irogers@google.com \
    --cc=jesussanp@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®