session.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 rb_root threads;
  16. struct thread *last_match;
  17. struct rb_root kerninfo_root;
  18. struct events_stats events_stats;
  19. struct rb_root stats_by_id;
  20. unsigned long event_total[PERF_RECORD_MAX];
  21. unsigned long unknown_events;
  22. struct rb_root hists;
  23. u64 sample_type;
  24. int fd;
  25. bool fd_pipe;
  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. attr,
  42. event_type,
  43. tracing_data,
  44. build_id;
  45. };
  46. struct perf_session *perf_session__new(const char *filename, int mode, bool force);
  47. void perf_session__delete(struct perf_session *self);
  48. void perf_event_header__bswap(struct perf_event_header *self);
  49. int __perf_session__process_events(struct perf_session *self,
  50. u64 data_offset, u64 data_size, u64 size,
  51. struct perf_event_ops *ops);
  52. int perf_session__process_events(struct perf_session *self,
  53. struct perf_event_ops *event_ops);
  54. struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
  55. struct thread *thread,
  56. struct ip_callchain *chain,
  57. struct symbol **parent);
  58. bool perf_session__has_traces(struct perf_session *self, const char *msg);
  59. int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps,
  60. const char *symbol_name,
  61. u64 addr);
  62. void mem_bswap_64(void *src, int byte_size);
  63. int perf_session__create_kernel_maps(struct perf_session *self);
  64. int do_read(int fd, void *buf, size_t size);
  65. void perf_session__update_sample_type(struct perf_session *self);
  66. #ifdef NO_NEWT_SUPPORT
  67. static inline int perf_session__browse_hists(struct rb_root *hists __used,
  68. u64 nr_hists __used,
  69. u64 session_total __used,
  70. const char *helpline __used,
  71. const char *input_name __used)
  72. {
  73. return 0;
  74. }
  75. #else
  76. int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
  77. u64 session_total, const char *helpline,
  78. const char *input_name);
  79. #endif
  80. #endif /* __PERF_SESSION_H */