Hello,
On Mon, Jun 12, 2023 at 8:41 PM Yang Jihong <yangjihong1@xxxxxxxxxx> 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@xxxxxxxxxx>
Acked-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
---
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;
I think we need to call put_tracepoints_path() before return.