session.h 2.4 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 19
	struct rb_root		threads;
	struct thread		*last_match;
20
	struct rb_root		kerninfo_root;
21
	struct events_stats	events_stats;
22
	struct rb_root		stats_by_id;
23
	unsigned long		event_total[PERF_RECORD_MAX];
24
	unsigned long		unknown_events;
25
	struct rb_root		hists;
26
	u64			sample_type;
27
	int			fd;
28
	bool			fd_pipe;
29 30
	int			cwdlen;
	char			*cwd;
31 32 33
	char filename[0];
};

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

struct perf_event_ops {
37 38 39 40 41 42 43 44
	event_op sample,
		 mmap,
		 comm,
		 fork,
		 exit,
		 lost,
		 read,
		 throttle,
45
		 unthrottle,
46
		 attr,
47
		 event_type,
48 49
		 tracing_data,
		 build_id;
50 51
};

52
struct perf_session *perf_session__new(const char *filename, int mode, bool force);
53 54
void perf_session__delete(struct perf_session *self);

55 56
void perf_event_header__bswap(struct perf_event_header *self);

57 58 59
int __perf_session__process_events(struct perf_session *self,
				   u64 data_offset, u64 data_size, u64 size,
				   struct perf_event_ops *ops);
60
int perf_session__process_events(struct perf_session *self,
61
				 struct perf_event_ops *event_ops);
62

63 64 65 66
struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
						   struct thread *thread,
						   struct ip_callchain *chain,
						   struct symbol **parent);
67

68
bool perf_session__has_traces(struct perf_session *self, const char *msg);
69

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

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

76
int perf_session__create_kernel_maps(struct perf_session *self);
77

78 79 80
int do_read(int fd, void *buf, size_t size);
void perf_session__update_sample_type(struct perf_session *self);

81
#ifdef NO_NEWT_SUPPORT
82 83
static inline int perf_session__browse_hists(struct rb_root *hists __used,
					      u64 nr_hists __used,
84
					      u64 session_total __used,
85 86
					     const char *helpline __used,
					     const char *input_name __used)
87 88 89
{
	return 0;
}
90
#else
91
int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
92 93
			       u64 session_total, const char *helpline,
			       const char *input_name);
94
#endif
95
#endif /* __PERF_SESSION_H */