From: Adrian Hunter <adrian.hunter@intel.com>
To: Yang Jihong <yangjihong1@huawei.com>,
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,
anshuman.khandual@arm.com, jesussanp@google.com,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] perf trace-event-info: Add tracepoint_id_to_name() helper
Date: Wed, 10 May 2023 10:48:39 +0300 [thread overview]
Message-ID: <07770bac-cbeb-170e-b3c1-d0276d4ffef3@intel.com> (raw)
In-Reply-To: <20230419122912.73746-2-yangjihong1@huawei.com>
On 19/04/23 15:29, Yang Jihong wrote:
> 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;
Initializer should be tracepoint_id_to_path(config) i.e.
struct tracepoint_path *path = tracepoint_id_to_path(config);
> +
> + path = tracepoint_id_to_path(config);
> + if (path == NULL)
> + return NULL;
> +
> + snprintf(buf, sizeof(buf), "%s:%s", path->system, path->name);
asprintf() can be used then buf and strdup() are not needed.
> + 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;
next prev parent reply other threads:[~2023-05-10 7:49 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 ` [PATCH 1/4] perf trace-event-info: Add tracepoint_id_to_name() helper Yang Jihong
2023-05-10 7:48 ` Adrian Hunter [this message]
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=07770bac-cbeb-170e-b3c1-d0276d4ffef3@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--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 \
--cc=yangjihong1@huawei.com \
/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).