18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _PERF_UTIL_TRACE_EVENT_H 38c2ecf20Sopenharmony_ci#define _PERF_UTIL_TRACE_EVENT_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <traceevent/event-parse.h> 68c2ecf20Sopenharmony_ci#include "parse-events.h" 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_cistruct machine; 98c2ecf20Sopenharmony_cistruct perf_sample; 108c2ecf20Sopenharmony_ciunion perf_event; 118c2ecf20Sopenharmony_cistruct perf_tool; 128c2ecf20Sopenharmony_cistruct thread; 138c2ecf20Sopenharmony_cistruct tep_plugin_list; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistruct trace_event { 168c2ecf20Sopenharmony_ci struct tep_handle *pevent; 178c2ecf20Sopenharmony_ci struct tep_plugin_list *plugin_list; 188c2ecf20Sopenharmony_ci}; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ciint trace_event__init(struct trace_event *t); 218c2ecf20Sopenharmony_civoid trace_event__cleanup(struct trace_event *t); 228c2ecf20Sopenharmony_ciint trace_event__register_resolver(struct machine *machine, 238c2ecf20Sopenharmony_ci tep_func_resolver_t *func); 248c2ecf20Sopenharmony_cistruct tep_event* 258c2ecf20Sopenharmony_citrace_event__tp_format(const char *sys, const char *name); 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistruct tep_event *trace_event__tp_format_id(int id); 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ciint bigendian(void); 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_civoid event_format__fprintf(struct tep_event *event, 328c2ecf20Sopenharmony_ci int cpu, void *data, int size, FILE *fp); 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_civoid event_format__print(struct tep_event *event, 358c2ecf20Sopenharmony_ci int cpu, void *data, int size); 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ciint parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size); 388c2ecf20Sopenharmony_ciint parse_event_file(struct tep_handle *pevent, 398c2ecf20Sopenharmony_ci char *buf, unsigned long size, char *sys); 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciunsigned long long 428c2ecf20Sopenharmony_ciraw_field_value(struct tep_event *event, const char *name, void *data); 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_civoid parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size); 458c2ecf20Sopenharmony_civoid parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size); 468c2ecf20Sopenharmony_civoid parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int size); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cissize_t trace_report(int fd, struct trace_event *tevent, bool repipe); 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ciunsigned long long read_size(struct tep_event *event, void *ptr, int size); 518c2ecf20Sopenharmony_ciunsigned long long eval_flag(const char *flag); 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ciint read_tracing_data(int fd, struct list_head *pattrs); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistruct tracing_data { 568c2ecf20Sopenharmony_ci /* size is only valid if temp is 'true' */ 578c2ecf20Sopenharmony_ci ssize_t size; 588c2ecf20Sopenharmony_ci bool temp; 598c2ecf20Sopenharmony_ci char temp_file[50]; 608c2ecf20Sopenharmony_ci}; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistruct tracing_data *tracing_data_get(struct list_head *pattrs, 638c2ecf20Sopenharmony_ci int fd, bool temp); 648c2ecf20Sopenharmony_ciint tracing_data_put(struct tracing_data *tdata); 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistruct addr_location; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistruct perf_session; 708c2ecf20Sopenharmony_cistruct perf_stat_config; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cistruct scripting_ops { 738c2ecf20Sopenharmony_ci const char *name; 748c2ecf20Sopenharmony_ci int (*start_script) (const char *script, int argc, const char **argv); 758c2ecf20Sopenharmony_ci int (*flush_script) (void); 768c2ecf20Sopenharmony_ci int (*stop_script) (void); 778c2ecf20Sopenharmony_ci void (*process_event) (union perf_event *event, 788c2ecf20Sopenharmony_ci struct perf_sample *sample, 798c2ecf20Sopenharmony_ci struct evsel *evsel, 808c2ecf20Sopenharmony_ci struct addr_location *al); 818c2ecf20Sopenharmony_ci void (*process_switch)(union perf_event *event, 828c2ecf20Sopenharmony_ci struct perf_sample *sample, 838c2ecf20Sopenharmony_ci struct machine *machine); 848c2ecf20Sopenharmony_ci void (*process_stat)(struct perf_stat_config *config, 858c2ecf20Sopenharmony_ci struct evsel *evsel, u64 tstamp); 868c2ecf20Sopenharmony_ci void (*process_stat_interval)(u64 tstamp); 878c2ecf20Sopenharmony_ci int (*generate_script) (struct tep_handle *pevent, const char *outfile); 888c2ecf20Sopenharmony_ci}; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ciextern unsigned int scripting_max_stack; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ciint script_spec_register(const char *spec, struct scripting_ops *ops); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_civoid setup_perl_scripting(void); 958c2ecf20Sopenharmony_civoid setup_python_scripting(void); 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistruct scripting_context { 988c2ecf20Sopenharmony_ci struct tep_handle *pevent; 998c2ecf20Sopenharmony_ci void *event_data; 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ciint common_pc(struct scripting_context *context); 1038c2ecf20Sopenharmony_ciint common_flags(struct scripting_context *context); 1048c2ecf20Sopenharmony_ciint common_lock_depth(struct scripting_context *context); 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#endif /* _PERF_UTIL_TRACE_EVENT_H */ 107