John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 1 | #ifndef __PERF_HEADER_H |
| 2 | #define __PERF_HEADER_H |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 3 | |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 4 | #include "../../../include/linux/perf_event.h" |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 5 | #include <sys/types.h> |
Arnaldo Carvalho de Melo | 8d06367 | 2009-11-04 18:50:43 -0200 | [diff] [blame] | 6 | #include <stdbool.h> |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 7 | #include "types.h" |
Arnaldo Carvalho de Melo | ef12a14 | 2010-01-20 15:28:45 -0200 | [diff] [blame] | 8 | #include "event.h" |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 9 | |
Frederic Weisbecker | db9f11e | 2009-10-17 17:57:18 +0200 | [diff] [blame] | 10 | #include <linux/bitmap.h> |
| 11 | |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 12 | enum { |
| 13 | HEADER_TRACE_INFO = 1, |
| 14 | HEADER_BUILD_ID, |
| 15 | HEADER_LAST_FEATURE, |
| 16 | }; |
Frederic Weisbecker | 2ba0825 | 2009-10-17 17:12:34 +0200 | [diff] [blame] | 17 | |
| 18 | #define HEADER_FEAT_BITS 256 |
| 19 | |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 20 | struct perf_file_section { |
| 21 | u64 offset; |
| 22 | u64 size; |
| 23 | }; |
| 24 | |
| 25 | struct perf_file_header { |
| 26 | u64 magic; |
| 27 | u64 size; |
| 28 | u64 attr_size; |
| 29 | struct perf_file_section attrs; |
| 30 | struct perf_file_section data; |
| 31 | struct perf_file_section event_types; |
| 32 | DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); |
| 33 | }; |
| 34 | |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 35 | struct perf_pipe_file_header { |
| 36 | u64 magic; |
| 37 | u64 size; |
| 38 | }; |
| 39 | |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 40 | struct perf_header; |
| 41 | |
Arnaldo Carvalho de Melo | 1c0b04d | 2011-03-09 08:13:19 -0300 | [diff] [blame] | 42 | int perf_file_header__read(struct perf_file_header *header, |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 43 | struct perf_header *ph, int fd); |
| 44 | |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 45 | struct perf_header { |
Frederic Weisbecker | 2ba0825 | 2009-10-17 17:12:34 +0200 | [diff] [blame] | 46 | int frozen; |
Arnaldo Carvalho de Melo | eed05fe | 2010-04-05 12:53:45 -0300 | [diff] [blame] | 47 | bool needs_swap; |
Frederic Weisbecker | 2ba0825 | 2009-10-17 17:12:34 +0200 | [diff] [blame] | 48 | s64 attr_offset; |
| 49 | u64 data_offset; |
| 50 | u64 data_size; |
| 51 | u64 event_offset; |
| 52 | u64 event_size; |
Frederic Weisbecker | db9f11e | 2009-10-17 17:57:18 +0200 | [diff] [blame] | 53 | DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 54 | }; |
| 55 | |
Arnaldo Carvalho de Melo | 361c99a | 2011-01-11 20:56:53 -0200 | [diff] [blame] | 56 | struct perf_evlist; |
| 57 | |
Arnaldo Carvalho de Melo | a91e543 | 2011-03-10 11:15:54 -0300 | [diff] [blame] | 58 | int perf_session__read_header(struct perf_session *session, int fd); |
| 59 | int perf_session__write_header(struct perf_session *session, |
| 60 | struct perf_evlist *evlist, |
| 61 | int fd, bool at_exit); |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 62 | int perf_header__write_pipe(int fd); |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 63 | |
Arnaldo Carvalho de Melo | ae99fb2 | 2009-12-28 22:48:33 -0200 | [diff] [blame] | 64 | int perf_header__push_event(u64 id, const char *name); |
Arjan van de Ven | 8755a8f | 2009-09-12 07:52:51 +0200 | [diff] [blame] | 65 | char *perf_header__find_event(u64 id); |
| 66 | |
Arnaldo Carvalho de Melo | 1c0b04d | 2011-03-09 08:13:19 -0300 | [diff] [blame] | 67 | void perf_header__set_feat(struct perf_header *header, int feat); |
| 68 | void perf_header__clear_feat(struct perf_header *header, int feat); |
| 69 | bool perf_header__has_feat(const struct perf_header *header, int feat); |
Peter Zijlstra | 7c6a1c6 | 2009-06-25 17:05:54 +0200 | [diff] [blame] | 70 | |
Arnaldo Carvalho de Melo | 1c0b04d | 2011-03-09 08:13:19 -0300 | [diff] [blame] | 71 | int perf_header__process_sections(struct perf_header *header, int fd, |
| 72 | int (*process)(struct perf_file_section *section, |
Arnaldo Carvalho de Melo | ba21594 | 2010-01-14 12:23:10 -0200 | [diff] [blame] | 73 | struct perf_header *ph, |
Arnaldo Carvalho de Melo | 37562ea | 2009-11-16 16:32:43 -0200 | [diff] [blame] | 74 | int feat, int fd)); |
| 75 | |
Arnaldo Carvalho de Melo | ef12a14 | 2010-01-20 15:28:45 -0200 | [diff] [blame] | 76 | int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, |
| 77 | const char *name, bool is_kallsyms); |
| 78 | int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir); |
| 79 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 80 | int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, |
| 81 | perf_event__handler_t process, |
Tom Zanussi | 9215545 | 2010-04-01 23:59:21 -0500 | [diff] [blame] | 82 | struct perf_session *session); |
Arnaldo Carvalho de Melo | a91e543 | 2011-03-10 11:15:54 -0300 | [diff] [blame] | 83 | int perf_session__synthesize_attrs(struct perf_session *session, |
| 84 | perf_event__handler_t process); |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 85 | int perf_event__process_attr(union perf_event *event, struct perf_session *session); |
Tom Zanussi | cd19a03 | 2010-04-01 23:59:20 -0500 | [diff] [blame] | 86 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 87 | int perf_event__synthesize_event_type(u64 event_id, char *name, |
| 88 | perf_event__handler_t process, |
| 89 | struct perf_session *session); |
| 90 | int perf_event__synthesize_event_types(perf_event__handler_t process, |
| 91 | struct perf_session *session); |
| 92 | int perf_event__process_event_type(union perf_event *event, |
| 93 | struct perf_session *session); |
Tom Zanussi | c7929e4 | 2010-04-01 23:59:22 -0500 | [diff] [blame] | 94 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 95 | int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, |
| 96 | perf_event__handler_t process, |
| 97 | struct perf_session *session); |
| 98 | int perf_event__process_tracing_data(union perf_event *event, |
| 99 | struct perf_session *session); |
| 100 | |
| 101 | int perf_event__synthesize_build_id(struct dso *pos, u16 misc, |
| 102 | perf_event__handler_t process, |
| 103 | struct machine *machine, |
| 104 | struct perf_session *session); |
| 105 | int perf_event__process_build_id(union perf_event *event, |
| 106 | struct perf_session *session); |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 107 | #endif /* __PERF_HEADER_H */ |