session.h 2.6 KB
Newer Older
1 2 3
#ifndef __PERF_SESSION_H
#define __PERF_SESSION_H

4
#include "event.h"
5
#include "header.h"
6
#include "symbol.h"
7
#include "thread.h"
8
#include <linux/rbtree.h>
9
#include "../../../include/linux/perf_event.h"
10

11
struct ip_callchain;
12
struct thread;
13 14 15 16

struct perf_session {
	struct perf_header	header;
	unsigned long		size;
17
	unsigned long		mmap_window;
18
	struct map_groups	kmaps;
19 20
	struct rb_root		threads;
	struct thread		*last_match;
21
	struct map		*vmlinux_maps[MAP__NR_TYPES];
22
	struct events_stats	events_stats;
23
	struct rb_root		stats_by_id;
24
	unsigned long		event_total[PERF_RECORD_MAX];
25
	unsigned long		unknown_events;
26
	struct rb_root		hists;
27
	u64			sample_type;
28
	struct ref_reloc_sym	ref_reloc_sym;
29
	int			fd;
30 31
	int			cwdlen;
	char			*cwd;
32 33 34
	char filename[0];
};

35 36 37
typedef int (*event_op)(event_t *self, struct perf_session *session);

struct perf_event_ops {
38 39 40 41 42 43 44 45 46
	event_op sample,
		 mmap,
		 comm,
		 fork,
		 exit,
		 lost,
		 read,
		 throttle,
		 unthrottle;
47 48
};

49
struct perf_session *perf_session__new(const char *filename, int mode, bool force);
50 51
void perf_session__delete(struct perf_session *self);

52 53
void perf_event_header__bswap(struct perf_event_header *self);

54 55 56
int __perf_session__process_events(struct perf_session *self,
				   u64 data_offset, u64 data_size, u64 size,
				   struct perf_event_ops *ops);
57
int perf_session__process_events(struct perf_session *self,
58
				 struct perf_event_ops *event_ops);
59

60 61 62 63
struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
						   struct thread *thread,
						   struct ip_callchain *chain,
						   struct symbol **parent);
64

65
bool perf_session__has_traces(struct perf_session *self, const char *msg);
66

67 68
int perf_header__read_build_ids(struct perf_header *self, int input,
				u64 offset, u64 file_size);
69

70 71 72 73
int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
					     const char *symbol_name,
					     u64 addr);

74 75
void mem_bswap_64(void *src, int byte_size);

76 77 78 79 80 81 82 83 84 85 86 87 88
static inline int __perf_session__create_kernel_maps(struct perf_session *self,
						struct dso *kernel)
{
	return __map_groups__create_kernel_maps(&self->kmaps,
						self->vmlinux_maps, kernel);
}

static inline struct map *
	perf_session__new_module_map(struct perf_session *self,
				     u64 start, const char *filename)
{
	return map_groups__new_module(&self->kmaps, start, filename);
}
89 90

#ifdef NO_NEWT_SUPPORT
91 92
static inline int perf_session__browse_hists(struct rb_root *hists __used,
					      u64 nr_hists __used,
93
					      u64 session_total __used,
94 95 96 97
					      const char *helpline __used)
{
	return 0;
}
98
#else
99 100
int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
				u64 session_total, const char *helpline);
101
#endif
102
#endif /* __PERF_SESSION_H */