0001
0002 #ifndef _PERF_UTIL_TRACE_EVENT_H
0003 #define _PERF_UTIL_TRACE_EVENT_H
0004
0005 #include <traceevent/event-parse.h>
0006 #include "parse-events.h"
0007
0008 struct machine;
0009 struct perf_sample;
0010 union perf_event;
0011 struct perf_tool;
0012 struct thread;
0013 struct tep_plugin_list;
0014 struct evsel;
0015
0016 struct trace_event {
0017 struct tep_handle *pevent;
0018 struct tep_plugin_list *plugin_list;
0019 };
0020
0021 int trace_event__init(struct trace_event *t);
0022 void trace_event__cleanup(struct trace_event *t);
0023 int trace_event__register_resolver(struct machine *machine,
0024 tep_func_resolver_t *func);
0025 struct tep_event*
0026 trace_event__tp_format(const char *sys, const char *name);
0027
0028 struct tep_event *trace_event__tp_format_id(int id);
0029
0030 int bigendian(void);
0031
0032 void event_format__fprintf(struct tep_event *event,
0033 int cpu, void *data, int size, FILE *fp);
0034
0035 void event_format__print(struct tep_event *event,
0036 int cpu, void *data, int size);
0037
0038 int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size);
0039 int parse_event_file(struct tep_handle *pevent,
0040 char *buf, unsigned long size, char *sys);
0041
0042 unsigned long long
0043 raw_field_value(struct tep_event *event, const char *name, void *data);
0044
0045 void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size);
0046 void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size);
0047 void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int size);
0048
0049 ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe);
0050
0051 unsigned long long read_size(struct tep_event *event, void *ptr, int size);
0052 unsigned long long eval_flag(const char *flag);
0053
0054 int read_tracing_data(int fd, struct list_head *pattrs);
0055
0056 struct tracing_data {
0057
0058 ssize_t size;
0059 bool temp;
0060 char temp_file[50];
0061 };
0062
0063 struct tracing_data *tracing_data_get(struct list_head *pattrs,
0064 int fd, bool temp);
0065 int tracing_data_put(struct tracing_data *tdata);
0066
0067
0068 struct addr_location;
0069
0070 struct perf_session;
0071 struct perf_stat_config;
0072
0073 struct scripting_ops {
0074 const char *name;
0075 const char *dirname;
0076 int (*start_script)(const char *script, int argc, const char **argv,
0077 struct perf_session *session);
0078 int (*flush_script) (void);
0079 int (*stop_script) (void);
0080 void (*process_event) (union perf_event *event,
0081 struct perf_sample *sample,
0082 struct evsel *evsel,
0083 struct addr_location *al,
0084 struct addr_location *addr_al);
0085 void (*process_switch)(union perf_event *event,
0086 struct perf_sample *sample,
0087 struct machine *machine);
0088 void (*process_auxtrace_error)(struct perf_session *session,
0089 union perf_event *event);
0090 void (*process_stat)(struct perf_stat_config *config,
0091 struct evsel *evsel, u64 tstamp);
0092 void (*process_stat_interval)(u64 tstamp);
0093 void (*process_throttle)(union perf_event *event,
0094 struct perf_sample *sample,
0095 struct machine *machine);
0096 int (*generate_script) (struct tep_handle *pevent, const char *outfile);
0097 };
0098
0099 extern unsigned int scripting_max_stack;
0100
0101 int script_spec_register(const char *spec, struct scripting_ops *ops);
0102
0103 void script_fetch_insn(struct perf_sample *sample, struct thread *thread,
0104 struct machine *machine);
0105
0106 void setup_perl_scripting(void);
0107 void setup_python_scripting(void);
0108
0109 struct scripting_context {
0110 struct tep_handle *pevent;
0111 void *event_data;
0112 union perf_event *event;
0113 struct perf_sample *sample;
0114 struct evsel *evsel;
0115 struct addr_location *al;
0116 struct addr_location *addr_al;
0117 struct perf_session *session;
0118 };
0119
0120 void scripting_context__update(struct scripting_context *scripting_context,
0121 union perf_event *event,
0122 struct perf_sample *sample,
0123 struct evsel *evsel,
0124 struct addr_location *al,
0125 struct addr_location *addr_al);
0126
0127 int common_pc(struct scripting_context *context);
0128 int common_flags(struct scripting_context *context);
0129 int common_lock_depth(struct scripting_context *context);
0130
0131 #define SAMPLE_FLAGS_BUF_SIZE 64
0132 int perf_sample__sprintf_flags(u32 flags, char *str, size_t sz);
0133
0134 #endif