]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf header: Add utility to convert feature number to a string
authorIan Rogers <irogers@google.com>
Wed, 1 Apr 2026 16:13:18 +0000 (09:13 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 3 Apr 2026 02:35:16 +0000 (19:35 -0700)
For logging and debug messages it can be convenient to convert a
feature number to a name. Add header_feat__name for this and reuse the
data already within the feat_ops struct.

Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/header.c
tools/perf/util/header.h

index 9ffc0f4ca6d132daba499745b1b23062f7b83d2c..34178ce826fbfaa2f1bd3d4660895554535afb53 100644 (file)
@@ -3780,6 +3780,13 @@ struct header_print_data {
        bool full; /* extended list of headers */
 };
 
+const char *header_feat__name(unsigned int id)
+{
+       if (id < HEADER_LAST_FEATURE)
+               return feat_ops[id].name ?: "INVALID";
+       return "INVALID";
+}
+
 static int perf_file_section__fprintf_info(struct perf_file_section *section,
                                           struct perf_header *ph,
                                           int feat, int fd, void *data)
index cc40ac796f52644b09c4771c0fd34f6c3c2c46d2..ca22030a143435f2c87084c77e152dc6b9bdf819 100644 (file)
@@ -132,6 +132,8 @@ struct perf_header_feature_ops {
 
 extern const char perf_version_string[];
 
+const char *header_feat__name(unsigned int id);
+
 int perf_session__read_header(struct perf_session *session);
 int perf_session__write_header(struct perf_session *session,
                               struct evlist *evlist,