M7350/kernel/tools/perf/builtin-evlist.c

68 lines
1.7 KiB
C
Raw Permalink Normal View History

2024-09-09 08:52:07 +00:00
/*
* Builtin evlist command: Show the list of event selectors present
* in a perf.data file.
*/
#include "builtin.h"
#include "util/util.h"
#include <linux/list.h>
#include "perf.h"
#include "util/evlist.h"
#include "util/evsel.h"
#include "util/parse-events.h"
#include "util/parse-options.h"
#include "util/session.h"
2024-09-09 08:57:42 +00:00
#include "util/data.h"
#include "util/debug.h"
2024-09-09 08:52:07 +00:00
2024-09-09 08:57:42 +00:00
static int __cmd_evlist(const char *file_name, struct perf_attr_details *details)
2024-09-09 08:52:07 +00:00
{
struct perf_session *session;
struct perf_evsel *pos;
2024-09-09 08:57:42 +00:00
struct perf_data_file file = {
.path = file_name,
.mode = PERF_DATA_MODE_READ,
};
2024-09-09 08:52:07 +00:00
2024-09-09 08:57:42 +00:00
session = perf_session__new(&file, 0, NULL);
2024-09-09 08:52:07 +00:00
if (session == NULL)
2024-09-09 08:57:42 +00:00
return -1;
2024-09-09 08:52:07 +00:00
2024-09-09 08:57:42 +00:00
evlist__for_each(session->evlist, pos)
perf_evsel__fprintf(pos, details, stdout);
2024-09-09 08:52:07 +00:00
perf_session__delete(session);
return 0;
}
2024-09-09 08:57:42 +00:00
int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
{
struct perf_attr_details details = { .verbose = false, };
const struct option options[] = {
OPT_STRING('i', "input", &input_name, "file", "Input file name"),
OPT_BOOLEAN('F', "freq", &details.freq, "Show the sample frequency"),
OPT_BOOLEAN('v', "verbose", &details.verbose,
"Show all event attr details"),
OPT_BOOLEAN('g', "group", &details.event_group,
"Show event group information"),
2024-09-09 08:52:07 +00:00
OPT_END()
2024-09-09 08:57:42 +00:00
};
const char * const evlist_usage[] = {
"perf evlist [<options>]",
NULL
};
2024-09-09 08:52:07 +00:00
argc = parse_options(argc, argv, options, evlist_usage, 0);
if (argc)
usage_with_options(evlist_usage, options);
2024-09-09 08:57:42 +00:00
if (details.event_group && (details.verbose || details.freq)) {
pr_err("--group option is not compatible with other options\n");
usage_with_options(evlist_usage, options);
}
return __cmd_evlist(input_name, &details);
2024-09-09 08:52:07 +00:00
}