Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[deliverable/linux.git] / tools / lib / traceevent / event-parse.h
CommitLineData
f7d82350
SR
1/*
2 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3 *
4 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation;
8 * version 2.1 of the License (not later!)
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
7b9f6b40 16 * License along with this program; if not, see <http://www.gnu.org/licenses>
f7d82350
SR
17 *
18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */
20#ifndef _PARSE_EVENTS_H
21#define _PARSE_EVENTS_H
22
1b372ca5 23#include <stdbool.h>
f7d82350
SR
24#include <stdarg.h>
25#include <regex.h>
26
1d037ca1
IT
27#ifndef __maybe_unused
28#define __maybe_unused __attribute__((unused))
f7d82350
SR
29#endif
30
31/* ----------------------- trace_seq ----------------------- */
32
33
34#ifndef TRACE_SEQ_BUF_SIZE
35#define TRACE_SEQ_BUF_SIZE 4096
36#endif
37
38#ifndef DEBUG_RECORD
39#define DEBUG_RECORD 0
40#endif
41
1c698186 42struct pevent_record {
f7d82350
SR
43 unsigned long long ts;
44 unsigned long long offset;
45 long long missed_events; /* buffer dropped events before */
46 int record_size; /* size of binary record */
47 int size; /* size of data */
48 void *data;
49 int cpu;
50 int ref_count;
51 int locked; /* Do not free, even if ref_count is zero */
ff1a70e7 52 void *priv;
f7d82350 53#if DEBUG_RECORD
1c698186
SR
54 struct pevent_record *prev;
55 struct pevent_record *next;
f7d82350
SR
56 long alloc_addr;
57#endif
58};
59
60/*
61 * Trace sequences are used to allow a function to call several other functions
62 * to create a string of data to use (up to a max of PAGE_SIZE).
63 */
64
65struct trace_seq {
66 char *buffer;
67 unsigned int buffer_size;
68 unsigned int len;
69 unsigned int readpos;
70};
71
72void trace_seq_init(struct trace_seq *s);
6a48aec3 73void trace_seq_reset(struct trace_seq *s);
f7d82350
SR
74void trace_seq_destroy(struct trace_seq *s);
75
76extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
77 __attribute__ ((format (printf, 2, 3)));
78extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
79 __attribute__ ((format (printf, 2, 0)));
80
81extern int trace_seq_puts(struct trace_seq *s, const char *str);
82extern int trace_seq_putc(struct trace_seq *s, unsigned char c);
83
84extern void trace_seq_terminate(struct trace_seq *s);
85
86extern int trace_seq_do_printf(struct trace_seq *s);
87
88
89/* ----------------------- pevent ----------------------- */
90
91struct pevent;
92struct event_format;
93
94typedef int (*pevent_event_handler_func)(struct trace_seq *s,
1c698186 95 struct pevent_record *record,
f7d82350
SR
96 struct event_format *event,
97 void *context);
98
99typedef int (*pevent_plugin_load_func)(struct pevent *pevent);
100typedef int (*pevent_plugin_unload_func)(void);
101
102struct plugin_option {
103 struct plugin_option *next;
104 void *handle;
105 char *file;
106 char *name;
107 char *plugin_alias;
108 char *description;
109 char *value;
ff1a70e7 110 void *priv;
f7d82350
SR
111 int set;
112};
113
114/*
115 * Plugin hooks that can be called:
116 *
117 * PEVENT_PLUGIN_LOADER: (required)
118 * The function name to initialized the plugin.
119 *
120 * int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
121 *
122 * PEVENT_PLUGIN_UNLOADER: (optional)
123 * The function called just before unloading
124 *
125 * int PEVENT_PLUGIN_UNLOADER(void)
126 *
127 * PEVENT_PLUGIN_OPTIONS: (optional)
128 * Plugin options that can be set before loading
129 *
130 * struct plugin_option PEVENT_PLUGIN_OPTIONS[] = {
131 * {
132 * .name = "option-name",
133 * .plugin_alias = "overide-file-name", (optional)
134 * .description = "description of option to show users",
135 * },
136 * {
137 * .name = NULL,
138 * },
139 * };
140 *
141 * Array must end with .name = NULL;
142 *
143 *
144 * .plugin_alias is used to give a shorter name to access
145 * the vairable. Useful if a plugin handles more than one event.
146 *
147 * PEVENT_PLUGIN_ALIAS: (optional)
148 * The name to use for finding options (uses filename if not defined)
149 */
150#define PEVENT_PLUGIN_LOADER pevent_plugin_loader
151#define PEVENT_PLUGIN_UNLOADER pevent_plugin_unloader
152#define PEVENT_PLUGIN_OPTIONS pevent_plugin_options
153#define PEVENT_PLUGIN_ALIAS pevent_plugin_alias
154#define _MAKE_STR(x) #x
155#define MAKE_STR(x) _MAKE_STR(x)
156#define PEVENT_PLUGIN_LOADER_NAME MAKE_STR(PEVENT_PLUGIN_LOADER)
157#define PEVENT_PLUGIN_UNLOADER_NAME MAKE_STR(PEVENT_PLUGIN_UNLOADER)
158#define PEVENT_PLUGIN_OPTIONS_NAME MAKE_STR(PEVENT_PLUGIN_OPTIONS)
159#define PEVENT_PLUGIN_ALIAS_NAME MAKE_STR(PEVENT_PLUGIN_ALIAS)
160
161#define NSECS_PER_SEC 1000000000ULL
162#define NSECS_PER_USEC 1000ULL
163
164enum format_flags {
165 FIELD_IS_ARRAY = 1,
166 FIELD_IS_POINTER = 2,
167 FIELD_IS_SIGNED = 4,
168 FIELD_IS_STRING = 8,
169 FIELD_IS_DYNAMIC = 16,
170 FIELD_IS_LONG = 32,
668fe01f
SR
171 FIELD_IS_FLAG = 64,
172 FIELD_IS_SYMBOLIC = 128,
f7d82350
SR
173};
174
175struct format_field {
176 struct format_field *next;
177 struct event_format *event;
178 char *type;
179 char *name;
180 int offset;
181 int size;
182 unsigned int arraylen;
183 unsigned int elementsize;
184 unsigned long flags;
185};
186
187struct format {
188 int nr_common;
189 int nr_fields;
190 struct format_field *common_fields;
191 struct format_field *fields;
192};
193
194struct print_arg_atom {
195 char *atom;
196};
197
198struct print_arg_string {
199 char *string;
200 int offset;
201};
202
203struct print_arg_field {
204 char *name;
205 struct format_field *field;
206};
207
208struct print_flag_sym {
209 struct print_flag_sym *next;
210 char *value;
211 char *str;
212};
213
214struct print_arg_typecast {
215 char *type;
216 struct print_arg *item;
217};
218
219struct print_arg_flags {
220 struct print_arg *field;
221 char *delim;
222 struct print_flag_sym *flags;
223};
224
225struct print_arg_symbol {
226 struct print_arg *field;
227 struct print_flag_sym *symbols;
228};
229
e080e6f1
NK
230struct print_arg_hex {
231 struct print_arg *field;
232 struct print_arg *size;
233};
234
f7d82350
SR
235struct print_arg_dynarray {
236 struct format_field *field;
237 struct print_arg *index;
238};
239
240struct print_arg;
241
242struct print_arg_op {
243 char *op;
244 int prio;
245 struct print_arg *left;
246 struct print_arg *right;
247};
248
249struct pevent_function_handler;
250
251struct print_arg_func {
252 struct pevent_function_handler *func;
253 struct print_arg *args;
254};
255
256enum print_arg_type {
257 PRINT_NULL,
258 PRINT_ATOM,
259 PRINT_FIELD,
260 PRINT_FLAGS,
261 PRINT_SYMBOL,
e080e6f1 262 PRINT_HEX,
f7d82350
SR
263 PRINT_TYPE,
264 PRINT_STRING,
265 PRINT_BSTRING,
266 PRINT_DYNAMIC_ARRAY,
267 PRINT_OP,
268 PRINT_FUNC,
269};
270
271struct print_arg {
272 struct print_arg *next;
273 enum print_arg_type type;
274 union {
275 struct print_arg_atom atom;
276 struct print_arg_field field;
277 struct print_arg_typecast typecast;
278 struct print_arg_flags flags;
279 struct print_arg_symbol symbol;
e080e6f1 280 struct print_arg_hex hex;
f7d82350
SR
281 struct print_arg_func func;
282 struct print_arg_string string;
283 struct print_arg_op op;
284 struct print_arg_dynarray dynarray;
285 };
286};
287
288struct print_fmt {
289 char *format;
290 struct print_arg *args;
291};
292
293struct event_format {
294 struct pevent *pevent;
295 char *name;
296 int id;
297 int flags;
298 struct format format;
299 struct print_fmt print_fmt;
300 char *system;
301 pevent_event_handler_func handler;
302 void *context;
303};
304
305enum {
306 EVENT_FL_ISFTRACE = 0x01,
307 EVENT_FL_ISPRINT = 0x02,
308 EVENT_FL_ISBPRINT = 0x04,
309 EVENT_FL_ISFUNCENT = 0x10,
310 EVENT_FL_ISFUNCRET = 0x20,
c6c2b960
SR
311 EVENT_FL_NOHANDLE = 0x40,
312 EVENT_FL_PRINTRAW = 0x80,
f7d82350
SR
313
314 EVENT_FL_FAILED = 0x80000000
315};
316
317enum event_sort_type {
318 EVENT_SORT_ID,
319 EVENT_SORT_NAME,
320 EVENT_SORT_SYSTEM,
321};
322
323enum event_type {
324 EVENT_ERROR,
325 EVENT_NONE,
326 EVENT_SPACE,
327 EVENT_NEWLINE,
328 EVENT_OP,
329 EVENT_DELIM,
330 EVENT_ITEM,
331 EVENT_DQUOTE,
332 EVENT_SQUOTE,
333};
334
335typedef unsigned long long (*pevent_func_handler)(struct trace_seq *s,
336 unsigned long long *args);
337
338enum pevent_func_arg_type {
339 PEVENT_FUNC_ARG_VOID,
340 PEVENT_FUNC_ARG_INT,
341 PEVENT_FUNC_ARG_LONG,
342 PEVENT_FUNC_ARG_STRING,
343 PEVENT_FUNC_ARG_PTR,
344 PEVENT_FUNC_ARG_MAX_TYPES
345};
346
4dc1024a
SR
347enum pevent_flag {
348 PEVENT_NSEC_OUTPUT = 1, /* output in NSECS */
349};
350
2f197b9d
NK
351#define PEVENT_ERRORS \
352 _PE(MEM_ALLOC_FAILED, "failed to allocate memory"), \
353 _PE(PARSE_EVENT_FAILED, "failed to parse event"), \
354 _PE(READ_ID_FAILED, "failed to read event id"), \
355 _PE(READ_FORMAT_FAILED, "failed to read event format"), \
356 _PE(READ_PRINT_FAILED, "failed to read event print fmt"), \
67ed939c
NK
357 _PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace"),\
358 _PE(INVALID_ARG_TYPE, "invalid argument type")
2f197b9d
NK
359
360#undef _PE
361#define _PE(__code, __str) PEVENT_ERRNO__ ## __code
bffddffd
NK
362enum pevent_errno {
363 PEVENT_ERRNO__SUCCESS = 0,
364
365 /*
366 * Choose an arbitrary negative big number not to clash with standard
367 * errno since SUS requires the errno has distinct positive values.
368 * See 'Issue 6' in the link below.
369 *
370 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
371 */
372 __PEVENT_ERRNO__START = -100000,
373
2f197b9d 374 PEVENT_ERRORS,
bffddffd
NK
375
376 __PEVENT_ERRNO__END,
377};
2f197b9d 378#undef _PE
bffddffd 379
f7d82350
SR
380struct cmdline;
381struct cmdline_list;
382struct func_map;
383struct func_list;
384struct event_handler;
385
386struct pevent {
387 int ref_count;
388
389 int header_page_ts_offset;
390 int header_page_ts_size;
391 int header_page_size_offset;
392 int header_page_size_size;
393 int header_page_data_offset;
394 int header_page_data_size;
395 int header_page_overwrite;
396
397 int file_bigendian;
398 int host_bigendian;
399
400 int latency_format;
401
402 int old_format;
403
404 int cpus;
405 int long_size;
012ac692 406 int page_size;
f7d82350
SR
407
408 struct cmdline *cmdlines;
409 struct cmdline_list *cmdlist;
410 int cmdline_count;
411
412 struct func_map *func_map;
413 struct func_list *funclist;
414 unsigned int func_count;
415
416 struct printk_map *printk_map;
417 struct printk_list *printklist;
418 unsigned int printk_count;
419
4dc1024a 420
f7d82350
SR
421 struct event_format **events;
422 int nr_events;
423 struct event_format **sort_events;
424 enum event_sort_type last_type;
425
426 int type_offset;
427 int type_size;
428
429 int pid_offset;
430 int pid_size;
431
432 int pc_offset;
433 int pc_size;
434
435 int flags_offset;
436 int flags_size;
437
438 int ld_offset;
439 int ld_size;
440
441 int print_raw;
442
443 int test_filters;
444
4dc1024a
SR
445 int flags;
446
f7d82350
SR
447 struct format_field *bprint_ip_field;
448 struct format_field *bprint_fmt_field;
449 struct format_field *bprint_buf_field;
450
451 struct event_handler *handlers;
452 struct pevent_function_handler *func_handlers;
453
454 /* cache */
455 struct event_format *last_event;
1b372ca5
YY
456
457 char *trace_clock;
f7d82350
SR
458};
459
4dc1024a
SR
460static inline void pevent_set_flag(struct pevent *pevent, int flag)
461{
462 pevent->flags |= flag;
463}
464
f7d82350
SR
465static inline unsigned short
466__data2host2(struct pevent *pevent, unsigned short data)
467{
468 unsigned short swap;
469
470 if (pevent->host_bigendian == pevent->file_bigendian)
471 return data;
472
473 swap = ((data & 0xffULL) << 8) |
474 ((data & (0xffULL << 8)) >> 8);
475
476 return swap;
477}
478
479static inline unsigned int
480__data2host4(struct pevent *pevent, unsigned int data)
481{
482 unsigned int swap;
483
484 if (pevent->host_bigendian == pevent->file_bigendian)
485 return data;
486
487 swap = ((data & 0xffULL) << 24) |
488 ((data & (0xffULL << 8)) << 8) |
489 ((data & (0xffULL << 16)) >> 8) |
490 ((data & (0xffULL << 24)) >> 24);
491
492 return swap;
493}
494
495static inline unsigned long long
496__data2host8(struct pevent *pevent, unsigned long long data)
497{
498 unsigned long long swap;
499
500 if (pevent->host_bigendian == pevent->file_bigendian)
501 return data;
502
503 swap = ((data & 0xffULL) << 56) |
504 ((data & (0xffULL << 8)) << 40) |
505 ((data & (0xffULL << 16)) << 24) |
506 ((data & (0xffULL << 24)) << 8) |
507 ((data & (0xffULL << 32)) >> 8) |
508 ((data & (0xffULL << 40)) >> 24) |
509 ((data & (0xffULL << 48)) >> 40) |
510 ((data & (0xffULL << 56)) >> 56);
511
512 return swap;
513}
514
515#define data2host2(pevent, ptr) __data2host2(pevent, *(unsigned short *)(ptr))
516#define data2host4(pevent, ptr) __data2host4(pevent, *(unsigned int *)(ptr))
517#define data2host8(pevent, ptr) \
518({ \
519 unsigned long long __val; \
520 \
521 memcpy(&__val, (ptr), sizeof(unsigned long long)); \
522 __data2host8(pevent, __val); \
523})
524
525/* taken from kernel/trace/trace.h */
526enum trace_flag_type {
527 TRACE_FLAG_IRQS_OFF = 0x01,
528 TRACE_FLAG_IRQS_NOSUPPORT = 0x02,
529 TRACE_FLAG_NEED_RESCHED = 0x04,
530 TRACE_FLAG_HARDIRQ = 0x08,
531 TRACE_FLAG_SOFTIRQ = 0x10,
532};
533
534int pevent_register_comm(struct pevent *pevent, const char *comm, int pid);
1b372ca5 535void pevent_register_trace_clock(struct pevent *pevent, char *trace_clock);
f7d82350
SR
536int pevent_register_function(struct pevent *pevent, char *name,
537 unsigned long long addr, char *mod);
18900af8 538int pevent_register_print_string(struct pevent *pevent, const char *fmt,
f7d82350
SR
539 unsigned long long addr);
540int pevent_pid_is_registered(struct pevent *pevent, int pid);
541
542void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
1b372ca5 543 struct pevent_record *record, bool use_trace_clock);
f7d82350
SR
544
545int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long size,
546 int long_size);
547
bffddffd
NK
548enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
549 unsigned long size, const char *sys);
2b29175d
ACM
550enum pevent_errno pevent_parse_format(struct event_format **eventp, const char *buf,
551 unsigned long size, const char *sys);
552void pevent_free_format(struct event_format *event);
f7d82350
SR
553
554void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
1c698186 555 const char *name, struct pevent_record *record,
f7d82350
SR
556 int *len, int err);
557
558int pevent_get_field_val(struct trace_seq *s, struct event_format *event,
1c698186 559 const char *name, struct pevent_record *record,
f7d82350
SR
560 unsigned long long *val, int err);
561int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event,
1c698186 562 const char *name, struct pevent_record *record,
f7d82350
SR
563 unsigned long long *val, int err);
564int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event,
1c698186 565 const char *name, struct pevent_record *record,
f7d82350
SR
566 unsigned long long *val, int err);
567
568int pevent_print_num_field(struct trace_seq *s, const char *fmt,
569 struct event_format *event, const char *name,
1c698186 570 struct pevent_record *record, int err);
f7d82350 571
6d862b8c
SR
572int pevent_print_func_field(struct trace_seq *s, const char *fmt,
573 struct event_format *event, const char *name,
574 struct pevent_record *record, int err);
575
79d5adf0
NK
576int pevent_register_event_handler(struct pevent *pevent, int id,
577 const char *sys_name, const char *event_name,
f7d82350
SR
578 pevent_event_handler_func func, void *context);
579int pevent_register_print_function(struct pevent *pevent,
580 pevent_func_handler func,
581 enum pevent_func_arg_type ret_type,
582 char *name, ...);
583
584struct format_field *pevent_find_common_field(struct event_format *event, const char *name);
585struct format_field *pevent_find_field(struct event_format *event, const char *name);
586struct format_field *pevent_find_any_field(struct event_format *event, const char *name);
587
588const char *pevent_find_function(struct pevent *pevent, unsigned long long addr);
589unsigned long long
590pevent_find_function_address(struct pevent *pevent, unsigned long long addr);
591unsigned long long pevent_read_number(struct pevent *pevent, const void *ptr, int size);
592int pevent_read_number_field(struct format_field *field, const void *data,
593 unsigned long long *value);
594
595struct event_format *pevent_find_event(struct pevent *pevent, int id);
596
597struct event_format *
598pevent_find_event_by_name(struct pevent *pevent, const char *sys, const char *name);
599
600void pevent_data_lat_fmt(struct pevent *pevent,
1c698186
SR
601 struct trace_seq *s, struct pevent_record *record);
602int pevent_data_type(struct pevent *pevent, struct pevent_record *rec);
f7d82350 603struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type);
1c698186 604int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec);
f7d82350
SR
605const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid);
606void pevent_event_info(struct trace_seq *s, struct event_format *event,
1c698186 607 struct pevent_record *record);
2f197b9d
NK
608int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
609 char *buf, size_t buflen);
f7d82350
SR
610
611struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type);
612struct format_field **pevent_event_common_fields(struct event_format *event);
613struct format_field **pevent_event_fields(struct event_format *event);
614
615static inline int pevent_get_cpus(struct pevent *pevent)
616{
617 return pevent->cpus;
618}
619
620static inline void pevent_set_cpus(struct pevent *pevent, int cpus)
621{
622 pevent->cpus = cpus;
623}
624
625static inline int pevent_get_long_size(struct pevent *pevent)
626{
627 return pevent->long_size;
628}
629
630static inline void pevent_set_long_size(struct pevent *pevent, int long_size)
631{
632 pevent->long_size = long_size;
633}
634
012ac692
NK
635static inline int pevent_get_page_size(struct pevent *pevent)
636{
637 return pevent->page_size;
638}
639
640static inline void pevent_set_page_size(struct pevent *pevent, int _page_size)
641{
642 pevent->page_size = _page_size;
643}
644
f7d82350
SR
645static inline int pevent_is_file_bigendian(struct pevent *pevent)
646{
647 return pevent->file_bigendian;
648}
649
650static inline void pevent_set_file_bigendian(struct pevent *pevent, int endian)
651{
652 pevent->file_bigendian = endian;
653}
654
655static inline int pevent_is_host_bigendian(struct pevent *pevent)
656{
657 return pevent->host_bigendian;
658}
659
660static inline void pevent_set_host_bigendian(struct pevent *pevent, int endian)
661{
662 pevent->host_bigendian = endian;
663}
664
665static inline int pevent_is_latency_format(struct pevent *pevent)
666{
667 return pevent->latency_format;
668}
669
670static inline void pevent_set_latency_format(struct pevent *pevent, int lat)
671{
672 pevent->latency_format = lat;
673}
674
675struct pevent *pevent_alloc(void);
676void pevent_free(struct pevent *pevent);
677void pevent_ref(struct pevent *pevent);
678void pevent_unref(struct pevent *pevent);
679
680/* access to the internal parser */
681void pevent_buffer_init(const char *buf, unsigned long long size);
682enum event_type pevent_read_token(char **tok);
683void pevent_free_token(char *token);
684int pevent_peek_char(void);
685const char *pevent_get_input_buf(void);
686unsigned long long pevent_get_input_buf_ptr(void);
687
688/* for debugging */
689void pevent_print_funcs(struct pevent *pevent);
690void pevent_print_printk(struct pevent *pevent);
691
692/* ----------------------- filtering ----------------------- */
693
694enum filter_boolean_type {
695 FILTER_FALSE,
696 FILTER_TRUE,
697};
698
699enum filter_op_type {
700 FILTER_OP_AND = 1,
701 FILTER_OP_OR,
702 FILTER_OP_NOT,
703};
704
705enum filter_cmp_type {
706 FILTER_CMP_NONE,
707 FILTER_CMP_EQ,
708 FILTER_CMP_NE,
709 FILTER_CMP_GT,
710 FILTER_CMP_LT,
711 FILTER_CMP_GE,
712 FILTER_CMP_LE,
713 FILTER_CMP_MATCH,
714 FILTER_CMP_NOT_MATCH,
715 FILTER_CMP_REGEX,
716 FILTER_CMP_NOT_REGEX,
717};
718
719enum filter_exp_type {
720 FILTER_EXP_NONE,
721 FILTER_EXP_ADD,
722 FILTER_EXP_SUB,
723 FILTER_EXP_MUL,
724 FILTER_EXP_DIV,
725 FILTER_EXP_MOD,
726 FILTER_EXP_RSHIFT,
727 FILTER_EXP_LSHIFT,
728 FILTER_EXP_AND,
729 FILTER_EXP_OR,
730 FILTER_EXP_XOR,
731 FILTER_EXP_NOT,
732};
733
734enum filter_arg_type {
735 FILTER_ARG_NONE,
736 FILTER_ARG_BOOLEAN,
737 FILTER_ARG_VALUE,
738 FILTER_ARG_FIELD,
739 FILTER_ARG_EXP,
740 FILTER_ARG_OP,
741 FILTER_ARG_NUM,
742 FILTER_ARG_STR,
743};
744
745enum filter_value_type {
746 FILTER_NUMBER,
747 FILTER_STRING,
748 FILTER_CHAR
749};
750
751struct fliter_arg;
752
753struct filter_arg_boolean {
754 enum filter_boolean_type value;
755};
756
757struct filter_arg_field {
758 struct format_field *field;
759};
760
761struct filter_arg_value {
762 enum filter_value_type type;
763 union {
764 char *str;
765 unsigned long long val;
766 };
767};
768
769struct filter_arg_op {
770 enum filter_op_type type;
771 struct filter_arg *left;
772 struct filter_arg *right;
773};
774
775struct filter_arg_exp {
776 enum filter_exp_type type;
777 struct filter_arg *left;
778 struct filter_arg *right;
779};
780
781struct filter_arg_num {
782 enum filter_cmp_type type;
783 struct filter_arg *left;
784 struct filter_arg *right;
785};
786
787struct filter_arg_str {
788 enum filter_cmp_type type;
789 struct format_field *field;
790 char *val;
791 char *buffer;
792 regex_t reg;
793};
794
795struct filter_arg {
796 enum filter_arg_type type;
797 union {
668fe01f 798 struct filter_arg_boolean boolean;
f7d82350
SR
799 struct filter_arg_field field;
800 struct filter_arg_value value;
801 struct filter_arg_op op;
802 struct filter_arg_exp exp;
803 struct filter_arg_num num;
804 struct filter_arg_str str;
805 };
806};
807
808struct filter_type {
809 int event_id;
810 struct event_format *event;
811 struct filter_arg *filter;
812};
813
814struct event_filter {
815 struct pevent *pevent;
816 int filters;
817 struct filter_type *event_filters;
818};
819
820struct event_filter *pevent_filter_alloc(struct pevent *pevent);
821
822#define FILTER_NONE -2
823#define FILTER_NOEXIST -1
824#define FILTER_MISS 0
825#define FILTER_MATCH 1
826
827enum filter_trivial_type {
828 FILTER_TRIVIAL_FALSE,
829 FILTER_TRIVIAL_TRUE,
830 FILTER_TRIVIAL_BOTH,
831};
832
833int pevent_filter_add_filter_str(struct event_filter *filter,
834 const char *filter_str,
835 char **error_str);
836
837
838int pevent_filter_match(struct event_filter *filter,
1c698186 839 struct pevent_record *record);
f7d82350
SR
840
841int pevent_event_filtered(struct event_filter *filter,
842 int event_id);
843
844void pevent_filter_reset(struct event_filter *filter);
845
846void pevent_filter_clear_trivial(struct event_filter *filter,
847 enum filter_trivial_type type);
848
849void pevent_filter_free(struct event_filter *filter);
850
851char *pevent_filter_make_string(struct event_filter *filter, int event_id);
852
853int pevent_filter_remove_event(struct event_filter *filter,
854 int event_id);
855
856int pevent_filter_event_has_trivial(struct event_filter *filter,
857 int event_id,
858 enum filter_trivial_type type);
859
860int pevent_filter_copy(struct event_filter *dest, struct event_filter *source);
861
862int pevent_update_trivial(struct event_filter *dest, struct event_filter *source,
863 enum filter_trivial_type type);
864
865int pevent_filter_compare(struct event_filter *filter1, struct event_filter *filter2);
866
867#endif /* _PARSE_EVENTS_H */
This page took 0.129427 seconds and 5 git commands to generate.