session.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. };
  47. struct perf_session *perf_session__new(const char *filename, int mode, bool force);
  48. void perf_session__delete(struct perf_session *self);
  49. void perf_event_header__bswap(struct perf_event_header *self);
  50. int __perf_session__process_events(struct perf_session *self,
  51. u64 data_offset, u64 data_size, u64 size,
  52. struct perf_event_ops *ops);
  53. int perf_session__process_events(struct perf_session *self,
  54. struct perf_event_ops *event_ops);
  55. struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
  56. struct thread *thread,
  57. struct ip_callchain *chain,
  58. struct symbol **parent);
  59. bool perf_session__has_traces(struct perf_session *self, const char *msg);
  60. int perf_header__read_build_ids(struct perf_header *self, int input,
  61. u64 offset, u64 file_size);
  62. int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
  63. const char *symbol_name,
  64. u64 addr);
  65. void mem_bswap_64(void *src, int byte_size);
  66. static inline int __perf_session__create_kernel_maps(struct perf_session *self,
  67. struct dso *kernel)
  68. {
  69. return __map_groups__create_kernel_maps(&self->kmaps,
  70. self->vmlinux_maps, kernel);
  71. }
  72. static inline int perf_session__create_kernel_maps(struct perf_session *self)
  73. {
  74. return map_groups__create_kernel_maps(&self->kmaps, self->vmlinux_maps);
  75. }
  76. static inline struct map *
  77. perf_session__new_module_map(struct perf_session *self,
  78. u64 start, const char *filename)
  79. {
  80. return map_groups__new_module(&self->kmaps, start, filename);
  81. }
  82. int do_read(int fd, void *buf, size_t size);
  83. void perf_session__update_sample_type(struct perf_session *self);
  84. #ifdef NO_NEWT_SUPPORT
  85. static inline int perf_session__browse_hists(struct rb_root *hists __used,
  86. u64 nr_hists __used,
  87. u64 session_total __used,
  88. const char *helpline __used,
  89. const char *input_name __used)
  90. {
  91. return 0;
  92. }
  93. #else
  94. int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
  95. u64 session_total, const char *helpline,
  96. const char *input_name);
  97. #endif
  98. #endif /* __PERF_SESSION_H */