blob: 8fef1d6687b73250a24e682b4c41a9fb29384421 [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);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020035
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030036void print_event(struct pevent *pevent, int cpu, void *data, int size,
37 unsigned long long nsecs, char *comm);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020038
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030039int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size);
40int parse_event_file(struct pevent *pevent,
41 char *buf, unsigned long size, char *sys);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020042
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030043struct pevent_record *trace_peek_data(struct pevent *pevent, int cpu);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020044
45unsigned long long
46raw_field_value(struct event_format *event, const char *name, void *data);
47void *raw_field_ptr(struct event_format *event, const char *name, void *data);
48
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030049void parse_proc_kallsyms(struct pevent *pevent, char *file, unsigned int size);
50void parse_ftrace_printk(struct pevent *pevent, char *file, unsigned int size);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020051
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030052ssize_t trace_report(int fd, struct pevent **pevent, bool repipe);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020053
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030054int trace_parse_common_type(struct pevent *pevent, void *data);
55int trace_parse_common_pid(struct pevent *pevent, void *data);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020056
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030057struct event_format *trace_find_next_event(struct pevent *pevent,
58 struct event_format *event);
59unsigned long long read_size(struct pevent *pevent, void *ptr, int size);
Steven Rostedtaaf045f2012-04-06 00:47:56 +020060unsigned long long eval_flag(const char *flag);
61
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030062struct pevent_record *trace_read_data(struct pevent *pevent, int cpu);
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -020063int read_tracing_data(int fd, struct list_head *pattrs);
Jiri Olsa29208e52011-10-20 15:59:43 +020064
65struct tracing_data {
66 /* size is only valid if temp is 'true' */
67 ssize_t size;
68 bool temp;
69 char temp_file[50];
70};
71
72struct tracing_data *tracing_data_get(struct list_head *pattrs,
73 int fd, bool temp);
74void tracing_data_put(struct tracing_data *tdata);
75
Steven Rostedt520509432009-08-17 16:18:05 +020076
Tom Zanussi956ffd02009-11-25 01:15:46 -060077struct scripting_ops {
78 const char *name;
Tom Zanussi586bc5c2009-12-15 02:53:35 -060079 int (*start_script) (const char *script, int argc, const char **argv);
Tom Zanussi956ffd02009-11-25 01:15:46 -060080 int (*stop_script) (void);
David Ahernbe6d8422011-03-09 22:23:23 -070081 void (*process_event) (union perf_event *event,
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030082 struct pevent *pevent,
David Ahernbe6d8422011-03-09 22:23:23 -070083 struct perf_sample *sample,
Arnaldo Carvalho de Melo9e69c212011-03-15 15:44:01 -030084 struct perf_evsel *evsel,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020085 struct machine *machine,
David Ahernbe6d8422011-03-09 22:23:23 -070086 struct thread *thread);
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030087 int (*generate_script) (struct pevent *pevent, const char *outfile);
Tom Zanussi956ffd02009-11-25 01:15:46 -060088};
89
90int script_spec_register(const char *spec, struct scripting_ops *ops);
91
Tom Zanussi16c632d2009-11-25 01:15:48 -060092void setup_perl_scripting(void);
Tom Zanussi7e4b21b2010-01-27 02:27:57 -060093void setup_python_scripting(void);
Tom Zanussi16c632d2009-11-25 01:15:48 -060094
Tom Zanussi7397d802010-01-27 02:27:54 -060095struct scripting_context {
Arnaldo Carvalho de Meloda378962012-06-27 13:08:42 -030096 struct pevent *pevent;
Tom Zanussi7397d802010-01-27 02:27:54 -060097 void *event_data;
98};
99
100int common_pc(struct scripting_context *context);
101int common_flags(struct scripting_context *context);
102int common_lock_depth(struct scripting_context *context);
103
Steven Rostedt4ace73e2012-04-06 00:47:52 +0200104#endif /* _PERF_UTIL_TRACE_EVENT_H */