builtin-evlist.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Builtin evlist command: Show the list of event selectors present
  3. * in a perf.data file.
  4. */
  5. #include "builtin.h"
  6. #include "util/util.h"
  7. #include <linux/list.h>
  8. #include "perf.h"
  9. #include "util/evlist.h"
  10. #include "util/evsel.h"
  11. #include "util/parse-events.h"
  12. #include "util/parse-options.h"
  13. #include "util/session.h"
  14. static char const *input_name = "perf.data";
  15. static int __cmd_evlist(void)
  16. {
  17. struct perf_session *session;
  18. struct perf_evsel *pos;
  19. session = perf_session__new(input_name, O_RDONLY, 0, false, NULL);
  20. if (session == NULL)
  21. return -ENOMEM;
  22. list_for_each_entry(pos, &session->evlist->entries, node)
  23. printf("%s\n", event_name(pos));
  24. perf_session__delete(session);
  25. return 0;
  26. }
  27. static const char * const evlist_usage[] = {
  28. "perf evlist [<options>]",
  29. NULL
  30. };
  31. static const struct option options[] = {
  32. OPT_STRING('i', "input", &input_name, "file",
  33. "input file name"),
  34. OPT_END()
  35. };
  36. int cmd_evlist(int argc, const char **argv, const char *prefix __used)
  37. {
  38. argc = parse_options(argc, argv, options, evlist_usage, 0);
  39. if (argc)
  40. usage_with_options(evlist_usage, options);
  41. return __cmd_evlist();
  42. }