session.h 3.9 KB

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