blob: a55fd37ffea1e50600f8af68797ded8411686128 [file] [log] [blame]
Steven Rostedt4ace73e2012-04-06 00:47:52 +02001#ifndef _PERF_UTIL_TRACE_EVENT_H
2#define _PERF_UTIL_TRACE_EVENT_H
Steven Rostedt520509432009-08-17 16:18:05 +02003
Frederic Weisbecker1ef2ed12009-08-28 03:09:58 +02004#include "parse-events.h"
Steven Rostedtaaf045f2012-04-06 00:47:56 +02005#include "event-parse.h"
Steven Rostedt4ace73e2012-04-06 00:47:52 +02006#include "session.h"
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -02007
8struct machine;
9struct perf_sample;
10union perf_event;
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030011struct perf_tool;
Steven Rostedt520509432009-08-17 16:18:05 +020012
Steven Rostedtaaf045f2012-04-06 00:47:56 +020013extern int header_page_size_size;
14extern int header_page_ts_size;
15extern int header_page_data_offset;
16
17extern bool latency_format;
18extern struct pevent *perf_pevent;
19
20enum {
21 RINGBUF_TYPE_PADDING = 29,
22 RINGBUF_TYPE_TIME_EXTEND = 30,
23 RINGBUF_TYPE_TIME_STAMP = 31,
24};
25
26#ifndef TS_SHIFT
27#define TS_SHIFT 27
28#endif
29
30int bigendian(void);
31
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030032struct pevent *read_trace_init(int file_bigendian, int host_bigendian);
33void print_trace_event(struct pevent *pevent, int cpu, void *data, int size);
Arnaldo Carvalho de Melofcf65bf2012-08-07 09:58:03 -030034void event_format__print(struct event_format *event,
35 int cpu, void *data, int size);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020036
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030037void print_event(struct pevent *pevent, int cpu, void *data, int size,
38 unsigned long long nsecs, char *comm);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020039
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030040int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size);
41int parse_event_file(struct pevent *pevent,
42 char *buf, unsigned long size, char *sys);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020043
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030044struct pevent_record *trace_peek_data(struct pevent *pevent, int cpu);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020045
46unsigned long long
47raw_field_value(struct event_format *event, const char *name, void *data);
48void *raw_field_ptr(struct event_format *event, const char *name, void *data);
49
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030050void parse_proc_kallsyms(struct pevent *pevent, char *file, unsigned int size);
51void parse_ftrace_printk(struct pevent *pevent, char *file, unsigned int size);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020052
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030053ssize_t trace_report(int fd, struct pevent **pevent, bool repipe);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020054
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030055int trace_parse_common_type(struct pevent *pevent, void *data);
56int trace_parse_common_pid(struct pevent *pevent, void *data);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020057
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030058struct event_format *trace_find_next_event(struct pevent *pevent,
59 struct event_format *event);
Arnaldo Carvalho de Melo97822432012-08-07 23:50:21 -030060unsigned long long read_size(struct event_format *event, void *ptr, int size);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020061unsigned long long eval_flag(const char *flag);
62
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030063struct pevent_record *trace_read_data(struct pevent *pevent, int cpu);
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -020064int read_tracing_data(int fd, struct list_head *pattrs);
Jiri Olsa29208e52011-10-20 15:59:43 +020065
66struct tracing_data {
67 /* size is only valid if temp is 'true' */
68 ssize_t size;
69 bool temp;
70 char temp_file[50];
71};
72
73struct tracing_data *tracing_data_get(struct list_head *pattrs,
74 int fd, bool temp);
75void tracing_data_put(struct tracing_data *tdata);
76
Steven Rostedt520509432009-08-17 16:18:05 +020077
Feng Tang73994dc2012-08-08 17:57:52 +080078struct addr_location;
79
Jiri Olsa71ad0f52012-08-07 15:20:46 +020080struct perf_session;
81
Tom Zanussi956ffd02009-11-25 01:15:46 -060082struct scripting_ops {
83 const char *name;
Tom Zanussi586bc5c2009-12-15 02:53:35 -060084 int (*start_script) (const char *script, int argc, const char **argv);
Tom Zanussi956ffd02009-11-25 01:15:46 -060085 int (*stop_script) (void);
David Ahernbe6d8422011-03-09 22:23:23 -070086 void (*process_event) (union perf_event *event,
87 struct perf_sample *sample,
Arnaldo Carvalho de Melo9e69c212011-03-15 15:44:01 -030088 struct perf_evsel *evsel,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020089 struct machine *machine,
Feng Tang73994dc2012-08-08 17:57:52 +080090 struct addr_location *al);
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030091 int (*generate_script) (struct pevent *pevent, const char *outfile);
Tom Zanussi956ffd02009-11-25 01:15:46 -060092};
93
94int script_spec_register(const char *spec, struct scripting_ops *ops);
95
Tom Zanussi16c632d2009-11-25 01:15:48 -060096void setup_perl_scripting(void);
Tom Zanussi7e4b21b2010-01-27 02:27:57 -060097void setup_python_scripting(void);
Tom Zanussi16c632d2009-11-25 01:15:48 -060098
Tom Zanussi7397d802010-01-27 02:27:54 -060099struct scripting_context {
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -0300100 struct pevent *pevent;
Tom Zanussi7397d802010-01-27 02:27:54 -0600101 void *event_data;
102};
103
104int common_pc(struct scripting_context *context);
105int common_flags(struct scripting_context *context);
106int common_lock_depth(struct scripting_context *context);
107
Steven Rostedt4ace73e2012-04-06 00:47:52 +0200108#endif /* _PERF_UTIL_TRACE_EVENT_H */