session.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef __PERF_SESSION_H
  2. #define __PERF_SESSION_H
  3. #include "event.h"
  4. #include "header.h"
  5. #include "symbol.h"
  6. #include "thread.h"
  7. #include <linux/rbtree.h>
  8. #include "../../../include/linux/perf_event.h"
  9. struct ip_callchain;
  10. struct thread;
  11. struct perf_session {
  12. struct perf_header header;
  13. unsigned long size;
  14. unsigned long mmap_window;
  15. struct map_groups kmaps;
  16. struct rb_root threads;
  17. struct thread *last_match;
  18. struct map *vmlinux_maps[MAP__NR_TYPES];
  19. struct events_stats events_stats;
  20. struct rb_root stats_by_id;
  21. unsigned long event_total[PERF_RECORD_MAX];
  22. unsigned long unknown_events;
  23. struct rb_root hists;
  24. u64 sample_type;
  25. struct ref_reloc_sym ref_reloc_sym;
  26. int fd;
  27. int cwdlen;
  28. char *cwd;
  29. char filename[0];
  30. };
  31. typedef int (*event_op)(event_t *self, struct perf_session *session);
  32. struct perf_event_ops {
  33. event_op sample,
  34. mmap,
  35. comm,
  36. fork,
  37. exit,
  38. lost,
  39. read,
  40. throttle,
  41. unthrottle;
  42. };
  43. struct perf_session *perf_session__new(const char *filename, int mode, bool force);
  44. void perf_session__delete(struct perf_session *self);
  45. void perf_event_header__bswap(struct perf_event_header *self);
  46. int __perf_session__process_events(struct perf_session *self,
  47. u64 data_offset, u64 data_size, u64 size,
  48. struct perf_event_ops *ops);
  49. int perf_session__process_events(struct perf_session *self,
  50. struct perf_event_ops *event_ops);
  51. struct symbol **perf_session__resolve_callchain(struct perf_session *self,
  52. struct thread *thread,
  53. struct ip_callchain *chain,
  54. struct symbol **parent);
  55. bool perf_session__has_traces(struct perf_session *self, const char *msg);
  56. int perf_header__read_build_ids(struct perf_header *self, int input,
  57. u64 offset, u64 file_size);
  58. int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
  59. const char *symbol_name,
  60. u64 addr);
  61. void mem_bswap_64(void *src, int byte_size);
  62. static inline int __perf_session__create_kernel_maps(struct perf_session *self,
  63. struct dso *kernel)
  64. {
  65. return __map_groups__create_kernel_maps(&self->kmaps,
  66. self->vmlinux_maps, kernel);
  67. }
  68. static inline struct map *
  69. perf_session__new_module_map(struct perf_session *self,
  70. u64 start, const char *filename)
  71. {
  72. return map_groups__new_module(&self->kmaps, start, filename);
  73. }
  74. #endif /* __PERF_SESSION_H */