Steven Rostedt (VMware) | 4e59ab93 | 2020-07-02 14:53:58 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: LGPL-2.1 */ |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> |
| 4 | * |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 5 | */ |
| 6 | #ifndef _PARSE_EVENTS_H |
| 7 | #define _PARSE_EVENTS_H |
| 8 | |
Yoshihiro YUNOMAE | 1b372ca | 2013-11-01 17:53:53 -0400 | [diff] [blame] | 9 | #include <stdbool.h> |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 10 | #include <stdarg.h> |
Arnaldo Carvalho de Melo | 402bb4e | 2015-02-03 12:44:09 -0300 | [diff] [blame] | 11 | #include <stdio.h> |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 12 | #include <regex.h> |
Jiri Olsa | 91a058a | 2013-12-03 14:09:18 +0100 | [diff] [blame] | 13 | #include <string.h> |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 14 | |
Tzvetomir Stoyanov (VMware) | 266b851 | 2018-08-28 18:50:38 -0400 | [diff] [blame] | 15 | #include "trace-seq.h" |
| 16 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 17 | #ifndef __maybe_unused |
| 18 | #define __maybe_unused __attribute__((unused)) |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 19 | #endif |
| 20 | |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 21 | #ifndef DEBUG_RECORD |
| 22 | #define DEBUG_RECORD 0 |
| 23 | #endif |
| 24 | |
Tzvetomir Stoyanov (VMware) | cbc49b2 | 2018-08-08 14:02:47 -0400 | [diff] [blame] | 25 | struct tep_record { |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 26 | unsigned long long ts; |
| 27 | unsigned long long offset; |
| 28 | long long missed_events; /* buffer dropped events before */ |
| 29 | int record_size; /* size of binary record */ |
| 30 | int size; /* size of data */ |
| 31 | void *data; |
| 32 | int cpu; |
| 33 | int ref_count; |
| 34 | int locked; /* Do not free, even if ref_count is zero */ |
Steven Rostedt | ff1a70e | 2012-08-23 11:22:01 -0400 | [diff] [blame] | 35 | void *priv; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 36 | #if DEBUG_RECORD |
Tzvetomir Stoyanov (VMware) | cbc49b2 | 2018-08-08 14:02:47 -0400 | [diff] [blame] | 37 | struct tep_record *prev; |
| 38 | struct tep_record *next; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 39 | long alloc_addr; |
| 40 | #endif |
| 41 | }; |
| 42 | |
Tzvetomir Stoyanov (VMware) | 4963b0f | 2018-09-19 14:56:44 -0400 | [diff] [blame] | 43 | /* ----------------------- tep ----------------------- */ |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 44 | |
Tzvetomir Stoyanov (VMware) | 096177a | 2018-08-08 14:02:46 -0400 | [diff] [blame] | 45 | struct tep_handle; |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 46 | struct tep_event; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 47 | |
Tzvetomir Stoyanov (VMware) | c32d52b | 2018-08-08 14:02:48 -0400 | [diff] [blame] | 48 | typedef int (*tep_event_handler_func)(struct trace_seq *s, |
| 49 | struct tep_record *record, |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 50 | struct tep_event *event, |
Tzvetomir Stoyanov (VMware) | c32d52b | 2018-08-08 14:02:48 -0400 | [diff] [blame] | 51 | void *context); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 52 | |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 53 | typedef int (*tep_plugin_load_func)(struct tep_handle *tep); |
| 54 | typedef int (*tep_plugin_unload_func)(struct tep_handle *tep); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 55 | |
Tzvetomir Stoyanov (VMware) | c32d52b | 2018-08-08 14:02:48 -0400 | [diff] [blame] | 56 | struct tep_plugin_option { |
| 57 | struct tep_plugin_option *next; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 58 | void *handle; |
| 59 | char *file; |
| 60 | char *name; |
| 61 | char *plugin_alias; |
| 62 | char *description; |
Steven Rostedt | 5dbcfd9 | 2015-03-24 09:57:54 -0400 | [diff] [blame] | 63 | const char *value; |
Steven Rostedt | ff1a70e | 2012-08-23 11:22:01 -0400 | [diff] [blame] | 64 | void *priv; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 65 | int set; |
| 66 | }; |
| 67 | |
| 68 | /* |
| 69 | * Plugin hooks that can be called: |
| 70 | * |
Tzvetomir Stoyanov (VMware) | c32d52b | 2018-08-08 14:02:48 -0400 | [diff] [blame] | 71 | * TEP_PLUGIN_LOADER: (required) |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 72 | * The function name to initialized the plugin. |
| 73 | * |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 74 | * int TEP_PLUGIN_LOADER(struct tep_handle *tep) |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 75 | * |
Tzvetomir Stoyanov (VMware) | c32d52b | 2018-08-08 14:02:48 -0400 | [diff] [blame] | 76 | * TEP_PLUGIN_UNLOADER: (optional) |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 77 | * The function called just before unloading |
| 78 | * |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 79 | * int TEP_PLUGIN_UNLOADER(struct tep_handle *tep) |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 80 | * |
Tzvetomir Stoyanov (VMware) | c32d52b | 2018-08-08 14:02:48 -0400 | [diff] [blame] | 81 | * TEP_PLUGIN_OPTIONS: (optional) |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 82 | * Plugin options that can be set before loading |
| 83 | * |
Tzvetomir Stoyanov (VMware) | c32d52b | 2018-08-08 14:02:48 -0400 | [diff] [blame] | 84 | * struct tep_plugin_option TEP_PLUGIN_OPTIONS[] = { |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 85 | * { |
| 86 | * .name = "option-name", |
Masahiro Yamada | 505d308 | 2017-03-09 16:16:33 -0800 | [diff] [blame] | 87 | * .plugin_alias = "override-file-name", (optional) |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 88 | * .description = "description of option to show users", |
| 89 | * }, |
| 90 | * { |
| 91 | * .name = NULL, |
| 92 | * }, |
| 93 | * }; |
| 94 | * |
| 95 | * Array must end with .name = NULL; |
| 96 | * |
| 97 | * |
| 98 | * .plugin_alias is used to give a shorter name to access |
| 99 | * the vairable. Useful if a plugin handles more than one event. |
| 100 | * |
Steven Rostedt | 5dbcfd9 | 2015-03-24 09:57:54 -0400 | [diff] [blame] | 101 | * If .value is not set, then it is considered a boolean and only |
| 102 | * .set will be processed. If .value is defined, then it is considered |
| 103 | * a string option and .set will be ignored. |
| 104 | * |
Tzvetomir Stoyanov (VMware) | c32d52b | 2018-08-08 14:02:48 -0400 | [diff] [blame] | 105 | * TEP_PLUGIN_ALIAS: (optional) |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 106 | * The name to use for finding options (uses filename if not defined) |
| 107 | */ |
Tzvetomir Stoyanov (VMware) | c32d52b | 2018-08-08 14:02:48 -0400 | [diff] [blame] | 108 | #define TEP_PLUGIN_LOADER tep_plugin_loader |
| 109 | #define TEP_PLUGIN_UNLOADER tep_plugin_unloader |
| 110 | #define TEP_PLUGIN_OPTIONS tep_plugin_options |
| 111 | #define TEP_PLUGIN_ALIAS tep_plugin_alias |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 112 | #define _MAKE_STR(x) #x |
| 113 | #define MAKE_STR(x) _MAKE_STR(x) |
Tzvetomir Stoyanov (VMware) | c32d52b | 2018-08-08 14:02:48 -0400 | [diff] [blame] | 114 | #define TEP_PLUGIN_LOADER_NAME MAKE_STR(TEP_PLUGIN_LOADER) |
| 115 | #define TEP_PLUGIN_UNLOADER_NAME MAKE_STR(TEP_PLUGIN_UNLOADER) |
| 116 | #define TEP_PLUGIN_OPTIONS_NAME MAKE_STR(TEP_PLUGIN_OPTIONS) |
| 117 | #define TEP_PLUGIN_ALIAS_NAME MAKE_STR(TEP_PLUGIN_ALIAS) |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 118 | |
Tzvetomir Stoyanov (VMware) | bb39ccb | 2018-09-19 14:56:46 -0400 | [diff] [blame] | 119 | enum tep_format_flags { |
| 120 | TEP_FIELD_IS_ARRAY = 1, |
| 121 | TEP_FIELD_IS_POINTER = 2, |
| 122 | TEP_FIELD_IS_SIGNED = 4, |
| 123 | TEP_FIELD_IS_STRING = 8, |
| 124 | TEP_FIELD_IS_DYNAMIC = 16, |
| 125 | TEP_FIELD_IS_LONG = 32, |
| 126 | TEP_FIELD_IS_FLAG = 64, |
| 127 | TEP_FIELD_IS_SYMBOLIC = 128, |
Masami Hiramatsu | cd77290 | 2021-11-22 18:30:40 +0900 | [diff] [blame] | 128 | TEP_FIELD_IS_RELATIVE = 256, |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 129 | }; |
| 130 | |
Tzvetomir Stoyanov (VMware) | 2c92f98 | 2018-09-19 14:56:45 -0400 | [diff] [blame] | 131 | struct tep_format_field { |
| 132 | struct tep_format_field *next; |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 133 | struct tep_event *event; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 134 | char *type; |
| 135 | char *name; |
Jiri Olsa | d354243 | 2015-04-18 17:50:18 +0200 | [diff] [blame] | 136 | char *alias; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 137 | int offset; |
| 138 | int size; |
| 139 | unsigned int arraylen; |
| 140 | unsigned int elementsize; |
| 141 | unsigned long flags; |
| 142 | }; |
| 143 | |
Tzvetomir Stoyanov (VMware) | 2c92f98 | 2018-09-19 14:56:45 -0400 | [diff] [blame] | 144 | struct tep_format { |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 145 | int nr_common; |
| 146 | int nr_fields; |
Tzvetomir Stoyanov (VMware) | 2c92f98 | 2018-09-19 14:56:45 -0400 | [diff] [blame] | 147 | struct tep_format_field *common_fields; |
| 148 | struct tep_format_field *fields; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 149 | }; |
| 150 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 151 | struct tep_print_arg_atom { |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 152 | char *atom; |
| 153 | }; |
| 154 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 155 | struct tep_print_arg_string { |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 156 | char *string; |
Masami Hiramatsu | cd77290 | 2021-11-22 18:30:40 +0900 | [diff] [blame] | 157 | struct tep_format_field *field; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 158 | }; |
| 159 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 160 | struct tep_print_arg_bitmask { |
Steven Rostedt (Red Hat) | 473a778 | 2014-06-02 23:20:16 -0400 | [diff] [blame] | 161 | char *bitmask; |
Masami Hiramatsu | cd77290 | 2021-11-22 18:30:40 +0900 | [diff] [blame] | 162 | struct tep_format_field *field; |
Steven Rostedt (Red Hat) | 473a778 | 2014-06-02 23:20:16 -0400 | [diff] [blame] | 163 | }; |
| 164 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 165 | struct tep_print_arg_field { |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 166 | char *name; |
Tzvetomir Stoyanov (VMware) | 2c92f98 | 2018-09-19 14:56:45 -0400 | [diff] [blame] | 167 | struct tep_format_field *field; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 168 | }; |
| 169 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 170 | struct tep_print_flag_sym { |
| 171 | struct tep_print_flag_sym *next; |
| 172 | char *value; |
| 173 | char *str; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 174 | }; |
| 175 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 176 | struct tep_print_arg_typecast { |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 177 | char *type; |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 178 | struct tep_print_arg *item; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 179 | }; |
| 180 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 181 | struct tep_print_arg_flags { |
| 182 | struct tep_print_arg *field; |
| 183 | char *delim; |
| 184 | struct tep_print_flag_sym *flags; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 185 | }; |
| 186 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 187 | struct tep_print_arg_symbol { |
| 188 | struct tep_print_arg *field; |
| 189 | struct tep_print_flag_sym *symbols; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 190 | }; |
| 191 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 192 | struct tep_print_arg_hex { |
| 193 | struct tep_print_arg *field; |
| 194 | struct tep_print_arg *size; |
Namhyung Kim | e080e6f | 2012-06-27 09:41:41 +0900 | [diff] [blame] | 195 | }; |
| 196 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 197 | struct tep_print_arg_int_array { |
| 198 | struct tep_print_arg *field; |
| 199 | struct tep_print_arg *count; |
| 200 | struct tep_print_arg *el_size; |
Javi Merino | b839e1e8 | 2015-03-24 11:07:19 +0000 | [diff] [blame] | 201 | }; |
| 202 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 203 | struct tep_print_arg_dynarray { |
Tzvetomir Stoyanov (VMware) | 2c92f98 | 2018-09-19 14:56:45 -0400 | [diff] [blame] | 204 | struct tep_format_field *field; |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 205 | struct tep_print_arg *index; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 206 | }; |
| 207 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 208 | struct tep_print_arg; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 209 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 210 | struct tep_print_arg_op { |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 211 | char *op; |
| 212 | int prio; |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 213 | struct tep_print_arg *left; |
| 214 | struct tep_print_arg *right; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 215 | }; |
| 216 | |
Tzvetomir Stoyanov (VMware) | 3cf4778 | 2018-08-08 14:02:59 -0400 | [diff] [blame] | 217 | struct tep_function_handler; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 218 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 219 | struct tep_print_arg_func { |
Tzvetomir Stoyanov (VMware) | 3cf4778 | 2018-08-08 14:02:59 -0400 | [diff] [blame] | 220 | struct tep_function_handler *func; |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 221 | struct tep_print_arg *args; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 222 | }; |
| 223 | |
Tzvetomir Stoyanov (VMware) | 1e97216f | 2018-09-19 14:56:50 -0400 | [diff] [blame] | 224 | enum tep_print_arg_type { |
| 225 | TEP_PRINT_NULL, |
| 226 | TEP_PRINT_ATOM, |
| 227 | TEP_PRINT_FIELD, |
| 228 | TEP_PRINT_FLAGS, |
| 229 | TEP_PRINT_SYMBOL, |
| 230 | TEP_PRINT_HEX, |
| 231 | TEP_PRINT_INT_ARRAY, |
| 232 | TEP_PRINT_TYPE, |
| 233 | TEP_PRINT_STRING, |
| 234 | TEP_PRINT_BSTRING, |
| 235 | TEP_PRINT_DYNAMIC_ARRAY, |
| 236 | TEP_PRINT_OP, |
| 237 | TEP_PRINT_FUNC, |
| 238 | TEP_PRINT_BITMASK, |
| 239 | TEP_PRINT_DYNAMIC_ARRAY_LEN, |
| 240 | TEP_PRINT_HEX_STR, |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 241 | }; |
| 242 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 243 | struct tep_print_arg { |
| 244 | struct tep_print_arg *next; |
Tzvetomir Stoyanov (VMware) | 1e97216f | 2018-09-19 14:56:50 -0400 | [diff] [blame] | 245 | enum tep_print_arg_type type; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 246 | union { |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 247 | struct tep_print_arg_atom atom; |
| 248 | struct tep_print_arg_field field; |
| 249 | struct tep_print_arg_typecast typecast; |
| 250 | struct tep_print_arg_flags flags; |
| 251 | struct tep_print_arg_symbol symbol; |
| 252 | struct tep_print_arg_hex hex; |
| 253 | struct tep_print_arg_int_array int_array; |
| 254 | struct tep_print_arg_func func; |
| 255 | struct tep_print_arg_string string; |
| 256 | struct tep_print_arg_bitmask bitmask; |
| 257 | struct tep_print_arg_op op; |
| 258 | struct tep_print_arg_dynarray dynarray; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 259 | }; |
| 260 | }; |
| 261 | |
Tzvetomir Stoyanov (VMware) | e7a9088 | 2020-07-02 14:53:51 -0400 | [diff] [blame] | 262 | struct tep_print_parse; |
| 263 | |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 264 | struct tep_print_fmt { |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 265 | char *format; |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 266 | struct tep_print_arg *args; |
Tzvetomir Stoyanov (VMware) | e7a9088 | 2020-07-02 14:53:51 -0400 | [diff] [blame] | 267 | struct tep_print_parse *print_cache; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 268 | }; |
| 269 | |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 270 | struct tep_event { |
Tzvetomir Stoyanov | 69769ce | 2019-04-01 12:43:18 -0400 | [diff] [blame] | 271 | struct tep_handle *tep; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 272 | char *name; |
| 273 | int id; |
| 274 | int flags; |
Tzvetomir Stoyanov (VMware) | 2c92f98 | 2018-09-19 14:56:45 -0400 | [diff] [blame] | 275 | struct tep_format format; |
Tzvetomir Stoyanov (VMware) | 5647f94 | 2018-09-19 14:56:49 -0400 | [diff] [blame] | 276 | struct tep_print_fmt print_fmt; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 277 | char *system; |
Tzvetomir Stoyanov (VMware) | c32d52b | 2018-08-08 14:02:48 -0400 | [diff] [blame] | 278 | tep_event_handler_func handler; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 279 | void *context; |
| 280 | }; |
| 281 | |
| 282 | enum { |
Tzvetomir Stoyanov (VMware) | c1953bc | 2018-09-19 14:56:48 -0400 | [diff] [blame] | 283 | TEP_EVENT_FL_ISFTRACE = 0x01, |
| 284 | TEP_EVENT_FL_ISPRINT = 0x02, |
| 285 | TEP_EVENT_FL_ISBPRINT = 0x04, |
| 286 | TEP_EVENT_FL_ISFUNCENT = 0x10, |
| 287 | TEP_EVENT_FL_ISFUNCRET = 0x20, |
| 288 | TEP_EVENT_FL_NOHANDLE = 0x40, |
| 289 | TEP_EVENT_FL_PRINTRAW = 0x80, |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 290 | |
Tzvetomir Stoyanov (VMware) | c1953bc | 2018-09-19 14:56:48 -0400 | [diff] [blame] | 291 | TEP_EVENT_FL_FAILED = 0x80000000 |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 292 | }; |
| 293 | |
Tzvetomir Stoyanov (VMware) | f25d9e0 | 2018-09-19 14:56:47 -0400 | [diff] [blame] | 294 | enum tep_event_sort_type { |
| 295 | TEP_EVENT_SORT_ID, |
| 296 | TEP_EVENT_SORT_NAME, |
| 297 | TEP_EVENT_SORT_SYSTEM, |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 298 | }; |
| 299 | |
Tzvetomir Stoyanov (VMware) | f25d9e0 | 2018-09-19 14:56:47 -0400 | [diff] [blame] | 300 | enum tep_event_type { |
| 301 | TEP_EVENT_ERROR, |
| 302 | TEP_EVENT_NONE, |
| 303 | TEP_EVENT_SPACE, |
| 304 | TEP_EVENT_NEWLINE, |
| 305 | TEP_EVENT_OP, |
| 306 | TEP_EVENT_DELIM, |
| 307 | TEP_EVENT_ITEM, |
| 308 | TEP_EVENT_DQUOTE, |
| 309 | TEP_EVENT_SQUOTE, |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 310 | }; |
| 311 | |
Tzvetomir Stoyanov (VMware) | 3cf4778 | 2018-08-08 14:02:59 -0400 | [diff] [blame] | 312 | typedef unsigned long long (*tep_func_handler)(struct trace_seq *s, |
| 313 | unsigned long long *args); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 314 | |
Tzvetomir Stoyanov (VMware) | 3cf4778 | 2018-08-08 14:02:59 -0400 | [diff] [blame] | 315 | enum tep_func_arg_type { |
| 316 | TEP_FUNC_ARG_VOID, |
| 317 | TEP_FUNC_ARG_INT, |
| 318 | TEP_FUNC_ARG_LONG, |
| 319 | TEP_FUNC_ARG_STRING, |
| 320 | TEP_FUNC_ARG_PTR, |
| 321 | TEP_FUNC_ARG_MAX_TYPES |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 322 | }; |
| 323 | |
Tzvetomir Stoyanov (VMware) | 6fed932 | 2018-08-08 14:02:57 -0400 | [diff] [blame] | 324 | enum tep_flag { |
| 325 | TEP_NSEC_OUTPUT = 1, /* output in NSECS */ |
| 326 | TEP_DISABLE_SYS_PLUGINS = 1 << 1, |
| 327 | TEP_DISABLE_PLUGINS = 1 << 2, |
Steven Rostedt | 4dc1024 | 2012-04-06 00:47:57 +0200 | [diff] [blame] | 328 | }; |
| 329 | |
Tzvetomir Stoyanov (VMware) | d97f4ef | 2018-08-08 14:02:58 -0400 | [diff] [blame] | 330 | #define TEP_ERRORS \ |
Namhyung Kim | 2f197b9 | 2012-08-22 16:00:30 +0900 | [diff] [blame] | 331 | _PE(MEM_ALLOC_FAILED, "failed to allocate memory"), \ |
| 332 | _PE(PARSE_EVENT_FAILED, "failed to parse event"), \ |
| 333 | _PE(READ_ID_FAILED, "failed to read event id"), \ |
| 334 | _PE(READ_FORMAT_FAILED, "failed to read event format"), \ |
| 335 | _PE(READ_PRINT_FAILED, "failed to read event print fmt"), \ |
Namhyung Kim | 67ed939 | 2012-09-07 11:49:47 +0900 | [diff] [blame] | 336 | _PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace"),\ |
Namhyung Kim | 605b8fd | 2013-12-12 16:36:08 +0900 | [diff] [blame] | 337 | _PE(INVALID_ARG_TYPE, "invalid argument type"), \ |
Namhyung Kim | 41e12e5 | 2013-12-12 16:36:15 +0900 | [diff] [blame] | 338 | _PE(INVALID_EXP_TYPE, "invalid expression type"), \ |
| 339 | _PE(INVALID_OP_TYPE, "invalid operator type"), \ |
Namhyung Kim | 605b8fd | 2013-12-12 16:36:08 +0900 | [diff] [blame] | 340 | _PE(INVALID_EVENT_NAME, "invalid event name"), \ |
Namhyung Kim | 02d62d6 | 2013-12-12 16:36:09 +0900 | [diff] [blame] | 341 | _PE(EVENT_NOT_FOUND, "no event found"), \ |
| 342 | _PE(SYNTAX_ERROR, "syntax error"), \ |
| 343 | _PE(ILLEGAL_RVALUE, "illegal rvalue"), \ |
| 344 | _PE(ILLEGAL_LVALUE, "illegal lvalue for string comparison"), \ |
| 345 | _PE(INVALID_REGEX, "regex did not compute"), \ |
| 346 | _PE(ILLEGAL_STRING_CMP, "illegal comparison for string"), \ |
Namhyung Kim | 7bb7355 | 2013-12-12 16:36:11 +0900 | [diff] [blame] | 347 | _PE(ILLEGAL_INTEGER_CMP,"illegal comparison for integer"), \ |
| 348 | _PE(REPARENT_NOT_OP, "cannot reparent other than OP"), \ |
| 349 | _PE(REPARENT_FAILED, "failed to reparent filter OP"), \ |
Namhyung Kim | c8ea690 | 2013-12-12 16:36:12 +0900 | [diff] [blame] | 350 | _PE(BAD_FILTER_ARG, "bad arg in filter tree"), \ |
Namhyung Kim | 42d6194 | 2013-12-12 16:36:13 +0900 | [diff] [blame] | 351 | _PE(UNEXPECTED_TYPE, "unexpected type (not a value)"), \ |
| 352 | _PE(ILLEGAL_TOKEN, "illegal token"), \ |
| 353 | _PE(INVALID_PAREN, "open parenthesis cannot come here"), \ |
| 354 | _PE(UNBALANCED_PAREN, "unbalanced number of parenthesis"), \ |
Namhyung Kim | 69c770a | 2013-12-12 16:36:14 +0900 | [diff] [blame] | 355 | _PE(UNKNOWN_TOKEN, "unknown token"), \ |
Namhyung Kim | 41e12e5 | 2013-12-12 16:36:15 +0900 | [diff] [blame] | 356 | _PE(FILTER_NOT_FOUND, "no filter found"), \ |
| 357 | _PE(NOT_A_NUMBER, "must have number field"), \ |
| 358 | _PE(NO_FILTER, "no filters exists"), \ |
| 359 | _PE(FILTER_MISS, "record does not match to filter") |
Namhyung Kim | 2f197b9 | 2012-08-22 16:00:30 +0900 | [diff] [blame] | 360 | |
| 361 | #undef _PE |
Tzvetomir Stoyanov (VMware) | d97f4ef | 2018-08-08 14:02:58 -0400 | [diff] [blame] | 362 | #define _PE(__code, __str) TEP_ERRNO__ ## __code |
| 363 | enum tep_errno { |
| 364 | TEP_ERRNO__SUCCESS = 0, |
| 365 | TEP_ERRNO__FILTER_MATCH = TEP_ERRNO__SUCCESS, |
Namhyung Kim | bffddff | 2012-08-22 16:00:29 +0900 | [diff] [blame] | 366 | |
| 367 | /* |
| 368 | * Choose an arbitrary negative big number not to clash with standard |
| 369 | * errno since SUS requires the errno has distinct positive values. |
| 370 | * See 'Issue 6' in the link below. |
| 371 | * |
Alexander A. Klimov | 79e3ea5 | 2020-08-06 23:17:22 -0700 | [diff] [blame] | 372 | * https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html |
Namhyung Kim | bffddff | 2012-08-22 16:00:29 +0900 | [diff] [blame] | 373 | */ |
Tzvetomir Stoyanov (VMware) | d97f4ef | 2018-08-08 14:02:58 -0400 | [diff] [blame] | 374 | __TEP_ERRNO__START = -100000, |
Namhyung Kim | bffddff | 2012-08-22 16:00:29 +0900 | [diff] [blame] | 375 | |
Tzvetomir Stoyanov (VMware) | d97f4ef | 2018-08-08 14:02:58 -0400 | [diff] [blame] | 376 | TEP_ERRORS, |
Namhyung Kim | bffddff | 2012-08-22 16:00:29 +0900 | [diff] [blame] | 377 | |
Tzvetomir Stoyanov (VMware) | d97f4ef | 2018-08-08 14:02:58 -0400 | [diff] [blame] | 378 | __TEP_ERRNO__END, |
Namhyung Kim | bffddff | 2012-08-22 16:00:29 +0900 | [diff] [blame] | 379 | }; |
Namhyung Kim | 2f197b9 | 2012-08-22 16:00:30 +0900 | [diff] [blame] | 380 | #undef _PE |
Namhyung Kim | bffddff | 2012-08-22 16:00:29 +0900 | [diff] [blame] | 381 | |
Tzvetomir Stoyanov (VMware) | 785be0c | 2018-09-19 14:56:56 -0400 | [diff] [blame] | 382 | struct tep_plugin_list; |
Jiri Olsa | c877bbd | 2013-12-03 14:09:16 +0100 | [diff] [blame] | 383 | |
Steven Rostedt | 5827f2f | 2014-06-03 18:41:54 -0400 | [diff] [blame] | 384 | #define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1)) |
| 385 | |
Tzvetomir Stoyanov (VMware) | 4d70cae | 2020-07-02 14:53:49 -0400 | [diff] [blame] | 386 | enum tep_plugin_load_priority { |
| 387 | TEP_PLUGIN_FIRST, |
| 388 | TEP_PLUGIN_LAST, |
| 389 | }; |
| 390 | |
| 391 | int tep_add_plugin_path(struct tep_handle *tep, char *path, |
| 392 | enum tep_plugin_load_priority prio); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 393 | struct tep_plugin_list *tep_load_plugins(struct tep_handle *tep); |
Tzvetomir Stoyanov (VMware) | 785be0c | 2018-09-19 14:56:56 -0400 | [diff] [blame] | 394 | void tep_unload_plugins(struct tep_plugin_list *plugin_list, |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 395 | struct tep_handle *tep); |
Tzvetomir Stoyanov (VMware) | 662081a | 2020-07-02 14:53:47 -0400 | [diff] [blame] | 396 | void tep_load_plugins_hook(struct tep_handle *tep, const char *suffix, |
| 397 | void (*load_plugin)(struct tep_handle *tep, |
| 398 | const char *path, |
| 399 | const char *name, |
| 400 | void *data), |
| 401 | void *data); |
Tzvetomir Stoyanov (VMware) | ca2921d | 2018-08-08 14:03:00 -0400 | [diff] [blame] | 402 | char **tep_plugin_list_options(void); |
| 403 | void tep_plugin_free_options_list(char **list); |
| 404 | int tep_plugin_add_options(const char *name, |
| 405 | struct tep_plugin_option *options); |
Tzvetomir Stoyanov (VMware) | 7400628 | 2020-07-02 14:53:48 -0400 | [diff] [blame] | 406 | int tep_plugin_add_option(const char *name, const char *val); |
Tzvetomir Stoyanov (VMware) | ca2921d | 2018-08-08 14:03:00 -0400 | [diff] [blame] | 407 | void tep_plugin_remove_options(struct tep_plugin_option *options); |
Tzvetomir Stoyanov (VMware) | 7400628 | 2020-07-02 14:53:48 -0400 | [diff] [blame] | 408 | void tep_plugin_print_options(struct trace_seq *s); |
Tzvetomir Stoyanov (VMware) | ca2921d | 2018-08-08 14:03:00 -0400 | [diff] [blame] | 409 | void tep_print_plugins(struct trace_seq *s, |
| 410 | const char *prefix, const char *suffix, |
Tzvetomir Stoyanov (VMware) | 785be0c | 2018-09-19 14:56:56 -0400 | [diff] [blame] | 411 | const struct tep_plugin_list *list); |
Jiri Olsa | c877bbd | 2013-12-03 14:09:16 +0100 | [diff] [blame] | 412 | |
Tzvetomir Stoyanov | bb3dd7e | 2018-10-05 12:22:25 -0400 | [diff] [blame] | 413 | /* tep_handle */ |
Tzvetomir Stoyanov (VMware) | 4d5c58b | 2018-08-08 14:02:49 -0400 | [diff] [blame] | 414 | typedef char *(tep_func_resolver_t)(void *priv, |
| 415 | unsigned long long *addrp, char **modp); |
Tzvetomir Stoyanov | bb3dd7e | 2018-10-05 12:22:25 -0400 | [diff] [blame] | 416 | void tep_set_flag(struct tep_handle *tep, int flag); |
Tzvetomir Stoyanov | 80c5526 | 2019-04-01 12:43:12 -0400 | [diff] [blame] | 417 | void tep_clear_flag(struct tep_handle *tep, enum tep_flag flag); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 418 | bool tep_test_flag(struct tep_handle *tep, enum tep_flag flags); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 419 | |
Tzvetomir Stoyanov | 55c34ae | 2019-04-01 12:43:16 -0400 | [diff] [blame] | 420 | static inline int tep_is_bigendian(void) |
Jiri Olsa | 91a058a | 2013-12-03 14:09:18 +0100 | [diff] [blame] | 421 | { |
| 422 | unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 }; |
| 423 | unsigned int val; |
| 424 | |
| 425 | memcpy(&val, str, 4); |
| 426 | return val == 0x01020304; |
| 427 | } |
| 428 | |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 429 | /* taken from kernel/trace/trace.h */ |
| 430 | enum trace_flag_type { |
| 431 | TRACE_FLAG_IRQS_OFF = 0x01, |
| 432 | TRACE_FLAG_IRQS_NOSUPPORT = 0x02, |
| 433 | TRACE_FLAG_NEED_RESCHED = 0x04, |
| 434 | TRACE_FLAG_HARDIRQ = 0x08, |
| 435 | TRACE_FLAG_SOFTIRQ = 0x10, |
| 436 | }; |
| 437 | |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 438 | int tep_set_function_resolver(struct tep_handle *tep, |
Tzvetomir Stoyanov (VMware) | ece2a4f | 2018-08-08 14:02:55 -0400 | [diff] [blame] | 439 | tep_func_resolver_t *func, void *priv); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 440 | void tep_reset_function_resolver(struct tep_handle *tep); |
| 441 | int tep_register_comm(struct tep_handle *tep, const char *comm, int pid); |
| 442 | int tep_override_comm(struct tep_handle *tep, const char *comm, int pid); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 443 | int tep_register_function(struct tep_handle *tep, char *name, |
Tzvetomir Stoyanov (VMware) | b843e9c | 2018-08-08 14:03:02 -0400 | [diff] [blame] | 444 | unsigned long long addr, char *mod); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 445 | int tep_register_print_string(struct tep_handle *tep, const char *fmt, |
Tzvetomir Stoyanov (VMware) | 13a4189 | 2018-08-08 14:02:54 -0400 | [diff] [blame] | 446 | unsigned long long addr); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 447 | bool tep_is_pid_registered(struct tep_handle *tep, int pid); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 448 | |
Tzvetomir Stoyanov (VMware) | d69094f | 2019-09-19 17:23:39 -0400 | [diff] [blame] | 449 | struct tep_event *tep_get_event(struct tep_handle *tep, int index); |
| 450 | |
Tzvetomir Stoyanov | 38847db | 2019-08-05 16:43:13 -0400 | [diff] [blame] | 451 | #define TEP_PRINT_INFO "INFO" |
| 452 | #define TEP_PRINT_INFO_RAW "INFO_RAW" |
| 453 | #define TEP_PRINT_COMM "COMM" |
| 454 | #define TEP_PRINT_LATENCY "LATENCY" |
| 455 | #define TEP_PRINT_NAME "NAME" |
| 456 | #define TEP_PRINT_PID 1U |
| 457 | #define TEP_PRINT_TIME 2U |
| 458 | #define TEP_PRINT_CPU 3U |
| 459 | |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 460 | void tep_print_event(struct tep_handle *tep, struct trace_seq *s, |
Tzvetomir Stoyanov | 38847db | 2019-08-05 16:43:13 -0400 | [diff] [blame] | 461 | struct tep_record *record, const char *fmt, ...) |
| 462 | __attribute__ ((format (printf, 4, 5))); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 463 | |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 464 | int tep_parse_header_page(struct tep_handle *tep, char *buf, unsigned long size, |
Tzvetomir Stoyanov (VMware) | c60167c | 2018-08-08 14:02:51 -0400 | [diff] [blame] | 465 | int long_size); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 466 | |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 467 | enum tep_errno tep_parse_event(struct tep_handle *tep, const char *buf, |
Tzvetomir Stoyanov (VMware) | d97f4ef | 2018-08-08 14:02:58 -0400 | [diff] [blame] | 468 | unsigned long size, const char *sys); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 469 | enum tep_errno tep_parse_format(struct tep_handle *tep, |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 470 | struct tep_event **eventp, |
Tzvetomir Stoyanov (VMware) | d97f4ef | 2018-08-08 14:02:58 -0400 | [diff] [blame] | 471 | const char *buf, |
| 472 | unsigned long size, const char *sys); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 473 | |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 474 | void *tep_get_field_raw(struct trace_seq *s, struct tep_event *event, |
Tzvetomir Stoyanov (VMware) | 8b3e087 | 2018-08-08 14:03:04 -0400 | [diff] [blame] | 475 | const char *name, struct tep_record *record, |
| 476 | int *len, int err); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 477 | |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 478 | int tep_get_field_val(struct trace_seq *s, struct tep_event *event, |
Tzvetomir Stoyanov (VMware) | 8b3e087 | 2018-08-08 14:03:04 -0400 | [diff] [blame] | 479 | const char *name, struct tep_record *record, |
| 480 | unsigned long long *val, int err); |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 481 | int tep_get_common_field_val(struct trace_seq *s, struct tep_event *event, |
Tzvetomir Stoyanov (VMware) | cbc49b2 | 2018-08-08 14:02:47 -0400 | [diff] [blame] | 482 | const char *name, struct tep_record *record, |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 483 | unsigned long long *val, int err); |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 484 | int tep_get_any_field_val(struct trace_seq *s, struct tep_event *event, |
Tzvetomir Stoyanov (VMware) | 8b3e087 | 2018-08-08 14:03:04 -0400 | [diff] [blame] | 485 | const char *name, struct tep_record *record, |
| 486 | unsigned long long *val, int err); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 487 | |
Tzvetomir Stoyanov (VMware) | 6a48dc2 | 2018-08-08 14:02:52 -0400 | [diff] [blame] | 488 | int tep_print_num_field(struct trace_seq *s, const char *fmt, |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 489 | struct tep_event *event, const char *name, |
Tzvetomir Stoyanov (VMware) | 4963b0f | 2018-09-19 14:56:44 -0400 | [diff] [blame] | 490 | struct tep_record *record, int err); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 491 | |
Tzvetomir Stoyanov (VMware) | 6a48dc2 | 2018-08-08 14:02:52 -0400 | [diff] [blame] | 492 | int tep_print_func_field(struct trace_seq *s, const char *fmt, |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 493 | struct tep_event *event, const char *name, |
Tzvetomir Stoyanov (VMware) | 6a48dc2 | 2018-08-08 14:02:52 -0400 | [diff] [blame] | 494 | struct tep_record *record, int err); |
Steven Rostedt | 6d862b8 | 2013-11-01 17:54:00 -0400 | [diff] [blame] | 495 | |
Tzvetomir Stoyanov | f87ce7c | 2018-11-30 23:08:11 -0500 | [diff] [blame] | 496 | enum tep_reg_handler { |
| 497 | TEP_REGISTER_SUCCESS = 0, |
| 498 | TEP_REGISTER_SUCCESS_OVERWRITE, |
| 499 | }; |
| 500 | |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 501 | int tep_register_event_handler(struct tep_handle *tep, int id, |
Tzvetomir Stoyanov (VMware) | b843e9c | 2018-08-08 14:03:02 -0400 | [diff] [blame] | 502 | const char *sys_name, const char *event_name, |
| 503 | tep_event_handler_func func, void *context); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 504 | int tep_unregister_event_handler(struct tep_handle *tep, int id, |
Tzvetomir Stoyanov (VMware) | b843e9c | 2018-08-08 14:03:02 -0400 | [diff] [blame] | 505 | const char *sys_name, const char *event_name, |
| 506 | tep_event_handler_func func, void *context); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 507 | int tep_register_print_function(struct tep_handle *tep, |
Tzvetomir Stoyanov (VMware) | b843e9c | 2018-08-08 14:03:02 -0400 | [diff] [blame] | 508 | tep_func_handler func, |
| 509 | enum tep_func_arg_type ret_type, |
| 510 | char *name, ...); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 511 | int tep_unregister_print_function(struct tep_handle *tep, |
Tzvetomir Stoyanov (VMware) | b843e9c | 2018-08-08 14:03:02 -0400 | [diff] [blame] | 512 | tep_func_handler func, char *name); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 513 | |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 514 | struct tep_format_field *tep_find_common_field(struct tep_event *event, const char *name); |
| 515 | struct tep_format_field *tep_find_field(struct tep_event *event, const char *name); |
| 516 | struct tep_format_field *tep_find_any_field(struct tep_event *event, const char *name); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 517 | |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 518 | const char *tep_find_function(struct tep_handle *tep, unsigned long long addr); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 519 | unsigned long long |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 520 | tep_find_function_address(struct tep_handle *tep, unsigned long long addr); |
| 521 | unsigned long long tep_read_number(struct tep_handle *tep, const void *ptr, int size); |
Tzvetomir Stoyanov (VMware) | 2c92f98 | 2018-09-19 14:56:45 -0400 | [diff] [blame] | 522 | int tep_read_number_field(struct tep_format_field *field, const void *data, |
Tzvetomir Stoyanov (VMware) | 59c1bae | 2018-08-08 14:02:53 -0400 | [diff] [blame] | 523 | unsigned long long *value); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 524 | |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 525 | struct tep_event *tep_get_first_event(struct tep_handle *tep); |
Tzvetomir Stoyanov | bb3dd7e | 2018-10-05 12:22:25 -0400 | [diff] [blame] | 526 | int tep_get_events_count(struct tep_handle *tep); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 527 | struct tep_event *tep_find_event(struct tep_handle *tep, int id); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 528 | |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 529 | struct tep_event * |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 530 | tep_find_event_by_name(struct tep_handle *tep, const char *sys, const char *name); |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 531 | struct tep_event * |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 532 | tep_find_event_by_record(struct tep_handle *tep, struct tep_record *record); |
Steven Rostedt | a674533 | 2016-02-29 09:01:28 -0500 | [diff] [blame] | 533 | |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 534 | int tep_data_type(struct tep_handle *tep, struct tep_record *rec); |
| 535 | int tep_data_pid(struct tep_handle *tep, struct tep_record *rec); |
| 536 | int tep_data_preempt_count(struct tep_handle *tep, struct tep_record *rec); |
| 537 | int tep_data_flags(struct tep_handle *tep, struct tep_record *rec); |
| 538 | const char *tep_data_comm_from_pid(struct tep_handle *tep, int pid); |
Tzvetomir Stoyanov | 2e4318a | 2018-11-30 23:08:09 -0500 | [diff] [blame] | 539 | struct tep_cmdline; |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 540 | struct tep_cmdline *tep_data_pid_from_comm(struct tep_handle *tep, const char *comm, |
Tzvetomir Stoyanov | 2e4318a | 2018-11-30 23:08:09 -0500 | [diff] [blame] | 541 | struct tep_cmdline *next); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 542 | int tep_cmdline_pid(struct tep_handle *tep, struct tep_cmdline *cmdline); |
Steven Rostedt (Red Hat) | 2771984 | 2015-03-24 09:57:52 -0400 | [diff] [blame] | 543 | |
Tzvetomir Stoyanov (VMware) | 6a48dc2 | 2018-08-08 14:02:52 -0400 | [diff] [blame] | 544 | void tep_print_field(struct trace_seq *s, void *data, |
Tzvetomir Stoyanov (VMware) | 2c92f98 | 2018-09-19 14:56:45 -0400 | [diff] [blame] | 545 | struct tep_format_field *field); |
Tzvetomir Stoyanov (VMware) | 6a48dc2 | 2018-08-08 14:02:52 -0400 | [diff] [blame] | 546 | void tep_print_fields(struct trace_seq *s, void *data, |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 547 | int size __maybe_unused, struct tep_event *event); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 548 | int tep_strerror(struct tep_handle *tep, enum tep_errno errnum, |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 549 | char *buf, size_t buflen); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 550 | |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 551 | struct tep_event **tep_list_events(struct tep_handle *tep, enum tep_event_sort_type); |
Tzvetomir Stoyanov | 6699ed7 | 2019-04-01 12:43:08 -0400 | [diff] [blame] | 552 | struct tep_event **tep_list_events_copy(struct tep_handle *tep, |
| 553 | enum tep_event_sort_type); |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 554 | struct tep_format_field **tep_event_common_fields(struct tep_event *event); |
| 555 | struct tep_format_field **tep_event_fields(struct tep_event *event); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 556 | |
Tzvetomir Stoyanov | bb3dd7e | 2018-10-05 12:22:25 -0400 | [diff] [blame] | 557 | enum tep_endian { |
| 558 | TEP_LITTLE_ENDIAN = 0, |
| 559 | TEP_BIG_ENDIAN |
| 560 | }; |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 561 | int tep_get_cpus(struct tep_handle *tep); |
| 562 | void tep_set_cpus(struct tep_handle *tep, int cpus); |
| 563 | int tep_get_long_size(struct tep_handle *tep); |
| 564 | void tep_set_long_size(struct tep_handle *tep, int long_size); |
| 565 | int tep_get_page_size(struct tep_handle *tep); |
| 566 | void tep_set_page_size(struct tep_handle *tep, int _page_size); |
| 567 | bool tep_is_file_bigendian(struct tep_handle *tep); |
| 568 | void tep_set_file_bigendian(struct tep_handle *tep, enum tep_endian endian); |
| 569 | bool tep_is_local_bigendian(struct tep_handle *tep); |
| 570 | void tep_set_local_bigendian(struct tep_handle *tep, enum tep_endian endian); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 571 | int tep_get_header_page_size(struct tep_handle *tep); |
Tzvetomir Stoyanov | 80c5526 | 2019-04-01 12:43:12 -0400 | [diff] [blame] | 572 | int tep_get_header_timestamp_size(struct tep_handle *tep); |
| 573 | bool tep_is_old_format(struct tep_handle *tep); |
Tzvetomir Stoyanov | 80c5526 | 2019-04-01 12:43:12 -0400 | [diff] [blame] | 574 | void tep_set_test_filters(struct tep_handle *tep, int test_filters); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 575 | |
Tzvetomir Stoyanov (VMware) | 4d5c58b | 2018-08-08 14:02:49 -0400 | [diff] [blame] | 576 | struct tep_handle *tep_alloc(void); |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 577 | void tep_free(struct tep_handle *tep); |
| 578 | void tep_ref(struct tep_handle *tep); |
| 579 | void tep_unref(struct tep_handle *tep); |
Tzvetomir Stoyanov | 477be10 | 2018-11-30 10:44:04 -0500 | [diff] [blame] | 580 | int tep_get_ref(struct tep_handle *tep); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 581 | |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 582 | /* for debugging */ |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 583 | void tep_print_funcs(struct tep_handle *tep); |
| 584 | void tep_print_printk(struct tep_handle *tep); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 585 | |
| 586 | /* ----------------------- filtering ----------------------- */ |
| 587 | |
Tzvetomir Stoyanov (VMware) | e906bb7 | 2018-09-19 14:56:51 -0400 | [diff] [blame] | 588 | enum tep_filter_boolean_type { |
| 589 | TEP_FILTER_FALSE, |
| 590 | TEP_FILTER_TRUE, |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 591 | }; |
| 592 | |
Tzvetomir Stoyanov (VMware) | e906bb7 | 2018-09-19 14:56:51 -0400 | [diff] [blame] | 593 | enum tep_filter_op_type { |
| 594 | TEP_FILTER_OP_AND = 1, |
| 595 | TEP_FILTER_OP_OR, |
| 596 | TEP_FILTER_OP_NOT, |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 597 | }; |
| 598 | |
Tzvetomir Stoyanov (VMware) | e906bb7 | 2018-09-19 14:56:51 -0400 | [diff] [blame] | 599 | enum tep_filter_cmp_type { |
| 600 | TEP_FILTER_CMP_NONE, |
| 601 | TEP_FILTER_CMP_EQ, |
| 602 | TEP_FILTER_CMP_NE, |
| 603 | TEP_FILTER_CMP_GT, |
| 604 | TEP_FILTER_CMP_LT, |
| 605 | TEP_FILTER_CMP_GE, |
| 606 | TEP_FILTER_CMP_LE, |
| 607 | TEP_FILTER_CMP_MATCH, |
| 608 | TEP_FILTER_CMP_NOT_MATCH, |
| 609 | TEP_FILTER_CMP_REGEX, |
| 610 | TEP_FILTER_CMP_NOT_REGEX, |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 611 | }; |
| 612 | |
Tzvetomir Stoyanov (VMware) | 4746d22 | 2018-09-19 14:56:52 -0400 | [diff] [blame] | 613 | enum tep_filter_exp_type { |
| 614 | TEP_FILTER_EXP_NONE, |
| 615 | TEP_FILTER_EXP_ADD, |
| 616 | TEP_FILTER_EXP_SUB, |
| 617 | TEP_FILTER_EXP_MUL, |
| 618 | TEP_FILTER_EXP_DIV, |
| 619 | TEP_FILTER_EXP_MOD, |
| 620 | TEP_FILTER_EXP_RSHIFT, |
| 621 | TEP_FILTER_EXP_LSHIFT, |
| 622 | TEP_FILTER_EXP_AND, |
| 623 | TEP_FILTER_EXP_OR, |
| 624 | TEP_FILTER_EXP_XOR, |
| 625 | TEP_FILTER_EXP_NOT, |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 626 | }; |
| 627 | |
Tzvetomir Stoyanov (VMware) | 4746d22 | 2018-09-19 14:56:52 -0400 | [diff] [blame] | 628 | enum tep_filter_arg_type { |
| 629 | TEP_FILTER_ARG_NONE, |
| 630 | TEP_FILTER_ARG_BOOLEAN, |
| 631 | TEP_FILTER_ARG_VALUE, |
| 632 | TEP_FILTER_ARG_FIELD, |
| 633 | TEP_FILTER_ARG_EXP, |
| 634 | TEP_FILTER_ARG_OP, |
| 635 | TEP_FILTER_ARG_NUM, |
| 636 | TEP_FILTER_ARG_STR, |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 637 | }; |
| 638 | |
Tzvetomir Stoyanov (VMware) | 0515ca5 | 2018-09-19 14:56:53 -0400 | [diff] [blame] | 639 | enum tep_filter_value_type { |
| 640 | TEP_FILTER_NUMBER, |
| 641 | TEP_FILTER_STRING, |
| 642 | TEP_FILTER_CHAR |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 643 | }; |
| 644 | |
Tzvetomir Stoyanov (VMware) | 0515ca5 | 2018-09-19 14:56:53 -0400 | [diff] [blame] | 645 | struct tep_filter_arg; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 646 | |
Tzvetomir Stoyanov (VMware) | 88e6c21 | 2018-09-19 14:56:54 -0400 | [diff] [blame] | 647 | struct tep_filter_arg_boolean { |
Tzvetomir Stoyanov (VMware) | e906bb7 | 2018-09-19 14:56:51 -0400 | [diff] [blame] | 648 | enum tep_filter_boolean_type value; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 649 | }; |
| 650 | |
Tzvetomir Stoyanov (VMware) | 88e6c21 | 2018-09-19 14:56:54 -0400 | [diff] [blame] | 651 | struct tep_filter_arg_field { |
| 652 | struct tep_format_field *field; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 653 | }; |
| 654 | |
Tzvetomir Stoyanov (VMware) | 88e6c21 | 2018-09-19 14:56:54 -0400 | [diff] [blame] | 655 | struct tep_filter_arg_value { |
Tzvetomir Stoyanov (VMware) | 0515ca5 | 2018-09-19 14:56:53 -0400 | [diff] [blame] | 656 | enum tep_filter_value_type type; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 657 | union { |
| 658 | char *str; |
| 659 | unsigned long long val; |
| 660 | }; |
| 661 | }; |
| 662 | |
Tzvetomir Stoyanov (VMware) | 88e6c21 | 2018-09-19 14:56:54 -0400 | [diff] [blame] | 663 | struct tep_filter_arg_op { |
| 664 | enum tep_filter_op_type type; |
| 665 | struct tep_filter_arg *left; |
| 666 | struct tep_filter_arg *right; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 667 | }; |
| 668 | |
Tzvetomir Stoyanov (VMware) | 88e6c21 | 2018-09-19 14:56:54 -0400 | [diff] [blame] | 669 | struct tep_filter_arg_exp { |
Tzvetomir Stoyanov (VMware) | 4746d22 | 2018-09-19 14:56:52 -0400 | [diff] [blame] | 670 | enum tep_filter_exp_type type; |
Tzvetomir Stoyanov (VMware) | 0515ca5 | 2018-09-19 14:56:53 -0400 | [diff] [blame] | 671 | struct tep_filter_arg *left; |
| 672 | struct tep_filter_arg *right; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 673 | }; |
| 674 | |
Tzvetomir Stoyanov (VMware) | 88e6c21 | 2018-09-19 14:56:54 -0400 | [diff] [blame] | 675 | struct tep_filter_arg_num { |
Tzvetomir Stoyanov (VMware) | e906bb7 | 2018-09-19 14:56:51 -0400 | [diff] [blame] | 676 | enum tep_filter_cmp_type type; |
Tzvetomir Stoyanov (VMware) | 88e6c21 | 2018-09-19 14:56:54 -0400 | [diff] [blame] | 677 | struct tep_filter_arg *left; |
| 678 | struct tep_filter_arg *right; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 679 | }; |
| 680 | |
Tzvetomir Stoyanov (VMware) | 88e6c21 | 2018-09-19 14:56:54 -0400 | [diff] [blame] | 681 | struct tep_filter_arg_str { |
Tzvetomir Stoyanov (VMware) | e906bb7 | 2018-09-19 14:56:51 -0400 | [diff] [blame] | 682 | enum tep_filter_cmp_type type; |
Tzvetomir Stoyanov (VMware) | 88e6c21 | 2018-09-19 14:56:54 -0400 | [diff] [blame] | 683 | struct tep_format_field *field; |
| 684 | char *val; |
| 685 | char *buffer; |
| 686 | regex_t reg; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 687 | }; |
| 688 | |
Tzvetomir Stoyanov (VMware) | 0515ca5 | 2018-09-19 14:56:53 -0400 | [diff] [blame] | 689 | struct tep_filter_arg { |
Tzvetomir Stoyanov (VMware) | 4746d22 | 2018-09-19 14:56:52 -0400 | [diff] [blame] | 690 | enum tep_filter_arg_type type; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 691 | union { |
Tzvetomir Stoyanov (VMware) | 88e6c21 | 2018-09-19 14:56:54 -0400 | [diff] [blame] | 692 | struct tep_filter_arg_boolean boolean; |
| 693 | struct tep_filter_arg_field field; |
| 694 | struct tep_filter_arg_value value; |
| 695 | struct tep_filter_arg_op op; |
| 696 | struct tep_filter_arg_exp exp; |
| 697 | struct tep_filter_arg_num num; |
| 698 | struct tep_filter_arg_str str; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 699 | }; |
| 700 | }; |
| 701 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 702 | struct tep_filter_type { |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 703 | int event_id; |
Tzvetomir Stoyanov | 97fbf3f | 2018-11-30 10:44:07 -0500 | [diff] [blame] | 704 | struct tep_event *event; |
Tzvetomir Stoyanov (VMware) | 0515ca5 | 2018-09-19 14:56:53 -0400 | [diff] [blame] | 705 | struct tep_filter_arg *filter; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 706 | }; |
| 707 | |
Tzvetomir Stoyanov (VMware) | 64e2379 | 2018-08-08 14:03:01 -0400 | [diff] [blame] | 708 | #define TEP_FILTER_ERROR_BUFSZ 1024 |
Namhyung Kim | bf19b82 | 2013-12-12 16:36:17 +0900 | [diff] [blame] | 709 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 710 | struct tep_event_filter { |
Tzvetomir Stoyanov | 6b1f4c4 | 2019-04-01 12:43:19 -0400 | [diff] [blame] | 711 | struct tep_handle *tep; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 712 | int filters; |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 713 | struct tep_filter_type *event_filters; |
Tzvetomir Stoyanov (VMware) | 64e2379 | 2018-08-08 14:03:01 -0400 | [diff] [blame] | 714 | char error_buffer[TEP_FILTER_ERROR_BUFSZ]; |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 715 | }; |
| 716 | |
Tzvetomir Stoyanov | 047ff22 | 2019-04-01 12:43:17 -0400 | [diff] [blame] | 717 | struct tep_event_filter *tep_filter_alloc(struct tep_handle *tep); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 718 | |
Namhyung Kim | 41e12e5 | 2013-12-12 16:36:15 +0900 | [diff] [blame] | 719 | /* for backward compatibility */ |
Tzvetomir Stoyanov (VMware) | d97f4ef | 2018-08-08 14:02:58 -0400 | [diff] [blame] | 720 | #define FILTER_NONE TEP_ERRNO__NO_FILTER |
| 721 | #define FILTER_NOEXIST TEP_ERRNO__FILTER_NOT_FOUND |
| 722 | #define FILTER_MISS TEP_ERRNO__FILTER_MISS |
| 723 | #define FILTER_MATCH TEP_ERRNO__FILTER_MATCH |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 724 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 725 | enum tep_errno tep_filter_add_filter_str(struct tep_event_filter *filter, |
Tzvetomir Stoyanov (VMware) | 64e2379 | 2018-08-08 14:03:01 -0400 | [diff] [blame] | 726 | const char *filter_str); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 727 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 728 | enum tep_errno tep_filter_match(struct tep_event_filter *filter, |
Tzvetomir Stoyanov (VMware) | 64e2379 | 2018-08-08 14:03:01 -0400 | [diff] [blame] | 729 | struct tep_record *record); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 730 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 731 | int tep_filter_strerror(struct tep_event_filter *filter, enum tep_errno err, |
Tzvetomir Stoyanov (VMware) | 64e2379 | 2018-08-08 14:03:01 -0400 | [diff] [blame] | 732 | char *buf, size_t buflen); |
Namhyung Kim | bf19b82 | 2013-12-12 16:36:17 +0900 | [diff] [blame] | 733 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 734 | int tep_event_filtered(struct tep_event_filter *filter, |
Tzvetomir Stoyanov (VMware) | 64e2379 | 2018-08-08 14:03:01 -0400 | [diff] [blame] | 735 | int event_id); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 736 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 737 | void tep_filter_reset(struct tep_event_filter *filter); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 738 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 739 | void tep_filter_free(struct tep_event_filter *filter); |
Tzvetomir Stoyanov (VMware) | 64e2379 | 2018-08-08 14:03:01 -0400 | [diff] [blame] | 740 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 741 | char *tep_filter_make_string(struct tep_event_filter *filter, int event_id); |
Tzvetomir Stoyanov (VMware) | 64e2379 | 2018-08-08 14:03:01 -0400 | [diff] [blame] | 742 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 743 | int tep_filter_remove_event(struct tep_event_filter *filter, |
Tzvetomir Stoyanov (VMware) | 64e2379 | 2018-08-08 14:03:01 -0400 | [diff] [blame] | 744 | int event_id); |
| 745 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 746 | int tep_filter_copy(struct tep_event_filter *dest, struct tep_event_filter *source); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 747 | |
Tzvetomir Stoyanov (VMware) | 9334c96 | 2018-09-19 14:56:55 -0400 | [diff] [blame] | 748 | int tep_filter_compare(struct tep_event_filter *filter1, struct tep_event_filter *filter2); |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 749 | |
| 750 | #endif /* _PARSE_EVENTS_H */ |