Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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