1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _PERF_UTIL_TRACE_EVENT_H
3 #define _PERF_UTIL_TRACE_EVENT_H
7 #include <linux/types.h>
15 struct tep_plugin_list;
19 struct tep_handle *pevent;
20 struct tep_plugin_list *plugin_list;
23 typedef char *(tep_func_resolver_t)(void *priv,
24 unsigned long long *addrp, char **modp);
26 bool have_tracepoints(struct list_head *evlist);
28 int trace_event__init(struct trace_event *t);
29 void trace_event__cleanup(struct trace_event *t);
30 int trace_event__register_resolver(struct machine *machine,
31 tep_func_resolver_t *func);
33 trace_event__tp_format(const char *sys, const char *name);
35 struct tep_event *trace_event__tp_format_id(int id);
37 void event_format__fprintf(struct tep_event *event,
38 int cpu, void *data, int size, FILE *fp);
40 void event_format__print(struct tep_event *event,
41 int cpu, void *data, int size);
43 int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size);
44 int parse_event_file(struct tep_handle *pevent,
45 char *buf, unsigned long size, char *sys);
48 raw_field_value(struct tep_event *event, const char *name, void *data);
50 void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size);
51 void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size);
52 void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int size);
54 ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe);
56 unsigned long long read_size(struct tep_event *event, void *ptr, int size);
57 unsigned long long eval_flag(const char *flag);
59 int read_tracing_data(int fd, struct list_head *pattrs);
62 /* size is only valid if temp is 'true' */
68 struct tracing_data *tracing_data_get(struct list_head *pattrs,
70 int tracing_data_put(struct tracing_data *tdata);
76 struct perf_stat_config;
78 struct scripting_ops {
80 const char *dirname; /* For script path .../scripts/<dirname>/... */
81 int (*start_script)(const char *script, int argc, const char **argv,
82 struct perf_session *session);
83 int (*flush_script) (void);
84 int (*stop_script) (void);
85 void (*process_event) (union perf_event *event,
86 struct perf_sample *sample,
88 struct addr_location *al,
89 struct addr_location *addr_al);
90 void (*process_switch)(union perf_event *event,
91 struct perf_sample *sample,
92 struct machine *machine);
93 void (*process_auxtrace_error)(struct perf_session *session,
94 union perf_event *event);
95 void (*process_stat)(struct perf_stat_config *config,
96 struct evsel *evsel, u64 tstamp);
97 void (*process_stat_interval)(u64 tstamp);
98 void (*process_throttle)(union perf_event *event,
99 struct perf_sample *sample,
100 struct machine *machine);
101 int (*generate_script) (struct tep_handle *pevent, const char *outfile);
104 extern unsigned int scripting_max_stack;
106 int script_spec_register(const char *spec, struct scripting_ops *ops);
108 void script_fetch_insn(struct perf_sample *sample, struct thread *thread,
109 struct machine *machine);
111 void setup_perl_scripting(void);
112 void setup_python_scripting(void);
114 struct scripting_context {
115 struct tep_handle *pevent;
117 union perf_event *event;
118 struct perf_sample *sample;
120 struct addr_location *al;
121 struct addr_location *addr_al;
122 struct perf_session *session;
125 void scripting_context__update(struct scripting_context *scripting_context,
126 union perf_event *event,
127 struct perf_sample *sample,
129 struct addr_location *al,
130 struct addr_location *addr_al);
132 int common_pc(struct scripting_context *context);
133 int common_flags(struct scripting_context *context);
134 int common_lock_depth(struct scripting_context *context);
136 #define SAMPLE_FLAGS_BUF_SIZE 64
137 int perf_sample__sprintf_flags(u32 flags, char *str, size_t sz);
139 #endif /* _PERF_UTIL_TRACE_EVENT_H */