blob: 5867c7d74f9790708cff2de939b2e9243bbaefe5 [file] [log] [blame]
John Kacur8b40f522009-09-24 18:02:18 +02001#ifndef __PERF_HEADER_H
2#define __PERF_HEADER_H
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +02003
Ingo Molnarcdd6c482009-09-21 12:02:48 +02004#include "../../../include/linux/perf_event.h"
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +02005#include <sys/types.h>
Arnaldo Carvalho de Melo8d063672009-11-04 18:50:43 -02006#include <stdbool.h>
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +02007#include "types.h"
Arnaldo Carvalho de Meloef12a142010-01-20 15:28:45 -02008#include "event.h"
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +02009
Frederic Weisbeckerdb9f11e2009-10-17 17:57:18 +020010#include <linux/bitmap.h>
11
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020012enum {
Robert Richterb1e5a9b2011-12-07 10:02:57 +010013 HEADER_RESERVED = 0, /* always cleared */
Robert Richter781ba9d2011-12-15 17:32:40 +010014 HEADER_FIRST_FEATURE = 1,
Stephane Eranian2eeaaa02012-05-15 13:28:13 +020015 HEADER_TRACING_DATA = 1,
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020016 HEADER_BUILD_ID,
Stephane Eranianfbe96f22011-09-30 15:40:40 +020017
18 HEADER_HOSTNAME,
19 HEADER_OSRELEASE,
20 HEADER_VERSION,
21 HEADER_ARCH,
22 HEADER_NRCPUS,
23 HEADER_CPUDESC,
24 HEADER_CPUID,
25 HEADER_TOTAL_MEM,
26 HEADER_CMDLINE,
27 HEADER_EVENT_DESC,
28 HEADER_CPU_TOPOLOGY,
29 HEADER_NUMA_TOPOLOGY,
Stephane Eranian330aa672012-03-08 23:47:46 +010030 HEADER_BRANCH_STACK,
Robert Richter50a96672012-08-16 21:10:24 +020031 HEADER_PMU_MAPPINGS,
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020032 HEADER_LAST_FEATURE,
Robert Richterb1e5a9b2011-12-07 10:02:57 +010033 HEADER_FEAT_BITS = 256,
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020034};
Frederic Weisbecker2ba08252009-10-17 17:12:34 +020035
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020036struct perf_file_section {
37 u64 offset;
38 u64 size;
39};
40
41struct perf_file_header {
42 u64 magic;
43 u64 size;
44 u64 attr_size;
45 struct perf_file_section attrs;
46 struct perf_file_section data;
47 struct perf_file_section event_types;
48 DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
49};
50
Tom Zanussi8dc58102010-04-01 23:59:15 -050051struct perf_pipe_file_header {
52 u64 magic;
53 u64 size;
54};
55
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020056struct perf_header;
57
Arnaldo Carvalho de Melo1c0b04d2011-03-09 08:13:19 -030058int perf_file_header__read(struct perf_file_header *header,
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020059 struct perf_header *ph, int fd);
60
Namhyung Kime93699b2012-09-24 17:14:58 +090061struct perf_session_env {
62 char *hostname;
63 char *os_release;
64 char *version;
65 char *arch;
66 int nr_cpus_online;
67 int nr_cpus_avail;
68 char *cpu_desc;
69 char *cpuid;
70 unsigned long long total_mem;
71
72 int nr_cmdline;
73 char *cmdline;
74 int nr_sibling_cores;
75 char *sibling_cores;
76 int nr_sibling_threads;
77 char *sibling_threads;
78 int nr_numa_nodes;
79 char *numa_nodes;
80 int nr_pmu_mappings;
81 char *pmu_mappings;
82};
83
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +020084struct perf_header {
Frederic Weisbecker2ba08252009-10-17 17:12:34 +020085 int frozen;
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030086 bool needs_swap;
Frederic Weisbecker2ba08252009-10-17 17:12:34 +020087 s64 attr_offset;
88 u64 data_offset;
89 u64 data_size;
90 u64 event_offset;
91 u64 event_size;
Frederic Weisbeckerdb9f11e2009-10-17 17:57:18 +020092 DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
Namhyung Kime93699b2012-09-24 17:14:58 +090093 struct perf_session_env env;
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +020094};
95
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020096struct perf_evlist;
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -020097struct perf_session;
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020098
Arnaldo Carvalho de Meloa91e5432011-03-10 11:15:54 -030099int perf_session__read_header(struct perf_session *session, int fd);
100int perf_session__write_header(struct perf_session *session,
101 struct perf_evlist *evlist,
102 int fd, bool at_exit);
Tom Zanussi8dc58102010-04-01 23:59:15 -0500103int perf_header__write_pipe(int fd);
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +0200104
Arnaldo Carvalho de Meloae99fb22009-12-28 22:48:33 -0200105int perf_header__push_event(u64 id, const char *name);
Arjan van de Ven8755a8f2009-09-12 07:52:51 +0200106char *perf_header__find_event(u64 id);
107
Arnaldo Carvalho de Melo1c0b04d2011-03-09 08:13:19 -0300108void perf_header__set_feat(struct perf_header *header, int feat);
109void perf_header__clear_feat(struct perf_header *header, int feat);
110bool perf_header__has_feat(const struct perf_header *header, int feat);
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +0200111
Stephane Eranianfbe96f22011-09-30 15:40:40 +0200112int perf_header__set_cmdline(int argc, const char **argv);
113
Arnaldo Carvalho de Melo1c0b04d2011-03-09 08:13:19 -0300114int perf_header__process_sections(struct perf_header *header, int fd,
Stephane Eranianfbe96f22011-09-30 15:40:40 +0200115 void *data,
Arnaldo Carvalho de Melo1c0b04d2011-03-09 08:13:19 -0300116 int (*process)(struct perf_file_section *section,
Stephane Eranianfbe96f22011-09-30 15:40:40 +0200117 struct perf_header *ph,
118 int feat, int fd, void *data));
119
120int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full);
Xiao Guangrongbcf6edc2012-09-17 16:31:15 +0800121char *perf_header__read_feature(struct perf_session *session, int feat);
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -0200122
Arnaldo Carvalho de Meloef12a142010-01-20 15:28:45 -0200123int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
Jiri Olsa7dbf4dc2012-09-10 18:50:19 +0200124 const char *name, bool is_kallsyms, bool is_vdso);
Arnaldo Carvalho de Meloef12a142010-01-20 15:28:45 -0200125int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
126
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200127int perf_event__synthesize_attr(struct perf_tool *tool,
Robert Richterf4d83432012-08-16 21:10:17 +0200128 struct perf_event_attr *attr, u32 ids, u64 *id,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200129 perf_event__handler_t process);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200130int perf_event__synthesize_attrs(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200131 struct perf_session *session,
132 perf_event__handler_t process);
Arnaldo Carvalho de Melo10d0f082011-11-11 22:45:41 -0200133int perf_event__process_attr(union perf_event *event, struct perf_evlist **pevlist);
Tom Zanussicd19a032010-04-01 23:59:20 -0500134
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200135int perf_event__synthesize_event_type(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200136 u64 event_id, char *name,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200137 perf_event__handler_t process,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200138 struct machine *machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200139int perf_event__synthesize_event_types(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200140 perf_event__handler_t process,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200141 struct machine *machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200142int perf_event__process_event_type(struct perf_tool *tool,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200143 union perf_event *event);
Tom Zanussic7929e42010-04-01 23:59:22 -0500144
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200145int perf_event__synthesize_tracing_data(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200146 int fd, struct perf_evlist *evlist,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200147 perf_event__handler_t process);
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200148int perf_event__process_tracing_data(union perf_event *event,
149 struct perf_session *session);
150
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200151int perf_event__synthesize_build_id(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200152 struct dso *pos, u16 misc,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200153 perf_event__handler_t process,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200154 struct machine *machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200155int perf_event__process_build_id(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200156 union perf_event *event,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200157 struct perf_session *session);
Stephane Eranianfbe96f22011-09-30 15:40:40 +0200158
159/*
160 * arch specific callback
161 */
162int get_cpuid(char *buffer, size_t sz);
163
John Kacur8b40f522009-09-24 18:02:18 +0200164#endif /* __PERF_HEADER_H */