blob: 112bc2aa72e110153db98ba0f4d22232022117da [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;
11struct thread;
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
32int read_trace_init(int file_bigendian, int host_bigendian);
33void print_trace_event(int cpu, void *data, int size);
34
35void print_event(int cpu, void *data, int size, unsigned long long nsecs,
36 char *comm);
37
38int parse_ftrace_file(char *buf, unsigned long size);
39int parse_event_file(char *buf, unsigned long size, char *sys);
40
41struct record *trace_peek_data(int cpu);
42struct event_format *trace_find_event(int type);
43
44unsigned long long
45raw_field_value(struct event_format *event, const char *name, void *data);
46void *raw_field_ptr(struct event_format *event, const char *name, void *data);
47
48void parse_proc_kallsyms(char *file, unsigned int size __unused);
49void parse_ftrace_printk(char *file, unsigned int size __unused);
50
51ssize_t trace_report(int fd, bool repipe);
52
53int trace_parse_common_type(void *data);
54int trace_parse_common_pid(void *data);
55
56struct event_format *trace_find_next_event(struct event_format *event);
57unsigned long long read_size(void *ptr, int size);
58unsigned long long eval_flag(const char *flag);
59
60struct record *trace_read_data(int cpu);
Arnaldo Carvalho de Melo69aad6f2011-01-03 16:39:04 -020061int read_tracing_data(int fd, struct list_head *pattrs);
Jiri Olsa29208e52011-10-20 15:59:43 +020062
63struct tracing_data {
64 /* size is only valid if temp is 'true' */
65 ssize_t size;
66 bool temp;
67 char temp_file[50];
68};
69
70struct tracing_data *tracing_data_get(struct list_head *pattrs,
71 int fd, bool temp);
72void tracing_data_put(struct tracing_data *tdata);
73
Steven Rostedt520509432009-08-17 16:18:05 +020074
Tom Zanussi956ffd02009-11-25 01:15:46 -060075struct scripting_ops {
76 const char *name;
Tom Zanussi586bc5c2009-12-15 02:53:35 -060077 int (*start_script) (const char *script, int argc, const char **argv);
Tom Zanussi956ffd02009-11-25 01:15:46 -060078 int (*stop_script) (void);
David Ahernbe6d8422011-03-09 22:23:23 -070079 void (*process_event) (union perf_event *event,
80 struct perf_sample *sample,
Arnaldo Carvalho de Melo9e69c212011-03-15 15:44:01 -030081 struct perf_evsel *evsel,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020082 struct machine *machine,
David Ahernbe6d8422011-03-09 22:23:23 -070083 struct thread *thread);
Tom Zanussi956ffd02009-11-25 01:15:46 -060084 int (*generate_script) (const char *outfile);
85};
86
87int script_spec_register(const char *spec, struct scripting_ops *ops);
88
Tom Zanussi16c632d2009-11-25 01:15:48 -060089void setup_perl_scripting(void);
Tom Zanussi7e4b21b2010-01-27 02:27:57 -060090void setup_python_scripting(void);
Tom Zanussi16c632d2009-11-25 01:15:48 -060091
Tom Zanussi7397d802010-01-27 02:27:54 -060092struct scripting_context {
93 void *event_data;
94};
95
96int common_pc(struct scripting_context *context);
97int common_flags(struct scripting_context *context);
98int common_lock_depth(struct scripting_context *context);
99
Steven Rostedt4ace73e2012-04-06 00:47:52 +0200100#endif /* _PERF_UTIL_TRACE_EVENT_H */