1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun #ifndef _PERF_UTIL_TRACE_EVENT_H 3*4882a593Smuzhiyun #define _PERF_UTIL_TRACE_EVENT_H 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun #include <traceevent/event-parse.h> 6*4882a593Smuzhiyun #include "parse-events.h" 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun struct machine; 9*4882a593Smuzhiyun struct perf_sample; 10*4882a593Smuzhiyun union perf_event; 11*4882a593Smuzhiyun struct perf_tool; 12*4882a593Smuzhiyun struct thread; 13*4882a593Smuzhiyun struct tep_plugin_list; 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun struct trace_event { 16*4882a593Smuzhiyun struct tep_handle *pevent; 17*4882a593Smuzhiyun struct tep_plugin_list *plugin_list; 18*4882a593Smuzhiyun }; 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun int trace_event__init(struct trace_event *t); 21*4882a593Smuzhiyun void trace_event__cleanup(struct trace_event *t); 22*4882a593Smuzhiyun int trace_event__register_resolver(struct machine *machine, 23*4882a593Smuzhiyun tep_func_resolver_t *func); 24*4882a593Smuzhiyun struct tep_event* 25*4882a593Smuzhiyun trace_event__tp_format(const char *sys, const char *name); 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun struct tep_event *trace_event__tp_format_id(int id); 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun int bigendian(void); 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun void event_format__fprintf(struct tep_event *event, 32*4882a593Smuzhiyun int cpu, void *data, int size, FILE *fp); 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun void event_format__print(struct tep_event *event, 35*4882a593Smuzhiyun int cpu, void *data, int size); 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size); 38*4882a593Smuzhiyun int parse_event_file(struct tep_handle *pevent, 39*4882a593Smuzhiyun char *buf, unsigned long size, char *sys); 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun unsigned long long 42*4882a593Smuzhiyun raw_field_value(struct tep_event *event, const char *name, void *data); 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size); 45*4882a593Smuzhiyun void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size); 46*4882a593Smuzhiyun void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int size); 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe); 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun unsigned long long read_size(struct tep_event *event, void *ptr, int size); 51*4882a593Smuzhiyun unsigned long long eval_flag(const char *flag); 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun int read_tracing_data(int fd, struct list_head *pattrs); 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun struct tracing_data { 56*4882a593Smuzhiyun /* size is only valid if temp is 'true' */ 57*4882a593Smuzhiyun ssize_t size; 58*4882a593Smuzhiyun bool temp; 59*4882a593Smuzhiyun char temp_file[50]; 60*4882a593Smuzhiyun }; 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun struct tracing_data *tracing_data_get(struct list_head *pattrs, 63*4882a593Smuzhiyun int fd, bool temp); 64*4882a593Smuzhiyun int tracing_data_put(struct tracing_data *tdata); 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun struct addr_location; 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun struct perf_session; 70*4882a593Smuzhiyun struct perf_stat_config; 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun struct scripting_ops { 73*4882a593Smuzhiyun const char *name; 74*4882a593Smuzhiyun int (*start_script) (const char *script, int argc, const char **argv); 75*4882a593Smuzhiyun int (*flush_script) (void); 76*4882a593Smuzhiyun int (*stop_script) (void); 77*4882a593Smuzhiyun void (*process_event) (union perf_event *event, 78*4882a593Smuzhiyun struct perf_sample *sample, 79*4882a593Smuzhiyun struct evsel *evsel, 80*4882a593Smuzhiyun struct addr_location *al); 81*4882a593Smuzhiyun void (*process_switch)(union perf_event *event, 82*4882a593Smuzhiyun struct perf_sample *sample, 83*4882a593Smuzhiyun struct machine *machine); 84*4882a593Smuzhiyun void (*process_stat)(struct perf_stat_config *config, 85*4882a593Smuzhiyun struct evsel *evsel, u64 tstamp); 86*4882a593Smuzhiyun void (*process_stat_interval)(u64 tstamp); 87*4882a593Smuzhiyun int (*generate_script) (struct tep_handle *pevent, const char *outfile); 88*4882a593Smuzhiyun }; 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun extern unsigned int scripting_max_stack; 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun int script_spec_register(const char *spec, struct scripting_ops *ops); 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun void setup_perl_scripting(void); 95*4882a593Smuzhiyun void setup_python_scripting(void); 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun struct scripting_context { 98*4882a593Smuzhiyun struct tep_handle *pevent; 99*4882a593Smuzhiyun void *event_data; 100*4882a593Smuzhiyun }; 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun int common_pc(struct scripting_context *context); 103*4882a593Smuzhiyun int common_flags(struct scripting_context *context); 104*4882a593Smuzhiyun int common_lock_depth(struct scripting_context *context); 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun #endif /* _PERF_UTIL_TRACE_EVENT_H */ 107