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 1/4] perf trace-event-info: Add tracepoint_id_to_name() helper
Date: Wed, 19 Apr 2023 12:29:09 +0000 [thread overview]
Message-ID: <20230419122912.73746-2-yangjihong1@huawei.com> (raw)
In-Reply-To: <20230419122912.73746-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 | 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
next prev parent reply other threads:[~2023-04-19 12:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-19 12:29 [PATCH 0/4] perf tools: Add printing perf_event_attr `config` and `id` symbol in perf_event_attr__fprintf() Yang Jihong
2023-04-19 12:29 ` Yang Jihong [this message]
2023-05-10 7:48 ` [PATCH 1/4] perf trace-event-info: Add tracepoint_id_to_name() helper Adrian Hunter
2023-05-10 8:09 ` Yang Jihong
2023-04-19 12:29 ` [PATCH 2/4] perf tools: Extend PRINT_ATTRf to support printing of members with a value of 0 Yang Jihong
2023-04-19 12:29 ` [PATCH 3/4] perf tools: Add printing perf_event_attr->type symbol in perf_event_attr__fprintf() Yang Jihong
2023-05-10 8:32 ` Adrian Hunter
2023-05-10 15:51 ` Adrian Hunter
2023-05-11 7:42 ` Yang Jihong
2023-04-19 12:29 ` [PATCH 4/4] perf tools: Add printing perf_event_attr->config " Yang Jihong
2023-05-10 7:22 ` [PATCH 0/4] perf tools: Add printing perf_event_attr `config` and `id` " 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=20230419122912.73746-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;
as well as URLs for NNTP newsgroup(s).