session.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. bool fd_pipe;
  28. int cwdlen;
  29. char *cwd;
  30. char filename[0];
  31. };
  32. typedef int (*event_op)(event_t *self, struct perf_session *session);
  33. struct perf_event_ops {
  34. event_op sample,
  35. mmap,
  36. comm,
  37. fork,
  38. exit,
  39. lost,
  40. read,
  41. throttle,
  42. unthrottle,
  43. attr,
  44. event_type,
  45. tracing_data,
  46. build_id;
  47. };
  48. struct perf_session *perf_session__new(const char *filename, int mode, bool force);
  49. void perf_session__delete(struct perf_session *self);
  50. void perf_event_header__bswap(struct perf_event_header *self);
  51. int __perf_session__process_events(struct perf_session *self,
  52. u64 data_offset, u64 data_size, u64 size,
  53. struct perf_event_ops *ops);
  54. int perf_session__process_events(struct perf_session *self,
  55. struct perf_event_ops *event_ops);
  56. struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
  57. struct thread *thread,
  58. struct ip_callchain *chain,
  59. struct symbol **parent);
  60. bool perf_session__has_traces(struct perf_session *self, const char *msg);
  61. int perf_header__read_build_ids(struct perf_header *self, int input,
  62. u64 offset, u64 file_size);
  63. int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
  64. const char *symbol_name,
  65. u64 addr);
  66. void mem_bswap_64(void *src, int byte_size);
  67. static inline int __perf_session__create_kernel_maps(struct perf_session *self,
  68. struct dso *kernel)
  69. {
  70. return __map_groups__create_kernel_maps(&self->kmaps,
  71. self->vmlinux_maps, kernel);
  72. }
  73. static inline int perf_session__create_kernel_maps(struct perf_session *self)
  74. {
  75. return map_groups__create_kernel_maps(&self->kmaps, self->vmlinux_maps);
  76. }
  77. static inline struct map *
  78. perf_session__new_module_map(struct perf_session *self,
  79. u64 start, const char *filename)
  80. {
  81. return map_groups__new_module(&self->kmaps, start, filename);
  82. }
  83. int do_read(int fd, void *buf, size_t size);
  84. void perf_session__update_sample_type(struct perf_session *self);
  85. #ifdef NO_NEWT_SUPPORT
  86. static inline int perf_session__browse_hists(struct rb_root *hists __used,
  87. u64 nr_hists __used,
  88. u64 session_total __used,
  89. const char *helpline __used,
  90. const char *input_name __used)
  91. {
  92. return 0;
  93. }
  94. #else
  95. int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
  96. u64 session_total, const char *helpline,
  97. const char *input_name);
  98. #endif
  99. #endif /* __PERF_SESSION_H */