session.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. unsigned long event_total[PERF_RECORD_MAX];
  21. unsigned long unknown_events;
  22. struct rb_root hists;
  23. u64 sample_type;
  24. struct ref_reloc_sym ref_reloc_sym;
  25. int fd;
  26. int cwdlen;
  27. char *cwd;
  28. char filename[0];
  29. };
  30. typedef int (*event_op)(event_t *self, struct perf_session *session);
  31. struct perf_event_ops {
  32. event_op sample,
  33. mmap,
  34. comm,
  35. fork,
  36. exit,
  37. lost,
  38. read,
  39. throttle,
  40. unthrottle;
  41. };
  42. struct perf_session *perf_session__new(const char *filename, int mode, bool force);
  43. void perf_session__delete(struct perf_session *self);
  44. void perf_event_header__bswap(struct perf_event_header *self);
  45. int __perf_session__process_events(struct perf_session *self,
  46. u64 data_offset, u64 data_size, u64 size,
  47. struct perf_event_ops *ops);
  48. int perf_session__process_events(struct perf_session *self,
  49. struct perf_event_ops *event_ops);
  50. struct symbol **perf_session__resolve_callchain(struct perf_session *self,
  51. struct thread *thread,
  52. struct ip_callchain *chain,
  53. struct symbol **parent);
  54. bool perf_session__has_traces(struct perf_session *self, const char *msg);
  55. int perf_header__read_build_ids(struct perf_header *self, int input,
  56. u64 offset, u64 file_size);
  57. int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
  58. const char *symbol_name,
  59. u64 addr);
  60. void mem_bswap_64(void *src, int byte_size);
  61. static inline int __perf_session__create_kernel_maps(struct perf_session *self,
  62. struct dso *kernel)
  63. {
  64. return __map_groups__create_kernel_maps(&self->kmaps,
  65. self->vmlinux_maps, kernel);
  66. }
  67. static inline struct map *
  68. perf_session__new_module_map(struct perf_session *self,
  69. u64 start, const char *filename)
  70. {
  71. return map_groups__new_module(&self->kmaps, start, filename);
  72. }
  73. #endif /* __PERF_SESSION_H */