event.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef __PERF_EVENT_H
  2. #define __PERF_EVENT_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. };
  38. struct lost_event {
  39. struct perf_event_header header;
  40. u64 id;
  41. u64 lost;
  42. };
  43. /*
  44. * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
  45. */
  46. struct read_event {
  47. struct perf_event_header header;
  48. u32 pid,tid;
  49. u64 value;
  50. u64 time_enabled;
  51. u64 time_running;
  52. u64 id;
  53. };
  54. typedef union event_union {
  55. struct perf_event_header header;
  56. struct ip_event ip;
  57. struct mmap_event mmap;
  58. struct comm_event comm;
  59. struct fork_event fork;
  60. struct lost_event lost;
  61. struct read_event read;
  62. } event_t;
  63. struct map {
  64. struct list_head node;
  65. u64 start;
  66. u64 end;
  67. u64 pgoff;
  68. u64 (*map_ip)(struct map *, u64);
  69. struct dso *dso;
  70. };
  71. static inline u64 map__map_ip(struct map *map, u64 ip)
  72. {
  73. return ip - map->start + map->pgoff;
  74. }
  75. static inline u64 vdso__map_ip(struct map *map __used, u64 ip)
  76. {
  77. return ip;
  78. }
  79. struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen);
  80. struct map *map__clone(struct map *self);
  81. int map__overlap(struct map *l, struct map *r);
  82. size_t map__fprintf(struct map *self, FILE *fp);
  83. #endif