Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Steven Rostedt | 4ace73e | 2012-04-06 00:47:52 +0200 | [diff] [blame] | 2 | #ifndef _PERF_UTIL_TRACE_EVENT_H |
| 3 | #define _PERF_UTIL_TRACE_EVENT_H |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 4 | |
Robert Richter | 4e31902 | 2013-06-11 17:29:18 +0200 | [diff] [blame] | 5 | #include <traceevent/event-parse.h> |
Frederic Weisbecker | 1ef2ed1 | 2009-08-28 03:09:58 +0200 | [diff] [blame] | 6 | #include "parse-events.h" |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 7 | |
| 8 | struct machine; |
| 9 | struct perf_sample; |
| 10 | union perf_event; |
Arnaldo Carvalho de Melo | da37896 | 2012-06-27 13:08:42 -0300 | [diff] [blame] | 11 | struct perf_tool; |
David Ahern | 2eaa1b4 | 2013-07-18 16:06:15 -0600 | [diff] [blame] | 12 | struct thread; |
Tzvetomir Stoyanov (VMware) | 785be0c | 2018-09-19 14:56:56 -0400 | [diff] [blame] | 13 | struct tep_plugin_list; |
Adrian Hunter | cac3040 | 2021-05-30 22:22:58 +0300 | [diff] [blame] | 14 | struct evsel; |
Jiri Olsa | 29f5ffd | 2013-12-03 14:09:23 +0100 | [diff] [blame] | 15 | |
| 16 | struct trace_event { |
Tzvetomir Stoyanov (VMware) | 096177a | 2018-08-08 14:02:46 -0400 | [diff] [blame] | 17 | struct tep_handle *pevent; |
Tzvetomir Stoyanov (VMware) | 785be0c | 2018-09-19 14:56:56 -0400 | [diff] [blame] | 18 | struct tep_plugin_list *plugin_list; |
Jiri Olsa | 29f5ffd | 2013-12-03 14:09:23 +0100 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | int trace_event__init(struct trace_event *t); |
| 22 | void trace_event__cleanup(struct trace_event *t); |
Arnaldo Carvalho de Melo | 959c219 | 2015-07-24 12:13:05 -0300 | [diff] [blame] | 23 | int trace_event__register_resolver(struct machine *machine, |
Tzvetomir Stoyanov (VMware) | 4d5c58b | 2018-08-08 14:02:49 -0400 | [diff] [blame] | 24 | tep_func_resolver_t *func); |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 25 | struct tep_event* |
Jiri Olsa | 97978b3 | 2013-12-03 14:09:24 +0100 | [diff] [blame] | 26 | trace_event__tp_format(const char *sys, const char *name); |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 27 | |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 28 | struct tep_event *trace_event__tp_format_id(int id); |
Jiri Olsa | 71fe105 | 2016-07-10 13:07:54 +0200 | [diff] [blame] | 29 | |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 30 | int bigendian(void); |
| 31 | |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 32 | void event_format__fprintf(struct tep_event *event, |
Arnaldo Carvalho de Melo | aa1aac1 | 2015-02-03 12:46:58 -0300 | [diff] [blame] | 33 | int cpu, void *data, int size, FILE *fp); |
| 34 | |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 35 | void event_format__print(struct tep_event *event, |
Arnaldo Carvalho de Melo | fcf65bf | 2012-08-07 09:58:03 -0300 | [diff] [blame] | 36 | int cpu, void *data, int size); |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 37 | |
Tzvetomir Stoyanov (VMware) | 096177a | 2018-08-08 14:02:46 -0400 | [diff] [blame] | 38 | int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size); |
| 39 | int parse_event_file(struct tep_handle *pevent, |
Arnaldo Carvalho de Melo | da37896 | 2012-06-27 13:08:42 -0300 | [diff] [blame] | 40 | char *buf, unsigned long size, char *sys); |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 41 | |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 42 | unsigned long long |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 43 | raw_field_value(struct tep_event *event, const char *name, void *data); |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 44 | |
Tzvetomir Stoyanov (VMware) | 096177a | 2018-08-08 14:02:46 -0400 | [diff] [blame] | 45 | void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size); |
| 46 | void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size); |
| 47 | void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int size); |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 48 | |
Jiri Olsa | 29f5ffd | 2013-12-03 14:09:23 +0100 | [diff] [blame] | 49 | ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe); |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 50 | |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 51 | unsigned long long read_size(struct tep_event *event, void *ptr, int size); |
Steven Rostedt | aaf045f | 2012-04-06 00:47:56 +0200 | [diff] [blame] | 52 | unsigned long long eval_flag(const char *flag); |
| 53 | |
Arnaldo Carvalho de Melo | 69aad6f | 2011-01-03 16:39:04 -0200 | [diff] [blame] | 54 | int read_tracing_data(int fd, struct list_head *pattrs); |
Jiri Olsa | 29208e5 | 2011-10-20 15:59:43 +0200 | [diff] [blame] | 55 | |
| 56 | struct tracing_data { |
| 57 | /* size is only valid if temp is 'true' */ |
| 58 | ssize_t size; |
| 59 | bool temp; |
| 60 | char temp_file[50]; |
| 61 | }; |
| 62 | |
| 63 | struct tracing_data *tracing_data_get(struct list_head *pattrs, |
| 64 | int fd, bool temp); |
Namhyung Kim | 8755d5e | 2013-03-21 16:18:46 +0900 | [diff] [blame] | 65 | int tracing_data_put(struct tracing_data *tdata); |
Jiri Olsa | 29208e5 | 2011-10-20 15:59:43 +0200 | [diff] [blame] | 66 | |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 67 | |
Feng Tang | 73994dc | 2012-08-08 17:57:52 +0800 | [diff] [blame] | 68 | struct addr_location; |
| 69 | |
Jiri Olsa | 71ad0f5 | 2012-08-07 15:20:46 +0200 | [diff] [blame] | 70 | struct perf_session; |
Jiri Olsa | 8058a30 | 2016-01-05 22:09:08 +0100 | [diff] [blame] | 71 | struct perf_stat_config; |
Jiri Olsa | 71ad0f5 | 2012-08-07 15:20:46 +0200 | [diff] [blame] | 72 | |
Tom Zanussi | 956ffd0 | 2009-11-25 01:15:46 -0600 | [diff] [blame] | 73 | struct scripting_ops { |
| 74 | const char *name; |
Adrian Hunter | 6ea4b5d | 2021-05-24 09:57:18 +0300 | [diff] [blame] | 75 | const char *dirname; /* For script path .../scripts/<dirname>/... */ |
Adrian Hunter | 67e50ce | 2021-05-30 22:22:59 +0300 | [diff] [blame] | 76 | int (*start_script)(const char *script, int argc, const char **argv, |
| 77 | struct perf_session *session); |
Adrian Hunter | d445dd2 | 2014-08-15 22:08:37 +0300 | [diff] [blame] | 78 | int (*flush_script) (void); |
Tom Zanussi | 956ffd0 | 2009-11-25 01:15:46 -0600 | [diff] [blame] | 79 | int (*stop_script) (void); |
David Ahern | be6d842 | 2011-03-09 22:23:23 -0700 | [diff] [blame] | 80 | void (*process_event) (union perf_event *event, |
| 81 | struct perf_sample *sample, |
Jiri Olsa | 32dcd02 | 2019-07-21 13:23:51 +0200 | [diff] [blame] | 82 | struct evsel *evsel, |
Adrian Hunter | 3f8e009 | 2021-05-25 12:51:05 +0300 | [diff] [blame] | 83 | struct addr_location *al, |
| 84 | struct addr_location *addr_al); |
Adrian Hunter | 5bf83c2 | 2019-07-10 11:58:06 +0300 | [diff] [blame] | 85 | void (*process_switch)(union perf_event *event, |
| 86 | struct perf_sample *sample, |
| 87 | struct machine *machine); |
Adrian Hunter | 2ede921 | 2021-05-25 12:51:11 +0300 | [diff] [blame] | 88 | void (*process_auxtrace_error)(struct perf_session *session, |
| 89 | union perf_event *event); |
Jiri Olsa | 8058a30 | 2016-01-05 22:09:08 +0100 | [diff] [blame] | 90 | void (*process_stat)(struct perf_stat_config *config, |
Jiri Olsa | 32dcd02 | 2019-07-21 13:23:51 +0200 | [diff] [blame] | 91 | struct evsel *evsel, u64 tstamp); |
Jiri Olsa | 8058a30 | 2016-01-05 22:09:08 +0100 | [diff] [blame] | 92 | void (*process_stat_interval)(u64 tstamp); |
Stephen Brennan | 538d9c1 | 2021-09-01 14:08:15 -0700 | [diff] [blame] | 93 | void (*process_throttle)(union perf_event *event, |
| 94 | struct perf_sample *sample, |
| 95 | struct machine *machine); |
Tzvetomir Stoyanov (VMware) | 096177a | 2018-08-08 14:02:46 -0400 | [diff] [blame] | 96 | int (*generate_script) (struct tep_handle *pevent, const char *outfile); |
Tom Zanussi | 956ffd0 | 2009-11-25 01:15:46 -0600 | [diff] [blame] | 97 | }; |
| 98 | |
Adrian Hunter | 44cbe72 | 2015-09-25 16:15:50 +0300 | [diff] [blame] | 99 | extern unsigned int scripting_max_stack; |
| 100 | |
Tom Zanussi | 956ffd0 | 2009-11-25 01:15:46 -0600 | [diff] [blame] | 101 | int script_spec_register(const char *spec, struct scripting_ops *ops); |
| 102 | |
Adrian Hunter | d9ae9c9 | 2021-05-30 22:23:01 +0300 | [diff] [blame] | 103 | void script_fetch_insn(struct perf_sample *sample, struct thread *thread, |
| 104 | struct machine *machine); |
| 105 | |
Tom Zanussi | 16c632d | 2009-11-25 01:15:48 -0600 | [diff] [blame] | 106 | void setup_perl_scripting(void); |
Tom Zanussi | 7e4b21b | 2010-01-27 02:27:57 -0600 | [diff] [blame] | 107 | void setup_python_scripting(void); |
Tom Zanussi | 16c632d | 2009-11-25 01:15:48 -0600 | [diff] [blame] | 108 | |
Tom Zanussi | 7397d80 | 2010-01-27 02:27:54 -0600 | [diff] [blame] | 109 | struct scripting_context { |
Tzvetomir Stoyanov (VMware) | 096177a | 2018-08-08 14:02:46 -0400 | [diff] [blame] | 110 | struct tep_handle *pevent; |
Tom Zanussi | 7397d80 | 2010-01-27 02:27:54 -0600 | [diff] [blame] | 111 | void *event_data; |
Adrian Hunter | cac3040 | 2021-05-30 22:22:58 +0300 | [diff] [blame] | 112 | union perf_event *event; |
| 113 | struct perf_sample *sample; |
| 114 | struct evsel *evsel; |
| 115 | struct addr_location *al; |
| 116 | struct addr_location *addr_al; |
Adrian Hunter | 67e50ce | 2021-05-30 22:22:59 +0300 | [diff] [blame] | 117 | struct perf_session *session; |
Tom Zanussi | 7397d80 | 2010-01-27 02:27:54 -0600 | [diff] [blame] | 118 | }; |
| 119 | |
Adrian Hunter | cac3040 | 2021-05-30 22:22:58 +0300 | [diff] [blame] | 120 | void scripting_context__update(struct scripting_context *scripting_context, |
| 121 | union perf_event *event, |
| 122 | struct perf_sample *sample, |
| 123 | struct evsel *evsel, |
| 124 | struct addr_location *al, |
| 125 | struct addr_location *addr_al); |
| 126 | |
Tom Zanussi | 7397d80 | 2010-01-27 02:27:54 -0600 | [diff] [blame] | 127 | int common_pc(struct scripting_context *context); |
| 128 | int common_flags(struct scripting_context *context); |
| 129 | int common_lock_depth(struct scripting_context *context); |
| 130 | |
Adrian Hunter | 54cd8b0 | 2021-05-25 12:51:06 +0300 | [diff] [blame] | 131 | #define SAMPLE_FLAGS_BUF_SIZE 64 |
| 132 | int perf_sample__sprintf_flags(u32 flags, char *str, size_t sz); |
| 133 | |
Steven Rostedt | 4ace73e | 2012-04-06 00:47:52 +0200 | [diff] [blame] | 134 | #endif /* _PERF_UTIL_TRACE_EVENT_H */ |