1#ifndef __PERF_HEADER_H
2#define __PERF_HEADER_H
3
4#include "../../../include/linux/perf_event.h"
5#include <sys/types.h>
6#include <stdbool.h>
7#include "types.h"
8#include "event.h"
9
10#include <linux/bitmap.h>
11
12enum {
13 HEADER_TRACE_INFO = 1,
14 HEADER_BUILD_ID,
15
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
29 HEADER_LAST_FEATURE,
30};
31
32#define HEADER_FEAT_BITS 256
33
34struct 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
49struct perf_pipe_file_header {
50 u64 magic;
51 u64 size;
52};
53
54struct perf_header;
55
56int perf_file_header__read(struct perf_file_header *header,
57 struct perf_header *ph, int fd);
58
59struct perf_header {
60 int frozen;
61 bool needs_swap;
62 s64 attr_offset;
63 u64 data_offset;
64 u64 data_size;
65 u64 event_offset;
66 u64 event_size;
67 DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
68};
69
70struct perf_evlist;
71
72int 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);
76int perf_header__write_pipe(int fd);
77
78int perf_header__push_event(u64 id, const char *name);
79char *perf_header__find_event(u64 id);
80
81void 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);
84
85int perf_header__set_cmdline(int argc, const char **argv);
86
87int perf_header__process_sections(struct perf_header *header, int fd,
88 void *data,
89 int (*process)(struct perf_file_section *section,
90 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);
94
95int 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
99int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
100 perf_event__handler_t process,
101 struct perf_session *session);
102int perf_session__synthesize_attrs(struct perf_session *session,
103 perf_event__handler_t process);
104int perf_event__process_attr(union perf_event *event, struct perf_session *session);
105
106int 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);
113
114int 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);
126
127
128
129
130int get_cpuid(char *buffer, size_t sz);
131
132#endif
133