event.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef __PERF_RECORD_H
  2. #define __PERF_RECORD_H
  3. #include "../perf.h"
  4. #include "util.h"
  5. #include <linux/list.h>
  6. #include <linux/rbtree.h>
  7. enum {
  8. SHOW_KERNEL = 1,
  9. SHOW_USER = 2,
  10. SHOW_HV = 4,
  11. };
  12. /*
  13. * PERF_SAMPLE_IP | PERF_SAMPLE_TID | *
  14. */
  15. struct ip_event {
  16. struct perf_event_header header;
  17. u64 ip;
  18. u32 pid, tid;
  19. unsigned char __more_data[];
  20. };
  21. struct mmap_event {
  22. struct perf_event_header header;
  23. u32 pid, tid;
  24. u64 start;
  25. u64 len;
  26. u64 pgoff;
  27. char filename[PATH_MAX];
  28. };
  29. struct comm_event {
  30. struct perf_event_header header;
  31. u32 pid, tid;
  32. char comm[16];
  33. };
  34. struct fork_event {
  35. struct perf_event_header header;
  36. u32 pid, ppid;
  37. u32 tid, ptid;
  38. u64 time;
  39. };
  40. struct lost_event {
  41. struct perf_event_header header;
  42. u64 id;
  43. u64 lost;
  44. };
  45. /*
  46. * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
  47. */
  48. struct read_event {
  49. struct perf_event_header header;
  50. u32 pid, tid;
  51. u64 value;
  52. u64 time_enabled;
  53. u64 time_running;
  54. u64 id;
  55. };
  56. struct sample_event{
  57. struct perf_event_header header;
  58. u64 array[];
  59. };
  60. typedef union event_union {
  61. struct perf_event_header header;
  62. struct ip_event ip;
  63. struct mmap_event mmap;
  64. struct comm_event comm;
  65. struct fork_event fork;
  66. struct lost_event lost;
  67. struct read_event read;
  68. struct sample_event sample;
  69. } event_t;
  70. struct map {
  71. union {
  72. struct rb_node rb_node;
  73. struct list_head node;
  74. };
  75. u64 start;
  76. u64 end;
  77. u64 pgoff;
  78. u64 (*map_ip)(struct map *, u64);
  79. struct dso *dso;
  80. };
  81. static inline u64 map__map_ip(struct map *map, u64 ip)
  82. {
  83. return ip - map->start + map->pgoff;
  84. }
  85. static inline u64 vdso__map_ip(struct map *map __used, u64 ip)
  86. {
  87. return ip;
  88. }
  89. struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen);
  90. struct map *map__clone(struct map *self);
  91. int map__overlap(struct map *l, struct map *r);
  92. size_t map__fprintf(struct map *self, FILE *fp);
  93. #endif /* __PERF_RECORD_H */