blob: d5fa7b7916ef40dd5216e533a5ce04bfdfc8a7d2 [file] [log] [blame]
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -02001#ifndef __PERF_SESSION_H
2#define __PERF_SESSION_H
3
Jiri Olsa29f5ffd2013-12-03 14:09:23 +01004#include "trace-event.h"
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -02005#include "event.h"
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -02006#include "header.h"
Arnaldo Carvalho de Melo69d25912012-11-09 11:32:52 -03007#include "machine.h"
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -02008#include "symbol.h"
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -02009#include "thread.h"
Jiri Olsaf5fc1412013-10-15 16:27:32 +020010#include "data.h"
Jiri Olsa5f86b802014-08-01 13:02:58 -030011#include "ordered-events.h"
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020012#include <linux/rbtree.h>
David Howellsd2709c72012-11-19 22:21:03 +000013#include <linux/perf_event.h>
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020014
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -020015struct ip_callchain;
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020016struct thread;
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020017
18struct perf_session {
19 struct perf_header header;
Arnaldo Carvalho de Melo876650e2012-12-18 19:15:48 -030020 struct machines machines;
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -030021 struct perf_evlist *evlist;
Jiri Olsa29f5ffd2013-12-03 14:09:23 +010022 struct trace_event tevent;
Tom Zanussi454c4072010-05-01 01:41:20 -050023 bool repipe;
Adrian Hunter919d86d2014-07-14 13:02:51 +030024 bool one_mmap;
25 void *one_mmap_addr;
26 u64 one_mmap_offset;
Jiri Olsa37e39aa2014-07-06 14:23:03 +020027 struct ordered_events ordered_events;
Jiri Olsacc9784bd2013-10-15 16:27:34 +020028 struct perf_data_file *file;
Arnaldo Carvalho de Melo9870d782015-03-31 12:48:16 -030029 struct perf_tool *tool;
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020030};
31
David Aherna6ffaf92013-08-07 22:50:51 -040032#define PRINT_IP_OPT_IP (1<<0)
33#define PRINT_IP_OPT_SYM (1<<1)
34#define PRINT_IP_OPT_DSO (1<<2)
35#define PRINT_IP_OPT_SYMOFFSET (1<<3)
David Ahernb0b35f02013-08-07 22:50:52 -040036#define PRINT_IP_OPT_ONELINE (1<<4)
Adrian Huntercc8fae12013-12-06 09:42:57 +020037#define PRINT_IP_OPT_SRCLINE (1<<5)
David Aherna6ffaf92013-08-07 22:50:51 -040038
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -020039struct perf_tool;
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020040
Jiri Olsaf5fc1412013-10-15 16:27:32 +020041struct perf_session *perf_session__new(struct perf_data_file *file,
42 bool repipe, struct perf_tool *tool);
Arnaldo Carvalho de Melo876650e2012-12-18 19:15:48 -030043void perf_session__delete(struct perf_session *session);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020044
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030045void perf_event_header__bswap(struct perf_event_header *hdr);
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -020046
Adrian Hunter5a52f332014-07-31 09:00:57 +030047int perf_session__peek_event(struct perf_session *session, off_t file_offset,
48 void *buf, size_t buf_sz,
49 union perf_event **event_ptr,
50 struct perf_sample *sample);
51
Arnaldo Carvalho de Melob7b61cb2015-03-03 11:58:45 -030052int perf_session__process_events(struct perf_session *session);
Arnaldo Carvalho de Melo301a0b02009-12-13 19:50:25 -020053
Arnaldo Carvalho de Melob7b61cb2015-03-03 11:58:45 -030054int perf_session__queue_event(struct perf_session *s, union perf_event *event,
55 struct perf_sample *sample, u64 file_offset);
David Ahern9c501402013-08-02 14:05:41 -060056
57void perf_tool__fill_defaults(struct perf_tool *tool);
58
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030059int perf_session__resolve_callchain(struct perf_session *session,
60 struct perf_evsel *evsel,
Frederic Weisbecker1b3a0e92011-01-14 04:51:58 +010061 struct thread *thread,
62 struct ip_callchain *chain,
63 struct symbol **parent);
Arnaldo Carvalho de Meloa3286262009-12-14 14:22:59 -020064
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030065bool perf_session__has_traces(struct perf_session *session, const char *msg);
Arnaldo Carvalho de Melo27295592009-12-27 21:37:01 -020066
David Aherneda39132011-07-15 12:34:09 -060067void perf_event__attr_swap(struct perf_event_attr *attr);
Arnaldo Carvalho de Meloba215942010-01-14 12:23:10 -020068
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030069int perf_session__create_kernel_maps(struct perf_session *session);
Arnaldo Carvalho de Melof9224c52010-03-11 20:12:44 -030070
Arnaldo Carvalho de Melo7b56cce2012-08-01 19:31:00 -030071void perf_session__set_id_hdr_size(struct perf_session *session);
Tom Zanussi8dc58102010-04-01 23:59:15 -050072
Arnaldo Carvalho de Melo23346f22010-04-27 21:17:50 -030073static inline
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030074struct machine *perf_session__find_machine(struct perf_session *session, pid_t pid)
Arnaldo Carvalho de Melo23346f22010-04-27 21:17:50 -030075{
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030076 return machines__find(&session->machines, pid);
Arnaldo Carvalho de Melo23346f22010-04-27 21:17:50 -030077}
78
79static inline
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030080struct machine *perf_session__findnew_machine(struct perf_session *session, pid_t pid)
Arnaldo Carvalho de Melo23346f22010-04-27 21:17:50 -030081{
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030082 return machines__findnew(&session->machines, pid);
Arnaldo Carvalho de Melo23346f22010-04-27 21:17:50 -030083}
84
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030085struct thread *perf_session__findnew(struct perf_session *session, pid_t pid);
86size_t perf_session__fprintf(struct perf_session *session, FILE *fp);
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020087
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030088size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp);
Arnaldo Carvalho de Melocbf69682010-04-27 21:22:44 -030089
Arnaldo Carvalho de Melo417c2ff2012-12-07 09:53:58 -030090size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp,
91 bool (fn)(struct dso *dso, int parm), int parm);
Arnaldo Carvalho de Meloc8446b92010-05-14 10:36:42 -030092
Arnaldo Carvalho de Meloe248de32011-03-05 21:40:06 -030093size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp);
Arnaldo Carvalho de Melod0dd74e2011-01-21 13:46:41 -020094
David Ahern9cbdb702011-04-06 21:54:20 -060095struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
96 unsigned int type);
97
Adrian Huntera2cb3cf2013-12-04 16:16:36 +020098void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample,
Arnaldo Carvalho de Melocc22e572013-12-19 17:20:06 -030099 struct addr_location *al,
David Ahern307cbb92013-08-07 22:50:53 -0400100 unsigned int print_opts, unsigned int stack_depth);
David Ahernc0230b22011-03-09 22:23:27 -0700101
Anton Blanchard5d67be92011-07-04 21:57:50 +1000102int perf_session__cpu_bitmap(struct perf_session *session,
103 const char *cpu_list, unsigned long *cpu_bitmap);
104
Stephane Eranianfbe96f22011-09-30 15:40:40 +0200105void perf_session__fprintf_info(struct perf_session *s, FILE *fp, bool full);
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -0300106
107struct perf_evsel_str_handler;
108
109int __perf_session__set_tracepoints_handlers(struct perf_session *session,
110 const struct perf_evsel_str_handler *assocs,
111 size_t nr_assocs);
112
113#define perf_session__set_tracepoints_handlers(session, array) \
114 __perf_session__set_tracepoints_handlers(session, array, ARRAY_SIZE(array))
Arnaldo Carvalho de Melo33e940a2013-09-17 16:34:28 -0300115
116extern volatile int session_done;
117
Pranith Kumar1da34da2014-09-23 10:55:08 -0400118#define session_done() ACCESS_ONCE(session_done)
Adrian Hunter3c659ee2014-10-27 15:49:22 +0200119
Adrian Huntera2938292014-10-27 15:49:23 +0200120int perf_session__deliver_synth_event(struct perf_session *session,
121 union perf_event *event,
Arnaldo Carvalho de Melob7b61cb2015-03-03 11:58:45 -0300122 struct perf_sample *sample);
Adrian Huntera2938292014-10-27 15:49:23 +0200123
Adrian Hunter3c659ee2014-10-27 15:49:22 +0200124int perf_event__process_id_index(struct perf_tool *tool,
125 union perf_event *event,
126 struct perf_session *session);
127
128int perf_event__synthesize_id_index(struct perf_tool *tool,
129 perf_event__handler_t process,
130 struct perf_evlist *evlist,
131 struct machine *machine);
132
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -0200133#endif /* __PERF_SESSION_H */