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 | |
Arnaldo Carvalho de Melo | a328626 | 2009-12-14 14:22:59 -0200 | [diff] [blame] | 11 | struct ip_callchain; |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 12 | struct thread; |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 13 | |
| 14 | struct perf_session { |
| 15 | struct perf_header header; |
| 16 | unsigned long size; |
Arnaldo Carvalho de Melo | ec91336 | 2009-12-13 19:50:27 -0200 | [diff] [blame] | 17 | unsigned long mmap_window; |
Arnaldo Carvalho de Melo | 4aa6563 | 2009-12-13 19:50:29 -0200 | [diff] [blame] | 18 | struct map_groups kmaps; |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 19 | struct rb_root threads; |
| 20 | struct thread *last_match; |
Arnaldo Carvalho de Melo | de17648 | 2010-01-04 16:19:29 -0200 | [diff] [blame] | 21 | struct map *vmlinux_maps[MAP__NR_TYPES]; |
Arnaldo Carvalho de Melo | f823e44 | 2009-12-14 15:06:01 -0200 | [diff] [blame] | 22 | struct events_stats events_stats; |
Eric B Munson | cb8f093 | 2010-03-05 12:51:07 -0300 | [diff] [blame] | 23 | struct rb_root stats_by_id; |
Arnaldo Carvalho de Melo | f823e44 | 2009-12-14 15:06:01 -0200 | [diff] [blame] | 24 | unsigned long event_total[PERF_RECORD_MAX]; |
Arnaldo Carvalho de Melo | 31d337c | 2009-12-27 21:37:03 -0200 | [diff] [blame] | 25 | unsigned long unknown_events; |
Arnaldo Carvalho de Melo | 4e4f06e | 2009-12-14 13:10:39 -0200 | [diff] [blame] | 26 | struct rb_root hists; |
Arnaldo Carvalho de Melo | c019879 | 2009-12-14 14:23:00 -0200 | [diff] [blame] | 27 | u64 sample_type; |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 28 | struct ref_reloc_sym ref_reloc_sym; |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 29 | int fd; |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 30 | bool fd_pipe; |
Arnaldo Carvalho de Melo | ec91336 | 2009-12-13 19:50:27 -0200 | [diff] [blame] | 31 | int cwdlen; |
| 32 | char *cwd; |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 33 | char filename[0]; |
| 34 | }; |
| 35 | |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 36 | typedef int (*event_op)(event_t *self, struct perf_session *session); |
| 37 | |
| 38 | struct perf_event_ops { |
Arnaldo Carvalho de Melo | 55aa640 | 2009-12-27 21:37:05 -0200 | [diff] [blame] | 39 | event_op sample, |
| 40 | mmap, |
| 41 | comm, |
| 42 | fork, |
| 43 | exit, |
| 44 | lost, |
| 45 | read, |
| 46 | throttle, |
Tom Zanussi | 2c46dbb | 2010-04-01 23:59:19 -0500 | [diff] [blame] | 47 | unthrottle, |
Tom Zanussi | cd19a03 | 2010-04-01 23:59:20 -0500 | [diff] [blame] | 48 | attr, |
Tom Zanussi | 9215545 | 2010-04-01 23:59:21 -0500 | [diff] [blame^] | 49 | event_type, |
| 50 | tracing_data; |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 51 | }; |
| 52 | |
Arnaldo Carvalho de Melo | 75be6cf | 2009-12-15 20:04:39 -0200 | [diff] [blame] | 53 | struct perf_session *perf_session__new(const char *filename, int mode, bool force); |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 54 | void perf_session__delete(struct perf_session *self); |
| 55 | |
Arnaldo Carvalho de Melo | ba21594 | 2010-01-14 12:23:10 -0200 | [diff] [blame] | 56 | void perf_event_header__bswap(struct perf_event_header *self); |
| 57 | |
Arnaldo Carvalho de Melo | 6122e4e | 2010-02-03 16:52:05 -0200 | [diff] [blame] | 58 | int __perf_session__process_events(struct perf_session *self, |
| 59 | u64 data_offset, u64 data_size, u64 size, |
| 60 | struct perf_event_ops *ops); |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 61 | int perf_session__process_events(struct perf_session *self, |
Arnaldo Carvalho de Melo | ec91336 | 2009-12-13 19:50:27 -0200 | [diff] [blame] | 62 | struct perf_event_ops *event_ops); |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 63 | |
Arnaldo Carvalho de Melo | b3c9ac0 | 2010-03-24 16:40:18 -0300 | [diff] [blame] | 64 | struct map_symbol *perf_session__resolve_callchain(struct perf_session *self, |
| 65 | struct thread *thread, |
| 66 | struct ip_callchain *chain, |
| 67 | struct symbol **parent); |
Arnaldo Carvalho de Melo | a328626 | 2009-12-14 14:22:59 -0200 | [diff] [blame] | 68 | |
Arnaldo Carvalho de Melo | d549c769 | 2009-12-27 21:37:02 -0200 | [diff] [blame] | 69 | 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] | 70 | |
Arnaldo Carvalho de Melo | ba21594 | 2010-01-14 12:23:10 -0200 | [diff] [blame] | 71 | int perf_header__read_build_ids(struct perf_header *self, int input, |
| 72 | u64 offset, u64 file_size); |
Arnaldo Carvalho de Melo | 301a0b0 | 2009-12-13 19:50:25 -0200 | [diff] [blame] | 73 | |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 74 | int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self, |
| 75 | const char *symbol_name, |
| 76 | u64 addr); |
Arnaldo Carvalho de Melo | 56b03f3 | 2010-01-05 16:50:31 -0200 | [diff] [blame] | 77 | |
Arnaldo Carvalho de Melo | ba21594 | 2010-01-14 12:23:10 -0200 | [diff] [blame] | 78 | void mem_bswap_64(void *src, int byte_size); |
| 79 | |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 80 | static inline int __perf_session__create_kernel_maps(struct perf_session *self, |
| 81 | struct dso *kernel) |
| 82 | { |
| 83 | return __map_groups__create_kernel_maps(&self->kmaps, |
| 84 | self->vmlinux_maps, kernel); |
| 85 | } |
| 86 | |
Arnaldo Carvalho de Melo | e727ca7 | 2010-04-01 19:12:13 -0300 | [diff] [blame] | 87 | static inline int perf_session__create_kernel_maps(struct perf_session *self) |
| 88 | { |
| 89 | return map_groups__create_kernel_maps(&self->kmaps, self->vmlinux_maps); |
| 90 | } |
| 91 | |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 92 | static inline struct map * |
| 93 | perf_session__new_module_map(struct perf_session *self, |
| 94 | u64 start, const char *filename) |
| 95 | { |
| 96 | return map_groups__new_module(&self->kmaps, start, filename); |
| 97 | } |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 98 | |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 99 | int do_read(int fd, void *buf, size_t size); |
| 100 | void perf_session__update_sample_type(struct perf_session *self); |
| 101 | |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 102 | #ifdef NO_NEWT_SUPPORT |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 103 | static inline int perf_session__browse_hists(struct rb_root *hists __used, |
| 104 | u64 nr_hists __used, |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 105 | u64 session_total __used, |
Arnaldo Carvalho de Melo | 533c46c | 2010-04-03 11:54:35 -0300 | [diff] [blame] | 106 | const char *helpline __used, |
| 107 | const char *input_name __used) |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 108 | { |
| 109 | return 0; |
| 110 | } |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 111 | #else |
Arnaldo Carvalho de Melo | 5f4d3f8 | 2010-03-26 21:16:22 -0300 | [diff] [blame] | 112 | 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] | 113 | u64 session_total, const char *helpline, |
| 114 | const char *input_name); |
Arnaldo Carvalho de Melo | f9224c5 | 2010-03-11 20:12:44 -0300 | [diff] [blame] | 115 | #endif |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 116 | #endif /* __PERF_SESSION_H */ |