session.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #ifndef __PERF_SESSION_H
  2. #define __PERF_SESSION_H
  3. #include "trace-event.h"
  4. #include "event.h"
  5. #include "header.h"
  6. #include "machine.h"
  7. #include "symbol.h"
  8. #include "thread.h"
  9. #include "data.h"
  10. #include "ordered-events.h"
  11. #include <linux/rbtree.h>
  12. #include <linux/perf_event.h>
  13. struct ip_callchain;
  14. struct thread;
  15. struct auxtrace;
  16. struct itrace_synth_opts;
  17. struct perf_session {
  18. struct perf_header header;
  19. struct machines machines;
  20. struct perf_evlist *evlist;
  21. struct auxtrace *auxtrace;
  22. struct itrace_synth_opts *itrace_synth_opts;
  23. struct list_head auxtrace_index;
  24. struct trace_event tevent;
  25. struct time_conv_event time_conv;
  26. bool repipe;
  27. bool one_mmap;
  28. void *one_mmap_addr;
  29. u64 one_mmap_offset;
  30. struct ordered_events ordered_events;
  31. struct perf_data_file *file;
  32. struct perf_tool *tool;
  33. };
  34. struct perf_tool;
  35. struct perf_session *perf_session__new(struct perf_data_file *file,
  36. bool repipe, struct perf_tool *tool);
  37. void perf_session__delete(struct perf_session *session);
  38. void perf_event_header__bswap(struct perf_event_header *hdr);
  39. int perf_session__peek_event(struct perf_session *session, off_t file_offset,
  40. void *buf, size_t buf_sz,
  41. union perf_event **event_ptr,
  42. struct perf_sample *sample);
  43. int perf_session__process_events(struct perf_session *session);
  44. int perf_session__queue_event(struct perf_session *s, union perf_event *event,
  45. struct perf_sample *sample, u64 file_offset);
  46. void perf_tool__fill_defaults(struct perf_tool *tool);
  47. int perf_session__resolve_callchain(struct perf_session *session,
  48. struct perf_evsel *evsel,
  49. struct thread *thread,
  50. struct ip_callchain *chain,
  51. struct symbol **parent);
  52. bool perf_session__has_traces(struct perf_session *session, const char *msg);
  53. void perf_event__attr_swap(struct perf_event_attr *attr);
  54. int perf_session__create_kernel_maps(struct perf_session *session);
  55. void perf_session__set_id_hdr_size(struct perf_session *session);
  56. static inline
  57. struct machine *perf_session__find_machine(struct perf_session *session, pid_t pid)
  58. {
  59. return machines__find(&session->machines, pid);
  60. }
  61. static inline
  62. struct machine *perf_session__findnew_machine(struct perf_session *session, pid_t pid)
  63. {
  64. return machines__findnew(&session->machines, pid);
  65. }
  66. struct thread *perf_session__findnew(struct perf_session *session, pid_t pid);
  67. int perf_session__register_idle_thread(struct perf_session *session);
  68. size_t perf_session__fprintf(struct perf_session *session, FILE *fp);
  69. size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp);
  70. size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp,
  71. bool (fn)(struct dso *dso, int parm), int parm);
  72. size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp);
  73. struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
  74. unsigned int type);
  75. int perf_session__cpu_bitmap(struct perf_session *session,
  76. const char *cpu_list, unsigned long *cpu_bitmap);
  77. void perf_session__fprintf_info(struct perf_session *s, FILE *fp, bool full);
  78. struct perf_evsel_str_handler;
  79. int __perf_session__set_tracepoints_handlers(struct perf_session *session,
  80. const struct perf_evsel_str_handler *assocs,
  81. size_t nr_assocs);
  82. #define perf_session__set_tracepoints_handlers(session, array) \
  83. __perf_session__set_tracepoints_handlers(session, array, ARRAY_SIZE(array))
  84. extern volatile int session_done;
  85. #define session_done() ACCESS_ONCE(session_done)
  86. int perf_session__deliver_synth_event(struct perf_session *session,
  87. union perf_event *event,
  88. struct perf_sample *sample);
  89. int perf_event__process_id_index(struct perf_tool *tool,
  90. union perf_event *event,
  91. struct perf_session *session);
  92. int perf_event__synthesize_id_index(struct perf_tool *tool,
  93. perf_event__handler_t process,
  94. struct perf_evlist *evlist,
  95. struct machine *machine);
  96. #endif /* __PERF_SESSION_H */