event.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef __PERF_RECORD_H
  2. #define __PERF_RECORD_H
  3. #include <limits.h>
  4. #include "../perf.h"
  5. #include "map.h"
  6. /*
  7. * PERF_SAMPLE_IP | PERF_SAMPLE_TID | *
  8. */
  9. struct ip_event {
  10. struct perf_event_header header;
  11. u64 ip;
  12. u32 pid, tid;
  13. unsigned char __more_data[];
  14. };
  15. struct mmap_event {
  16. struct perf_event_header header;
  17. u32 pid, tid;
  18. u64 start;
  19. u64 len;
  20. u64 pgoff;
  21. char filename[PATH_MAX];
  22. };
  23. struct comm_event {
  24. struct perf_event_header header;
  25. u32 pid, tid;
  26. char comm[16];
  27. };
  28. struct fork_event {
  29. struct perf_event_header header;
  30. u32 pid, ppid;
  31. u32 tid, ptid;
  32. u64 time;
  33. };
  34. struct lost_event {
  35. struct perf_event_header header;
  36. u64 id;
  37. u64 lost;
  38. };
  39. /*
  40. * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
  41. */
  42. struct read_event {
  43. struct perf_event_header header;
  44. u32 pid, tid;
  45. u64 value;
  46. u64 time_enabled;
  47. u64 time_running;
  48. u64 id;
  49. };
  50. struct sample_event {
  51. struct perf_event_header header;
  52. u64 array[];
  53. };
  54. struct sample_data {
  55. u64 ip;
  56. u32 pid, tid;
  57. u64 time;
  58. u64 addr;
  59. u64 id;
  60. u64 stream_id;
  61. u32 cpu;
  62. u64 period;
  63. struct ip_callchain *callchain;
  64. u32 raw_size;
  65. void *raw_data;
  66. };
  67. #define BUILD_ID_SIZE 20
  68. struct build_id_event {
  69. struct perf_event_header header;
  70. u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))];
  71. char filename[];
  72. };
  73. typedef union event_union {
  74. struct perf_event_header header;
  75. struct ip_event ip;
  76. struct mmap_event mmap;
  77. struct comm_event comm;
  78. struct fork_event fork;
  79. struct lost_event lost;
  80. struct read_event read;
  81. struct sample_event sample;
  82. } event_t;
  83. struct events_stats {
  84. u64 total;
  85. u64 lost;
  86. };
  87. struct event_stat_id {
  88. struct rb_node rb_node;
  89. struct rb_root hists;
  90. struct events_stats stats;
  91. u64 config;
  92. u64 event_stream;
  93. u32 type;
  94. };
  95. void event__print_totals(void);
  96. struct perf_session;
  97. typedef int (*event__handler_t)(event_t *event, struct perf_session *session);
  98. int event__synthesize_thread(pid_t pid, event__handler_t process,
  99. struct perf_session *session);
  100. void event__synthesize_threads(event__handler_t process,
  101. struct perf_session *session);
  102. int event__synthesize_kernel_mmap(event__handler_t process,
  103. struct perf_session *session,
  104. const char *symbol_name);
  105. int event__synthesize_modules(event__handler_t process,
  106. struct perf_session *session);
  107. int event__process_comm(event_t *self, struct perf_session *session);
  108. int event__process_lost(event_t *self, struct perf_session *session);
  109. int event__process_mmap(event_t *self, struct perf_session *session);
  110. int event__process_task(event_t *self, struct perf_session *session);
  111. struct addr_location;
  112. int event__preprocess_sample(const event_t *self, struct perf_session *session,
  113. struct addr_location *al, symbol_filter_t filter);
  114. int event__parse_sample(event_t *event, u64 type, struct sample_data *data);
  115. #endif /* __PERF_RECORD_H */