blob: 0739ebbbf9fdc1e1aa20af303e01078eedaa2fc9 [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;
Tom Zanussi8dc58102010-04-01 23:59:15 -050030 bool fd_pipe;
Arnaldo Carvalho de Meloec913362009-12-13 19:50:27 -020031 int cwdlen;
32 char *cwd;
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020033 char filename[0];
34};
35
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020036typedef int (*event_op)(event_t *self, struct perf_session *session);
37
38struct perf_event_ops {
Arnaldo Carvalho de Melo55aa6402009-12-27 21:37:05 -020039 event_op sample,
40 mmap,
41 comm,
42 fork,
43 exit,
44 lost,
45 read,
46 throttle,
Tom Zanussi2c46dbb2010-04-01 23:59:19 -050047 unthrottle,
Tom Zanussicd19a032010-04-01 23:59:20 -050048 attr,
Tom Zanussi92155452010-04-01 23:59:21 -050049 event_type,
50 tracing_data;
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020051};
52
Arnaldo Carvalho de Melo75be6cf2009-12-15 20:04:39 -020053struct perf_session *perf_session__new(const char *filename, int mode, bool force);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020054void perf_session__delete(struct perf_session *self);
55
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -020056void perf_event_header__bswap(struct perf_event_header *self);
57
Arnaldo Carvalho de Melo6122e4e2010-02-03 16:52:05 -020058int __perf_session__process_events(struct perf_session *self,
59 u64 data_offset, u64 data_size, u64 size,
60 struct perf_event_ops *ops);
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020061int perf_session__process_events(struct perf_session *self,
Arnaldo Carvalho de Meloec913362009-12-13 19:50:27 -020062 struct perf_event_ops *event_ops);
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020063
Arnaldo Carvalho de Melob3c9ac02010-03-24 16:40:18 -030064struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
65 struct thread *thread,
66 struct ip_callchain *chain,
67 struct symbol **parent);
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -020068
Arnaldo Carvalho de Melod549c7692009-12-27 21:37:02 -020069bool perf_session__has_traces(struct perf_session *self, const char *msg);
Arnaldo Carvalho de Melo27295592009-12-27 21:37:01 -020070
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -020071int perf_header__read_build_ids(struct perf_header *self, int input,
72 u64 offset, u64 file_size);
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020073
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -020074int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
75 const char *symbol_name,
76 u64 addr);
Arnaldo Carvalho de Melo56b03f32010-01-05 16:50:31 -020077
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -020078void mem_bswap_64(void *src, int byte_size);
79
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -020080static inline int __perf_session__create_kernel_maps(struct perf_session *self,
81 struct dso *kernel)
82{
83 return __map_groups__create_kernel_maps(&self->kmaps,
84 self->vmlinux_maps, kernel);
85}
86
Arnaldo Carvalho de Meloe727ca72010-04-01 19:12:13 -030087static inline int perf_session__create_kernel_maps(struct perf_session *self)
88{
89 return map_groups__create_kernel_maps(&self->kmaps, self->vmlinux_maps);
90}
91
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -020092static inline struct map *
93 perf_session__new_module_map(struct perf_session *self,
94 u64 start, const char *filename)
95{
96 return map_groups__new_module(&self->kmaps, start, filename);
97}
Arnaldo Carvalho de Melof9224c52010-03-11 20:12:44 -030098
Tom Zanussi8dc58102010-04-01 23:59:15 -050099int do_read(int fd, void *buf, size_t size);
100void perf_session__update_sample_type(struct perf_session *self);
101
Arnaldo Carvalho de Melof9224c52010-03-11 20:12:44 -0300102#ifdef NO_NEWT_SUPPORT
Arnaldo Carvalho de Melo5f4d3f82010-03-26 21:16:22 -0300103static inline int perf_session__browse_hists(struct rb_root *hists __used,
104 u64 nr_hists __used,
Arnaldo Carvalho de Melof9224c52010-03-11 20:12:44 -0300105 u64 session_total __used,
Arnaldo Carvalho de Melo533c46c2010-04-03 11:54:35 -0300106 const char *helpline __used,
107 const char *input_name __used)
Arnaldo Carvalho de Melo5f4d3f82010-03-26 21:16:22 -0300108{
109 return 0;
110}
Arnaldo Carvalho de Melof9224c52010-03-11 20:12:44 -0300111#else
Arnaldo Carvalho de Melo5f4d3f82010-03-26 21:16:22 -0300112int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
Arnaldo Carvalho de Melo533c46c2010-04-03 11:54:35 -0300113 u64 session_total, const char *helpline,
114 const char *input_name);
Arnaldo Carvalho de Melof9224c52010-03-11 20:12:44 -0300115#endif
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200116#endif /* __PERF_SESSION_H */