event.h 1.6 KB

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