diff options
| author | Ian Rogers <irogers@google.com> | 2026-04-01 19:13:18 +0300 |
|---|---|---|
| committer | Namhyung Kim <namhyung@kernel.org> | 2026-04-03 05:35:16 +0300 |
| commit | 8cc518735beb879c51df712a5ce5893c02f81b12 (patch) | |
| tree | e7d529ddd46566dfa7716df4ec50c73d97124cbc /tools | |
| parent | 623030fd0ad59ecc4197b0c0f8dd066a0f0598b3 (diff) | |
| download | linux-8cc518735beb879c51df712a5ce5893c02f81b12.tar.xz | |
perf header: Add utility to convert feature number to a string
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>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/util/header.c | 7 | ||||
| -rw-r--r-- | tools/perf/util/header.h | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 9ffc0f4ca6d1..34178ce826fb 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -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) diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index cc40ac796f52..ca22030a1434 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -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, |
