Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 1 | #ifndef __PERF_SESSION_H |
| 2 | #define __PERF_SESSION_H |
| 3 | |
Jiri Olsa | 29f5ffd | 2013-12-03 14:09:23 +0100 | [diff] [blame] | 4 | #include "trace-event.h" |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 5 | #include "event.h" |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 6 | #include "header.h" |
Arnaldo Carvalho de Melo | 69d2591 | 2012-11-09 11:32:52 -0300 | [diff] [blame] | 7 | #include "machine.h" |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 8 | #include "symbol.h" |
Arnaldo Carvalho de Melo | 4aa6563 | 2009-12-13 19:50:29 -0200 | [diff] [blame] | 9 | #include "thread.h" |
Jiri Olsa | f5fc141 | 2013-10-15 16:27:32 +0200 | [diff] [blame] | 10 | #include "data.h" |
Jiri Olsa | 5f86b80 | 2014-08-01 13:02:58 -0300 | [diff] [blame] | 11 | #include "ordered-events.h" |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 12 | #include <linux/rbtree.h> |
David Howells | d2709c7 | 2012-11-19 22:21:03 +0000 | [diff] [blame] | 13 | #include <linux/perf_event.h> |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 14 | |
Arnaldo Carvalho de Melo | a328626 | 2009-12-14 14:22:59 -0200 | [diff] [blame] | 15 | struct ip_callchain; |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 16 | struct thread; |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 17 | |
| 18 | struct perf_session { |
| 19 | struct perf_header header; |
Arnaldo Carvalho de Melo | 876650e | 2012-12-18 19:15:48 -0300 | [diff] [blame] | 20 | struct machines machines; |
Arnaldo Carvalho de Melo | e248de3 | 2011-03-05 21:40:06 -0300 | [diff] [blame] | 21 | struct perf_evlist *evlist; |
Jiri Olsa | 29f5ffd | 2013-12-03 14:09:23 +0100 | [diff] [blame] | 22 | struct trace_event tevent; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 23 | bool repipe; |
Adrian Hunter | 919d86d | 2014-07-14 13:02:51 +0300 | [diff] [blame] | 24 | bool one_mmap; |
| 25 | void *one_mmap_addr; |
| 26 | u64 one_mmap_offset; |
Jiri Olsa | 37e39aa | 2014-07-06 14:23:03 +0200 | [diff] [blame] | 27 | struct ordered_events ordered_events; |
Jiri Olsa | cc9784bd | 2013-10-15 16:27:34 +0200 | [diff] [blame] | 28 | struct perf_data_file *file; |
Arnaldo Carvalho de Melo | 9870d78 | 2015-03-31 12:48:16 -0300 | [diff] [blame] | 29 | struct perf_tool *tool; |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 30 | }; |
| 31 | |
David Ahern | a6ffaf9 | 2013-08-07 22:50:51 -0400 | [diff] [blame] | 32 | #define PRINT_IP_OPT_IP (1<<0) |
| 33 | #define PRINT_IP_OPT_SYM (1<<1) |
| 34 | #define PRINT_IP_OPT_DSO (1<<2) |
| 35 | #define PRINT_IP_OPT_SYMOFFSET (1<<3) |
David Ahern | b0b35f0 | 2013-08-07 22:50:52 -0400 | [diff] [blame] | 36 | #define PRINT_IP_OPT_ONELINE (1<<4) |
Adrian Hunter | cc8fae1 | 2013-12-06 09:42:57 +0200 | [diff] [blame] | 37 | #define PRINT_IP_OPT_SRCLINE (1<<5) |
David Ahern | a6ffaf9 | 2013-08-07 22:50:51 -0400 | [diff] [blame] | 38 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 39 | struct perf_tool; |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 40 | |
Jiri Olsa | f5fc141 | 2013-10-15 16:27:32 +0200 | [diff] [blame] | 41 | struct perf_session *perf_session__new(struct perf_data_file *file, |
| 42 | bool repipe, struct perf_tool *tool); |
Arnaldo Carvalho de Melo | 876650e | 2012-12-18 19:15:48 -0300 | [diff] [blame] | 43 | void perf_session__delete(struct perf_session *session); |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 44 | |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 45 | void perf_event_header__bswap(struct perf_event_header *hdr); |
Arnaldo Carvalho de Melo | ba21594 | 2010-01-14 12:23:10 -0200 | [diff] [blame] | 46 | |
Adrian Hunter | 5a52f33 | 2014-07-31 09:00:57 +0300 | [diff] [blame] | 47 | int perf_session__peek_event(struct perf_session *session, off_t file_offset, |
| 48 | void *buf, size_t buf_sz, |
| 49 | union perf_event **event_ptr, |
| 50 | struct perf_sample *sample); |
| 51 | |
Arnaldo Carvalho de Melo | b7b61cb | 2015-03-03 11:58:45 -0300 | [diff] [blame] | 52 | int perf_session__process_events(struct perf_session *session); |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 53 | |
Arnaldo Carvalho de Melo | b7b61cb | 2015-03-03 11:58:45 -0300 | [diff] [blame] | 54 | int perf_session__queue_event(struct perf_session *s, union perf_event *event, |
| 55 | struct perf_sample *sample, u64 file_offset); |
David Ahern | 9c50140 | 2013-08-02 14:05:41 -0600 | [diff] [blame] | 56 | |
| 57 | void perf_tool__fill_defaults(struct perf_tool *tool); |
| 58 | |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 59 | int perf_session__resolve_callchain(struct perf_session *session, |
| 60 | struct perf_evsel *evsel, |
Frederic Weisbecker | 1b3a0e9 | 2011-01-14 04:51:58 +0100 | [diff] [blame] | 61 | struct thread *thread, |
| 62 | struct ip_callchain *chain, |
| 63 | struct symbol **parent); |
Arnaldo Carvalho de Melo | a328626 | 2009-12-14 14:22:59 -0200 | [diff] [blame] | 64 | |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 65 | bool perf_session__has_traces(struct perf_session *session, const char *msg); |
Arnaldo Carvalho de Melo | 2729559 | 2009-12-27 21:37:01 -0200 | [diff] [blame] | 66 | |
David Ahern | eda3913 | 2011-07-15 12:34:09 -0600 | [diff] [blame] | 67 | void perf_event__attr_swap(struct perf_event_attr *attr); |
Arnaldo Carvalho de Melo | ba21594 | 2010-01-14 12:23:10 -0200 | [diff] [blame] | 68 | |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 69 | int perf_session__create_kernel_maps(struct perf_session *session); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 70 | |
Arnaldo Carvalho de Melo | 7b56cce | 2012-08-01 19:31:00 -0300 | [diff] [blame] | 71 | void perf_session__set_id_hdr_size(struct perf_session *session); |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 72 | |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 73 | static inline |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 74 | struct machine *perf_session__find_machine(struct perf_session *session, pid_t pid) |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 75 | { |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 76 | return machines__find(&session->machines, pid); |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | static inline |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 80 | struct machine *perf_session__findnew_machine(struct perf_session *session, pid_t pid) |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 81 | { |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 82 | return machines__findnew(&session->machines, pid); |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 83 | } |
| 84 | |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 85 | struct thread *perf_session__findnew(struct perf_session *session, pid_t pid); |
| 86 | size_t perf_session__fprintf(struct perf_session *session, FILE *fp); |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 87 | |
Arnaldo Carvalho de Melo | 316c713 | 2013-11-05 15:32:36 -0300 | [diff] [blame] | 88 | size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp); |
Arnaldo Carvalho de Melo | cbf6968 | 2010-04-27 21:22:44 -0300 | [diff] [blame] | 89 | |
Arnaldo Carvalho de Melo | 417c2ff | 2012-12-07 09:53:58 -0300 | [diff] [blame] | 90 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp, |
| 91 | bool (fn)(struct dso *dso, int parm), int parm); |
Arnaldo Carvalho de Melo | c8446b9 | 2010-05-14 10:36:42 -0300 | [diff] [blame] | 92 | |
Arnaldo Carvalho de Melo | e248de3 | 2011-03-05 21:40:06 -0300 | [diff] [blame] | 93 | size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp); |
Arnaldo Carvalho de Melo | d0dd74e | 2011-01-21 13:46:41 -0200 | [diff] [blame] | 94 | |
David Ahern | 9cbdb70 | 2011-04-06 21:54:20 -0600 | [diff] [blame] | 95 | struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, |
| 96 | unsigned int type); |
| 97 | |
Adrian Hunter | a2cb3cf | 2013-12-04 16:16:36 +0200 | [diff] [blame] | 98 | void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, |
Arnaldo Carvalho de Melo | cc22e57 | 2013-12-19 17:20:06 -0300 | [diff] [blame] | 99 | struct addr_location *al, |
David Ahern | 307cbb9 | 2013-08-07 22:50:53 -0400 | [diff] [blame] | 100 | unsigned int print_opts, unsigned int stack_depth); |
David Ahern | c0230b2 | 2011-03-09 22:23:27 -0700 | [diff] [blame] | 101 | |
Anton Blanchard | 5d67be9 | 2011-07-04 21:57:50 +1000 | [diff] [blame] | 102 | int perf_session__cpu_bitmap(struct perf_session *session, |
| 103 | const char *cpu_list, unsigned long *cpu_bitmap); |
| 104 | |
Stephane Eranian | fbe96f2 | 2011-09-30 15:40:40 +0200 | [diff] [blame] | 105 | void perf_session__fprintf_info(struct perf_session *s, FILE *fp, bool full); |
Arnaldo Carvalho de Melo | da37896 | 2012-06-27 13:08:42 -0300 | [diff] [blame] | 106 | |
| 107 | struct perf_evsel_str_handler; |
| 108 | |
| 109 | int __perf_session__set_tracepoints_handlers(struct perf_session *session, |
| 110 | const struct perf_evsel_str_handler *assocs, |
| 111 | size_t nr_assocs); |
| 112 | |
| 113 | #define perf_session__set_tracepoints_handlers(session, array) \ |
| 114 | __perf_session__set_tracepoints_handlers(session, array, ARRAY_SIZE(array)) |
Arnaldo Carvalho de Melo | 33e940a | 2013-09-17 16:34:28 -0300 | [diff] [blame] | 115 | |
| 116 | extern volatile int session_done; |
| 117 | |
Pranith Kumar | 1da34da | 2014-09-23 10:55:08 -0400 | [diff] [blame] | 118 | #define session_done() ACCESS_ONCE(session_done) |
Adrian Hunter | 3c659ee | 2014-10-27 15:49:22 +0200 | [diff] [blame] | 119 | |
Adrian Hunter | a293829 | 2014-10-27 15:49:23 +0200 | [diff] [blame] | 120 | int perf_session__deliver_synth_event(struct perf_session *session, |
| 121 | union perf_event *event, |
Arnaldo Carvalho de Melo | b7b61cb | 2015-03-03 11:58:45 -0300 | [diff] [blame] | 122 | struct perf_sample *sample); |
Adrian Hunter | a293829 | 2014-10-27 15:49:23 +0200 | [diff] [blame] | 123 | |
Adrian Hunter | 3c659ee | 2014-10-27 15:49:22 +0200 | [diff] [blame] | 124 | int perf_event__process_id_index(struct perf_tool *tool, |
| 125 | union perf_event *event, |
| 126 | struct perf_session *session); |
| 127 | |
| 128 | int perf_event__synthesize_id_index(struct perf_tool *tool, |
| 129 | perf_event__handler_t process, |
| 130 | struct perf_evlist *evlist, |
| 131 | struct machine *machine); |
| 132 | |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 133 | #endif /* __PERF_SESSION_H */ |