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 | |
Arnaldo Carvalho de Melo | 1c02c4d | 2010-05-10 13:04:11 -0300 | [diff] [blame] | 4 | #include "hist.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" |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 10 | #include <linux/rbtree.h> |
David Howells | d2709c7 | 2012-11-19 22:21:03 +0000 | [diff] [blame] | 11 | #include <linux/perf_event.h> |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 12 | |
Frederic Weisbecker | c61e52e | 2010-04-24 00:04:12 +0200 | [diff] [blame] | 13 | struct sample_queue; |
Arnaldo Carvalho de Melo | a328626 | 2009-12-14 14:22:59 -0200 | [diff] [blame] | 14 | struct ip_callchain; |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 15 | struct thread; |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 16 | |
Frederic Weisbecker | c61e52e | 2010-04-24 00:04:12 +0200 | [diff] [blame] | 17 | struct ordered_samples { |
| 18 | u64 last_flush; |
Frederic Weisbecker | d6b17be | 2010-05-03 15:14:33 +0200 | [diff] [blame] | 19 | u64 next_flush; |
| 20 | u64 max_timestamp; |
Thomas Gleixner | a1225de | 2010-11-30 17:49:33 +0000 | [diff] [blame] | 21 | struct list_head samples; |
Thomas Gleixner | 020bb75 | 2010-11-30 17:49:53 +0000 | [diff] [blame] | 22 | struct list_head sample_cache; |
Thomas Gleixner | 5c891f3 | 2010-11-30 17:49:55 +0000 | [diff] [blame] | 23 | struct list_head to_free; |
| 24 | struct sample_queue *sample_buffer; |
Thomas Gleixner | a1225de | 2010-11-30 17:49:33 +0000 | [diff] [blame] | 25 | struct sample_queue *last_sample; |
Thomas Gleixner | 5c891f3 | 2010-11-30 17:49:55 +0000 | [diff] [blame] | 26 | int sample_buffer_idx; |
Arnaldo Carvalho de Melo | 8866056 | 2011-10-29 12:41:45 -0200 | [diff] [blame] | 27 | unsigned int nr_samples; |
Frederic Weisbecker | c61e52e | 2010-04-24 00:04:12 +0200 | [diff] [blame] | 28 | }; |
| 29 | |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 30 | struct perf_session { |
| 31 | struct perf_header header; |
| 32 | unsigned long size; |
Arnaldo Carvalho de Melo | 876650e | 2012-12-18 19:15:48 -0300 | [diff] [blame] | 33 | struct machines machines; |
Arnaldo Carvalho de Melo | e248de3 | 2011-03-05 21:40:06 -0300 | [diff] [blame] | 34 | struct perf_evlist *evlist; |
Arnaldo Carvalho de Melo | da37896 | 2012-06-27 13:08:42 -0300 | [diff] [blame] | 35 | struct pevent *pevent; |
Arnaldo Carvalho de Melo | 28a6b6a | 2012-12-18 16:24:46 -0300 | [diff] [blame] | 36 | struct events_stats stats; |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 37 | int fd; |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 38 | bool fd_pipe; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 39 | bool repipe; |
Frederic Weisbecker | c61e52e | 2010-04-24 00:04:12 +0200 | [diff] [blame] | 40 | struct ordered_samples ordered_samples; |
Robert Richter | 002c4fd | 2011-12-07 10:02:52 +0100 | [diff] [blame] | 41 | char filename[1]; |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 42 | }; |
| 43 | |
David Ahern | a6ffaf9 | 2013-08-07 22:50:51 -0400 | [diff] [blame] | 44 | #define PRINT_IP_OPT_IP (1<<0) |
| 45 | #define PRINT_IP_OPT_SYM (1<<1) |
| 46 | #define PRINT_IP_OPT_DSO (1<<2) |
| 47 | #define PRINT_IP_OPT_SYMOFFSET (1<<3) |
David Ahern | b0b35f0 | 2013-08-07 22:50:52 -0400 | [diff] [blame^] | 48 | #define PRINT_IP_OPT_ONELINE (1<<4) |
David Ahern | a6ffaf9 | 2013-08-07 22:50:51 -0400 | [diff] [blame] | 49 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 50 | struct perf_tool; |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 51 | |
Ian Munsie | 21ef97f | 2010-12-10 14:09:16 +1100 | [diff] [blame] | 52 | struct perf_session *perf_session__new(const char *filename, int mode, |
| 53 | bool force, bool repipe, |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 54 | struct perf_tool *tool); |
Arnaldo Carvalho de Melo | 876650e | 2012-12-18 19:15:48 -0300 | [diff] [blame] | 55 | void perf_session__delete(struct perf_session *session); |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 56 | |
Arnaldo Carvalho de Melo | ba21594 | 2010-01-14 12:23:10 -0200 | [diff] [blame] | 57 | void perf_event_header__bswap(struct perf_event_header *self); |
| 58 | |
Arnaldo Carvalho de Melo | 6122e4e | 2010-02-03 16:52:05 -0200 | [diff] [blame] | 59 | int __perf_session__process_events(struct perf_session *self, |
| 60 | u64 data_offset, u64 data_size, u64 size, |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 61 | struct perf_tool *tool); |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 62 | int perf_session__process_events(struct perf_session *self, |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 63 | struct perf_tool *tool); |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 64 | |
David Ahern | e30b88a | 2013-08-05 21:41:33 -0400 | [diff] [blame] | 65 | int perf_session_queue_event(struct perf_session *s, union perf_event *event, |
| 66 | struct perf_sample *sample, u64 file_offset); |
David Ahern | 9c50140 | 2013-08-02 14:05:41 -0600 | [diff] [blame] | 67 | |
| 68 | void perf_tool__fill_defaults(struct perf_tool *tool); |
| 69 | |
Arnaldo Carvalho de Melo | 246d4ce | 2011-11-11 23:10:26 -0200 | [diff] [blame] | 70 | int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel, |
Frederic Weisbecker | 1b3a0e9 | 2011-01-14 04:51:58 +0100 | [diff] [blame] | 71 | struct thread *thread, |
| 72 | struct ip_callchain *chain, |
| 73 | struct symbol **parent); |
Arnaldo Carvalho de Melo | a328626 | 2009-12-14 14:22:59 -0200 | [diff] [blame] | 74 | |
Arnaldo Carvalho de Melo | d549c769 | 2009-12-27 21:37:02 -0200 | [diff] [blame] | 75 | bool perf_session__has_traces(struct perf_session *self, const char *msg); |
Arnaldo Carvalho de Melo | 2729559 | 2009-12-27 21:37:01 -0200 | [diff] [blame] | 76 | |
Arnaldo Carvalho de Melo | ba21594 | 2010-01-14 12:23:10 -0200 | [diff] [blame] | 77 | void mem_bswap_64(void *src, int byte_size); |
David Ahern | 80c0120 | 2012-06-08 11:47:51 -0300 | [diff] [blame] | 78 | void mem_bswap_32(void *src, int byte_size); |
David Ahern | eda3913 | 2011-07-15 12:34:09 -0600 | [diff] [blame] | 79 | void perf_event__attr_swap(struct perf_event_attr *attr); |
Arnaldo Carvalho de Melo | ba21594 | 2010-01-14 12:23:10 -0200 | [diff] [blame] | 80 | |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 81 | int perf_session__create_kernel_maps(struct perf_session *self); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 82 | |
Arnaldo Carvalho de Melo | 7b56cce | 2012-08-01 19:31:00 -0300 | [diff] [blame] | 83 | void perf_session__set_id_hdr_size(struct perf_session *session); |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 84 | |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 85 | static inline |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 86 | struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid) |
| 87 | { |
| 88 | return machines__find(&self->machines, pid); |
| 89 | } |
| 90 | |
| 91 | static inline |
| 92 | struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid) |
| 93 | { |
| 94 | return machines__findnew(&self->machines, pid); |
| 95 | } |
| 96 | |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 97 | struct thread *perf_session__findnew(struct perf_session *self, pid_t pid); |
| 98 | size_t perf_session__fprintf(struct perf_session *self, FILE *fp); |
| 99 | |
Arnaldo Carvalho de Melo | 1f626bc | 2010-05-09 19:57:08 -0300 | [diff] [blame] | 100 | size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp); |
Arnaldo Carvalho de Melo | cbf6968 | 2010-04-27 21:22:44 -0300 | [diff] [blame] | 101 | |
Arnaldo Carvalho de Melo | 417c2ff | 2012-12-07 09:53:58 -0300 | [diff] [blame] | 102 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp, |
| 103 | bool (fn)(struct dso *dso, int parm), int parm); |
Arnaldo Carvalho de Melo | c8446b9 | 2010-05-14 10:36:42 -0300 | [diff] [blame] | 104 | |
Arnaldo Carvalho de Melo | e248de3 | 2011-03-05 21:40:06 -0300 | [diff] [blame] | 105 | 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] | 106 | |
David Ahern | 9cbdb70 | 2011-04-06 21:54:20 -0600 | [diff] [blame] | 107 | struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, |
| 108 | unsigned int type); |
| 109 | |
Jiri Olsa | 71ad0f5 | 2012-08-07 15:20:46 +0200 | [diff] [blame] | 110 | void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, |
| 111 | struct perf_sample *sample, struct machine *machine, |
David Ahern | a6ffaf9 | 2013-08-07 22:50:51 -0400 | [diff] [blame] | 112 | unsigned int print_opts); |
David Ahern | c0230b2 | 2011-03-09 22:23:27 -0700 | [diff] [blame] | 113 | |
Anton Blanchard | 5d67be9 | 2011-07-04 21:57:50 +1000 | [diff] [blame] | 114 | int perf_session__cpu_bitmap(struct perf_session *session, |
| 115 | const char *cpu_list, unsigned long *cpu_bitmap); |
| 116 | |
Stephane Eranian | fbe96f2 | 2011-09-30 15:40:40 +0200 | [diff] [blame] | 117 | 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] | 118 | |
| 119 | struct perf_evsel_str_handler; |
| 120 | |
| 121 | int __perf_session__set_tracepoints_handlers(struct perf_session *session, |
| 122 | const struct perf_evsel_str_handler *assocs, |
| 123 | size_t nr_assocs); |
| 124 | |
| 125 | #define perf_session__set_tracepoints_handlers(session, array) \ |
| 126 | __perf_session__set_tracepoints_handlers(session, array, ARRAY_SIZE(array)) |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 127 | #endif /* __PERF_SESSION_H */ |