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