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 | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 4 | #include "event.h" |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 5 | #include "header.h" |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 6 | #include "symbol.h" |
Arnaldo Carvalho de Melo | 4aa6563 | 2009-12-13 19:50:29 -0200 | [diff] [blame] | 7 | #include "thread.h" |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 8 | #include <linux/rbtree.h> |
Arnaldo Carvalho de Melo | f823e44 | 2009-12-14 15:06:01 -0200 | [diff] [blame] | 9 | #include "../../../include/linux/perf_event.h" |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 10 | |
Frederic Weisbecker | c61e52e | 2010-04-24 00:04:12 +0200 | [diff] [blame] | 11 | struct sample_queue; |
Arnaldo Carvalho de Melo | a328626 | 2009-12-14 14:22:59 -0200 | [diff] [blame] | 12 | struct ip_callchain; |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 13 | struct thread; |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 14 | |
Frederic Weisbecker | c61e52e | 2010-04-24 00:04:12 +0200 | [diff] [blame] | 15 | struct ordered_samples { |
| 16 | u64 last_flush; |
Frederic Weisbecker | d6b17be | 2010-05-03 15:14:33 +0200 | [diff] [blame^] | 17 | u64 next_flush; |
| 18 | u64 max_timestamp; |
Frederic Weisbecker | c61e52e | 2010-04-24 00:04:12 +0200 | [diff] [blame] | 19 | struct list_head samples_head; |
| 20 | struct sample_queue *last_inserted; |
| 21 | }; |
| 22 | |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 23 | struct perf_session { |
| 24 | struct perf_header header; |
| 25 | unsigned long size; |
Arnaldo Carvalho de Melo | ec91336 | 2009-12-13 19:50:27 -0200 | [diff] [blame] | 26 | unsigned long mmap_window; |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 27 | struct rb_root threads; |
| 28 | struct thread *last_match; |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 29 | struct rb_root machines; |
Arnaldo Carvalho de Melo | f823e44 | 2009-12-14 15:06:01 -0200 | [diff] [blame] | 30 | struct events_stats events_stats; |
Eric B Munson | cb8f093 | 2010-03-05 12:51:07 -0300 | [diff] [blame] | 31 | struct rb_root stats_by_id; |
Arnaldo Carvalho de Melo | f823e44 | 2009-12-14 15:06:01 -0200 | [diff] [blame] | 32 | unsigned long event_total[PERF_RECORD_MAX]; |
Arnaldo Carvalho de Melo | 31d337c | 2009-12-27 21:37:03 -0200 | [diff] [blame] | 33 | unsigned long unknown_events; |
Arnaldo Carvalho de Melo | 4e4f06e | 2009-12-14 13:10:39 -0200 | [diff] [blame] | 34 | struct rb_root hists; |
Arnaldo Carvalho de Melo | c019879 | 2009-12-14 14:23:00 -0200 | [diff] [blame] | 35 | u64 sample_type; |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 36 | int fd; |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 37 | bool fd_pipe; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 38 | bool repipe; |
Arnaldo Carvalho de Melo | ec91336 | 2009-12-13 19:50:27 -0200 | [diff] [blame] | 39 | int cwdlen; |
| 40 | char *cwd; |
Frederic Weisbecker | c61e52e | 2010-04-24 00:04:12 +0200 | [diff] [blame] | 41 | struct ordered_samples ordered_samples; |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 42 | char filename[0]; |
| 43 | }; |
| 44 | |
Frederic Weisbecker | d6b17be | 2010-05-03 15:14:33 +0200 | [diff] [blame^] | 45 | struct perf_event_ops; |
| 46 | |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 47 | typedef int (*event_op)(event_t *self, struct perf_session *session); |
Frederic Weisbecker | d6b17be | 2010-05-03 15:14:33 +0200 | [diff] [blame^] | 48 | typedef int (*event_op2)(event_t *self, struct perf_session *session, |
| 49 | struct perf_event_ops *ops); |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 50 | |
| 51 | struct perf_event_ops { |
Frederic Weisbecker | d6b17be | 2010-05-03 15:14:33 +0200 | [diff] [blame^] | 52 | event_op sample, |
| 53 | mmap, |
| 54 | comm, |
| 55 | fork, |
| 56 | exit, |
| 57 | lost, |
| 58 | read, |
| 59 | throttle, |
| 60 | unthrottle, |
| 61 | attr, |
| 62 | event_type, |
| 63 | tracing_data, |
| 64 | build_id; |
| 65 | event_op2 finished_round; |
| 66 | bool ordered_samples; |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 67 | }; |
| 68 | |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 69 | struct perf_session *perf_session__new(const char *filename, int mode, bool force, bool repipe); |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 70 | void perf_session__delete(struct perf_session *self); |
| 71 | |
Arnaldo Carvalho de Melo | ba21594 | 2010-01-14 12:23:10 -0200 | [diff] [blame] | 72 | void perf_event_header__bswap(struct perf_event_header *self); |
| 73 | |
Arnaldo Carvalho de Melo | 6122e4e | 2010-02-03 16:52:05 -0200 | [diff] [blame] | 74 | int __perf_session__process_events(struct perf_session *self, |
| 75 | u64 data_offset, u64 data_size, u64 size, |
| 76 | struct perf_event_ops *ops); |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 77 | int perf_session__process_events(struct perf_session *self, |
Arnaldo Carvalho de Melo | ec91336 | 2009-12-13 19:50:27 -0200 | [diff] [blame] | 78 | struct perf_event_ops *event_ops); |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 79 | |
Arnaldo Carvalho de Melo | b3c9ac0 | 2010-03-24 16:40:18 -0300 | [diff] [blame] | 80 | struct map_symbol *perf_session__resolve_callchain(struct perf_session *self, |
| 81 | struct thread *thread, |
| 82 | struct ip_callchain *chain, |
| 83 | struct symbol **parent); |
Arnaldo Carvalho de Melo | a328626 | 2009-12-14 14:22:59 -0200 | [diff] [blame] | 84 | |
Arnaldo Carvalho de Melo | d549c769 | 2009-12-27 21:37:02 -0200 | [diff] [blame] | 85 | 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] | 86 | |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 87 | int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps, |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 88 | const char *symbol_name, |
| 89 | u64 addr); |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 90 | |
Arnaldo Carvalho de Melo | ba21594 | 2010-01-14 12:23:10 -0200 | [diff] [blame] | 91 | void mem_bswap_64(void *src, int byte_size); |
| 92 | |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 93 | int perf_session__create_kernel_maps(struct perf_session *self); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 94 | |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 95 | int do_read(int fd, void *buf, size_t size); |
| 96 | void perf_session__update_sample_type(struct perf_session *self); |
| 97 | |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 98 | #ifdef NO_NEWT_SUPPORT |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 99 | static inline int perf_session__browse_hists(struct rb_root *hists __used, |
| 100 | u64 nr_hists __used, |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 101 | u64 session_total __used, |
Arnaldo Carvalho de Melo | 533c46c | 2010-04-03 11:54:35 -0300 | [diff] [blame] | 102 | const char *helpline __used, |
| 103 | const char *input_name __used) |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 104 | { |
| 105 | return 0; |
| 106 | } |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 107 | #else |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 108 | int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, |
Arnaldo Carvalho de Melo | 533c46c | 2010-04-03 11:54:35 -0300 | [diff] [blame] | 109 | u64 session_total, const char *helpline, |
| 110 | const char *input_name); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 111 | #endif |
Arnaldo Carvalho de Melo | 23346f2 | 2010-04-27 21:17:50 -0300 | [diff] [blame] | 112 | |
| 113 | static inline |
| 114 | struct machine *perf_session__find_host_machine(struct perf_session *self) |
| 115 | { |
| 116 | return machines__find_host(&self->machines); |
| 117 | } |
| 118 | |
| 119 | static inline |
| 120 | struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid) |
| 121 | { |
| 122 | return machines__find(&self->machines, pid); |
| 123 | } |
| 124 | |
| 125 | static inline |
| 126 | struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid) |
| 127 | { |
| 128 | return machines__findnew(&self->machines, pid); |
| 129 | } |
| 130 | |
| 131 | static inline |
| 132 | void perf_session__process_machines(struct perf_session *self, |
| 133 | machine__process_t process) |
| 134 | { |
| 135 | return machines__process(&self->machines, process, self); |
| 136 | } |
Arnaldo Carvalho de Melo | cbf6968 | 2010-04-27 21:22:44 -0300 | [diff] [blame] | 137 | |
| 138 | static inline |
| 139 | size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp) |
| 140 | { |
| 141 | return machines__fprintf_dsos(&self->machines, fp); |
| 142 | } |
| 143 | |
| 144 | static inline |
| 145 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp, |
| 146 | bool with_hits) |
| 147 | { |
| 148 | return machines__fprintf_dsos_buildid(&self->machines, fp, with_hits); |
| 149 | } |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 150 | #endif /* __PERF_SESSION_H */ |