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