blob: 0a88982bc39261d46a5326d883031a2e295e84b1 [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 {
13 HEADER_TRACE_INFO = 1,
14 HEADER_BUILD_ID,
Stephane Eranianfbe96f22011-09-30 15:40:40 +020015
16 HEADER_HOSTNAME,
17 HEADER_OSRELEASE,
18 HEADER_VERSION,
19 HEADER_ARCH,
20 HEADER_NRCPUS,
21 HEADER_CPUDESC,
22 HEADER_CPUID,
23 HEADER_TOTAL_MEM,
24 HEADER_CMDLINE,
25 HEADER_EVENT_DESC,
26 HEADER_CPU_TOPOLOGY,
27 HEADER_NUMA_TOPOLOGY,
28
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020029 HEADER_LAST_FEATURE,
30};
Frederic Weisbecker2ba08252009-10-17 17:12:34 +020031
32#define HEADER_FEAT_BITS 256
33
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020034struct perf_file_section {
35 u64 offset;
36 u64 size;
37};
38
39struct perf_file_header {
40 u64 magic;
41 u64 size;
42 u64 attr_size;
43 struct perf_file_section attrs;
44 struct perf_file_section data;
45 struct perf_file_section event_types;
46 DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
47};
48
Tom Zanussi8dc58102010-04-01 23:59:15 -050049struct perf_pipe_file_header {
50 u64 magic;
51 u64 size;
52};
53
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020054struct perf_header;
55
Arnaldo Carvalho de Melo1c0b04d2011-03-09 08:13:19 -030056int perf_file_header__read(struct perf_file_header *header,
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020057 struct perf_header *ph, int fd);
58
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +020059struct perf_header {
Frederic Weisbecker2ba08252009-10-17 17:12:34 +020060 int frozen;
Arnaldo Carvalho de Meloeed05fe2010-04-05 12:53:45 -030061 bool needs_swap;
Frederic Weisbecker2ba08252009-10-17 17:12:34 +020062 s64 attr_offset;
63 u64 data_offset;
64 u64 data_size;
65 u64 event_offset;
66 u64 event_size;
Frederic Weisbeckerdb9f11e2009-10-17 17:57:18 +020067 DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +020068};
69
Arnaldo Carvalho de Melo361c99a2011-01-11 20:56:53 -020070struct perf_evlist;
71
Arnaldo Carvalho de Meloa91e5432011-03-10 11:15:54 -030072int perf_session__read_header(struct perf_session *session, int fd);
73int perf_session__write_header(struct perf_session *session,
74 struct perf_evlist *evlist,
75 int fd, bool at_exit);
Tom Zanussi8dc58102010-04-01 23:59:15 -050076int perf_header__write_pipe(int fd);
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +020077
Arnaldo Carvalho de Meloae99fb22009-12-28 22:48:33 -020078int perf_header__push_event(u64 id, const char *name);
Arjan van de Ven8755a8f2009-09-12 07:52:51 +020079char *perf_header__find_event(u64 id);
80
Arnaldo Carvalho de Melo1c0b04d2011-03-09 08:13:19 -030081void perf_header__set_feat(struct perf_header *header, int feat);
82void perf_header__clear_feat(struct perf_header *header, int feat);
83bool perf_header__has_feat(const struct perf_header *header, int feat);
Peter Zijlstra7c6a1c62009-06-25 17:05:54 +020084
Stephane Eranianfbe96f22011-09-30 15:40:40 +020085int perf_header__set_cmdline(int argc, const char **argv);
86
Arnaldo Carvalho de Melo1c0b04d2011-03-09 08:13:19 -030087int perf_header__process_sections(struct perf_header *header, int fd,
Stephane Eranianfbe96f22011-09-30 15:40:40 +020088 void *data,
Arnaldo Carvalho de Melo1c0b04d2011-03-09 08:13:19 -030089 int (*process)(struct perf_file_section *section,
Stephane Eranianfbe96f22011-09-30 15:40:40 +020090 struct perf_header *ph,
91 int feat, int fd, void *data));
92
93int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full);
Arnaldo Carvalho de Melo37562ea2009-11-16 16:32:43 -020094
Arnaldo Carvalho de Meloef12a142010-01-20 15:28:45 -020095int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
96 const char *name, bool is_kallsyms);
97int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
98
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -020099int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
100 perf_event__handler_t process,
Tom Zanussi92155452010-04-01 23:59:21 -0500101 struct perf_session *session);
Arnaldo Carvalho de Meloa91e5432011-03-10 11:15:54 -0300102int perf_session__synthesize_attrs(struct perf_session *session,
103 perf_event__handler_t process);
Arnaldo Carvalho de Melo10d0f082011-11-11 22:45:41 -0200104int perf_event__process_attr(union perf_event *event, struct perf_evlist **pevlist);
Tom Zanussicd19a032010-04-01 23:59:20 -0500105
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200106int perf_event__synthesize_event_type(u64 event_id, char *name,
107 perf_event__handler_t process,
108 struct perf_session *session);
109int perf_event__synthesize_event_types(perf_event__handler_t process,
110 struct perf_session *session);
111int perf_event__process_event_type(union perf_event *event,
112 struct perf_session *session);
Tom Zanussic7929e42010-04-01 23:59:22 -0500113
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200114int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
115 perf_event__handler_t process,
116 struct perf_session *session);
117int perf_event__process_tracing_data(union perf_event *event,
118 struct perf_session *session);
119
120int perf_event__synthesize_build_id(struct dso *pos, u16 misc,
121 perf_event__handler_t process,
122 struct machine *machine,
123 struct perf_session *session);
124int perf_event__process_build_id(union perf_event *event,
125 struct perf_session *session);
Stephane Eranianfbe96f22011-09-30 15:40:40 +0200126
127/*
128 * arch specific callback
129 */
130int get_cpuid(char *buffer, size_t sz);
131
John Kacur8b40f522009-09-24 18:02:18 +0200132#endif /* __PERF_HEADER_H */