builtin-list.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * builtin-list.c
  3. *
  4. * Builtin list command: list all event types
  5. *
  6. * Copyright (C) 2009, Thomas Gleixner <tglx@linutronix.de>
  7. * Copyright (C) 2008-2009, Red Hat Inc, Ingo Molnar <mingo@redhat.com>
  8. * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
  9. */
  10. #include "builtin.h"
  11. #include "perf.h"
  12. #include "util/parse-events.h"
  13. #include "util/cache.h"
  14. #include "util/pmu.h"
  15. int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
  16. {
  17. setup_pager();
  18. if (argc == 1)
  19. print_events(NULL, false);
  20. else {
  21. int i;
  22. for (i = 1; i < argc; ++i) {
  23. if (i > 2)
  24. putchar('\n');
  25. if (strncmp(argv[i], "tracepoint", 10) == 0)
  26. print_tracepoint_events(NULL, NULL, false);
  27. else if (strcmp(argv[i], "hw") == 0 ||
  28. strcmp(argv[i], "hardware") == 0)
  29. print_events_type(PERF_TYPE_HARDWARE);
  30. else if (strcmp(argv[i], "sw") == 0 ||
  31. strcmp(argv[i], "software") == 0)
  32. print_events_type(PERF_TYPE_SOFTWARE);
  33. else if (strcmp(argv[i], "cache") == 0 ||
  34. strcmp(argv[i], "hwcache") == 0)
  35. print_hwcache_events(NULL, false);
  36. else if (strcmp(argv[i], "pmu") == 0)
  37. print_pmu_events(NULL, false);
  38. else if (strcmp(argv[i], "--raw-dump") == 0)
  39. print_events(NULL, true);
  40. else {
  41. char *sep = strchr(argv[i], ':'), *s;
  42. int sep_idx;
  43. if (sep == NULL) {
  44. print_events(argv[i], false);
  45. continue;
  46. }
  47. sep_idx = sep - argv[i];
  48. s = strdup(argv[i]);
  49. if (s == NULL)
  50. return -1;
  51. s[sep_idx] = '\0';
  52. print_tracepoint_events(s, s + sep_idx + 1, false);
  53. free(s);
  54. }
  55. }
  56. }
  57. return 0;
  58. }