blob: 5c33417eebb396599d77caa15798e5bce5293063 [file] [log] [blame]
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -02001#ifndef __PERF_SESSION_H
2#define __PERF_SESSION_H
3
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -02004#include "event.h"
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -02005#include "header.h"
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -02006#include "symbol.h"
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -02007#include "thread.h"
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -02008#include <linux/rbtree.h>
Arnaldo Carvalho de Melof823e442009-12-14 15:06:01 -02009#include "../../../include/linux/perf_event.h"
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020010
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -020011struct ip_callchain;
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020012struct thread;
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020013
14struct perf_session {
15 struct perf_header header;
16 unsigned long size;
Arnaldo Carvalho de Meloec913362009-12-13 19:50:27 -020017 unsigned long mmap_window;
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -020018 struct map_groups kmaps;
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020019 struct rb_root threads;
20 struct thread *last_match;
Arnaldo Carvalho de Melode176482010-01-04 16:19:29 -020021 struct map *vmlinux_maps[MAP__NR_TYPES];
Arnaldo Carvalho de Melof823e442009-12-14 15:06:01 -020022 struct events_stats events_stats;
Eric B Munsoncb8f0932010-03-05 12:51:07 -030023 struct rb_root stats_by_id;
Arnaldo Carvalho de Melof823e442009-12-14 15:06:01 -020024 unsigned long event_total[PERF_RECORD_MAX];
Arnaldo Carvalho de Melo31d337c2009-12-27 21:37:03 -020025 unsigned long unknown_events;
Arnaldo Carvalho de Melo4e4f06e2009-12-14 13:10:39 -020026 struct rb_root hists;
Arnaldo Carvalho de Meloc0198792009-12-14 14:23:00 -020027 u64 sample_type;
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -020028 struct ref_reloc_sym ref_reloc_sym;
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020029 int fd;
Arnaldo Carvalho de Meloec913362009-12-13 19:50:27 -020030 int cwdlen;
31 char *cwd;
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020032 char filename[0];
33};
34
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020035typedef int (*event_op)(event_t *self, struct perf_session *session);
36
37struct perf_event_ops {
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -020038 event_op sample,
39 mmap,
40 comm,
41 fork,
42 exit,
43 lost,
44 read,
45 throttle,
46 unthrottle;
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020047};
48
Arnaldo Carvalho de Melo75be6cf2009-12-15 20:04:39 -020049struct perf_session *perf_session__new(const char *filename, int mode, bool force);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020050void perf_session__delete(struct perf_session *self);
51
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -020052void perf_event_header__bswap(struct perf_event_header *self);
53
Arnaldo Carvalho de Melo6122e4e2010-02-03 16:52:05 -020054int __perf_session__process_events(struct perf_session *self,
55 u64 data_offset, u64 data_size, u64 size,
56 struct perf_event_ops *ops);
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020057int perf_session__process_events(struct perf_session *self,
Arnaldo Carvalho de Meloec913362009-12-13 19:50:27 -020058 struct perf_event_ops *event_ops);
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020059
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -020060struct symbol **perf_session__resolve_callchain(struct perf_session *self,
61 struct thread *thread,
62 struct ip_callchain *chain,
63 struct symbol **parent);
64
Arnaldo Carvalho de Melod549c7692009-12-27 21:37:02 -020065bool perf_session__has_traces(struct perf_session *self, const char *msg);
Arnaldo Carvalho de Melo27295592009-12-27 21:37:01 -020066
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -020067int perf_header__read_build_ids(struct perf_header *self, int input,
68 u64 offset, u64 file_size);
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020069
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -020070int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
71 const char *symbol_name,
72 u64 addr);
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -020073
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -020074void mem_bswap_64(void *src, int byte_size);
75
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -020076static inline int __perf_session__create_kernel_maps(struct perf_session *self,
77 struct dso *kernel)
78{
79 return __map_groups__create_kernel_maps(&self->kmaps,
80 self->vmlinux_maps, kernel);
81}
82
83static inline struct map *
84 perf_session__new_module_map(struct perf_session *self,
85 u64 start, const char *filename)
86{
87 return map_groups__new_module(&self->kmaps, start, filename);
88}
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020089#endif /* __PERF_SESSION_H */