blob: 069d105e0fc0f4e1551517fa989c609177505a76 [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;
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020012struct thread;
Steven Rostedt520509432009-08-17 16:18:05 +020013
Steven Rostedtaaf045f2012-04-06 00:47:56 +020014extern int header_page_size_size;
15extern int header_page_ts_size;
16extern int header_page_data_offset;
17
18extern bool latency_format;
19extern struct pevent *perf_pevent;
20
21enum {
22 RINGBUF_TYPE_PADDING = 29,
23 RINGBUF_TYPE_TIME_EXTEND = 30,
24 RINGBUF_TYPE_TIME_STAMP = 31,
25};
26
27#ifndef TS_SHIFT
28#define TS_SHIFT 27
29#endif
30
31int bigendian(void);
32
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030033struct pevent *read_trace_init(int file_bigendian, int host_bigendian);
34void print_trace_event(struct pevent *pevent, int cpu, void *data, int size);
Arnaldo Carvalho de Melofcf65bf2012-08-07 09:58:03 -030035void event_format__print(struct event_format *event,
36 int cpu, void *data, int size);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020037
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030038void print_event(struct pevent *pevent, int cpu, void *data, int size,
39 unsigned long long nsecs, char *comm);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020040
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030041int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size);
42int parse_event_file(struct pevent *pevent,
43 char *buf, unsigned long size, char *sys);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020044
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030045struct pevent_record *trace_peek_data(struct pevent *pevent, int cpu);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020046
47unsigned long long
48raw_field_value(struct event_format *event, const char *name, void *data);
49void *raw_field_ptr(struct event_format *event, const char *name, void *data);
50
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030051void parse_proc_kallsyms(struct pevent *pevent, char *file, unsigned int size);
52void parse_ftrace_printk(struct pevent *pevent, char *file, unsigned int size);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020053
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030054ssize_t trace_report(int fd, struct pevent **pevent, bool repipe);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020055
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030056int trace_parse_common_type(struct pevent *pevent, void *data);
57int trace_parse_common_pid(struct pevent *pevent, void *data);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020058
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030059struct event_format *trace_find_next_event(struct pevent *pevent,
60 struct event_format *event);
61unsigned long long read_size(struct pevent *pevent, void *ptr, int size);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020062unsigned long long eval_flag(const char *flag);
63
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030064struct pevent_record *trace_read_data(struct pevent *pevent, int cpu);
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -020065int read_tracing_data(int fd, struct list_head *pattrs);
Jiri Olsa29208e52011-10-20 15:59:43 +020066
67struct tracing_data {
68 /* size is only valid if temp is 'true' */
69 ssize_t size;
70 bool temp;
71 char temp_file[50];
72};
73
74struct tracing_data *tracing_data_get(struct list_head *pattrs,
75 int fd, bool temp);
76void tracing_data_put(struct tracing_data *tdata);
77
Steven Rostedt520509432009-08-17 16:18:05 +020078
Tom Zanussi956ffd02009-11-25 01:15:46 -060079struct scripting_ops {
80 const char *name;
Tom Zanussi586bc5c2009-12-15 02:53:35 -060081 int (*start_script) (const char *script, int argc, const char **argv);
Tom Zanussi956ffd02009-11-25 01:15:46 -060082 int (*stop_script) (void);
David Ahernbe6d8422011-03-09 22:23:23 -070083 void (*process_event) (union perf_event *event,
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030084 struct pevent *pevent,
David Ahernbe6d8422011-03-09 22:23:23 -070085 struct perf_sample *sample,
Arnaldo Carvalho de Melo9e69c212011-03-15 15:44:01 -030086 struct perf_evsel *evsel,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020087 struct machine *machine,
David Ahernbe6d8422011-03-09 22:23:23 -070088 struct thread *thread);
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030089 int (*generate_script) (struct pevent *pevent, const char *outfile);
Tom Zanussi956ffd02009-11-25 01:15:46 -060090};
91
92int script_spec_register(const char *spec, struct scripting_ops *ops);
93
Tom Zanussi16c632d2009-11-25 01:15:48 -060094void setup_perl_scripting(void);
Tom Zanussi7e4b21b2010-01-27 02:27:57 -060095void setup_python_scripting(void);
Tom Zanussi16c632d2009-11-25 01:15:48 -060096
Tom Zanussi7397d802010-01-27 02:27:54 -060097struct scripting_context {
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030098 struct pevent *pevent;
Tom Zanussi7397d802010-01-27 02:27:54 -060099 void *event_data;
100};
101
102int common_pc(struct scripting_context *context);
103int common_flags(struct scripting_context *context);
104int common_lock_depth(struct scripting_context *context);
105
Steven Rostedt4ace73e2012-04-06 00:47:52 +0200106#endif /* _PERF_UTIL_TRACE_EVENT_H */