event.h 1.8 KB

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