Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

events: Update tools/lib/traceevent to work with perf

Some of the util functions of libtraceevent.a conflict with perf,
such as die(), warning() and others. Move them into event-util.h
that is not included by the perf tools.

Also, as perf compiles with 'bool' the filter_arg->bool needs to
be renamed to filter_arg->boolean.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Arun Sharma <asharma@fb.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>

authored by

Steven Rostedt and committed by
Frederic Weisbecker
668fe01f d0e7b850

+37 -33
+1
tools/lib/traceevent/event-parse.c
··· 33 33 #include <errno.h> 34 34 35 35 #include "event-parse.h" 36 + #include "event-utils.h" 36 37 37 38 static const char *input_buf; 38 39 static unsigned long long input_buf_ptr;
+3 -17
tools/lib/traceevent/event-parse.h
··· 167 167 FIELD_IS_STRING = 8, 168 168 FIELD_IS_DYNAMIC = 16, 169 169 FIELD_IS_LONG = 32, 170 + FIELD_IS_FLAG = 64, 171 + FIELD_IS_SYMBOLIC = 128, 170 172 }; 171 173 172 174 struct format_field { ··· 407 405 /* cache */ 408 406 struct event_format *last_event; 409 407 }; 410 - 411 - /* Can be overridden */ 412 - void die(const char *fmt, ...); 413 - void *malloc_or_die(unsigned int size); 414 - void warning(const char *fmt, ...); 415 - void pr_stat(const char *fmt, ...); 416 - void vpr_stat(const char *fmt, va_list ap); 417 - 418 - /* Always available */ 419 - void __die(const char *fmt, ...); 420 - void __warning(const char *fmt, ...); 421 - void __pr_stat(const char *fmt, ...); 422 - 423 - void __vdie(const char *fmt, ...); 424 - void __vwarning(const char *fmt, ...); 425 - void __vpr_stat(const char *fmt, ...); 426 408 427 409 static inline unsigned short 428 410 __data2host2(struct pevent *pevent, unsigned short data) ··· 720 734 struct filter_arg { 721 735 enum filter_arg_type type; 722 736 union { 723 - struct filter_arg_boolean bool; 737 + struct filter_arg_boolean boolean; 724 738 struct filter_arg_field field; 725 739 struct filter_arg_value value; 726 740 struct filter_arg_op op;
+16
tools/lib/traceevent/event-utils.h
··· 23 23 24 24 #include <ctype.h> 25 25 26 + /* Can be overridden */ 27 + void die(const char *fmt, ...); 28 + void *malloc_or_die(unsigned int size); 29 + void warning(const char *fmt, ...); 30 + void pr_stat(const char *fmt, ...); 31 + void vpr_stat(const char *fmt, va_list ap); 32 + 33 + /* Always available */ 34 + void __die(const char *fmt, ...); 35 + void __warning(const char *fmt, ...); 36 + void __pr_stat(const char *fmt, ...); 37 + 38 + void __vdie(const char *fmt, ...); 39 + void __vwarning(const char *fmt, ...); 40 + void __vpr_stat(const char *fmt, ...); 41 + 26 42 static inline char *strim(char *string) 27 43 { 28 44 char *ret;
+16 -16
tools/lib/traceevent/parse-filter.c
··· 359 359 if (strcmp(token, COMM) != 0) { 360 360 /* not a field, Make it false */ 361 361 arg->type = FILTER_ARG_BOOLEAN; 362 - arg->bool.value = FILTER_FALSE; 362 + arg->boolean.value = FILTER_FALSE; 363 363 break; 364 364 } 365 365 /* If token is 'COMM' then it is special */ ··· 487 487 free_arg(left); 488 488 free_arg(arg); 489 489 op->type = FILTER_ARG_BOOLEAN; 490 - op->bool.value = FILTER_FALSE; 490 + op->boolean.value = FILTER_FALSE; 491 491 break; 492 492 } 493 493 ··· 772 772 773 773 /* bad case */ 774 774 case FILTER_ARG_BOOLEAN: 775 - return FILTER_VAL_FALSE + arg->bool.value; 775 + return FILTER_VAL_FALSE + arg->boolean.value; 776 776 777 777 /* good cases: */ 778 778 case FILTER_ARG_STR: ··· 871 871 free_arg(arg); 872 872 arg = allocate_arg(); 873 873 arg->type = FILTER_ARG_BOOLEAN; 874 - arg->bool.value = ret == FILTER_VAL_TRUE; 874 + arg->boolean.value = ret == FILTER_VAL_TRUE; 875 875 } 876 876 877 877 return arg; ··· 1116 1116 if (!*parg) { 1117 1117 *parg = allocate_arg(); 1118 1118 (*parg)->type = FILTER_ARG_BOOLEAN; 1119 - (*parg)->bool.value = FILTER_FALSE; 1119 + (*parg)->boolean.value = FILTER_FALSE; 1120 1120 } 1121 1121 1122 1122 return 0; ··· 1139 1139 /* just add a TRUE arg */ 1140 1140 arg = allocate_arg(); 1141 1141 arg->type = FILTER_ARG_BOOLEAN; 1142 - arg->bool.value = FILTER_TRUE; 1142 + arg->boolean.value = FILTER_TRUE; 1143 1143 } 1144 1144 1145 1145 filter_type = add_filter_type(filter, event->id); ··· 1369 1369 arg = allocate_arg(); 1370 1370 arg->type = FILTER_ARG_BOOLEAN; 1371 1371 if (strcmp(str, "TRUE") == 0) 1372 - arg->bool.value = 1; 1372 + arg->boolean.value = 1; 1373 1373 else 1374 - arg->bool.value = 0; 1374 + arg->boolean.value = 0; 1375 1375 1376 1376 filter_type = add_filter_type(filter, event->id); 1377 1377 filter_type->filter = arg; ··· 1442 1442 arg = filter_type->filter; 1443 1443 if (arg->type != FILTER_ARG_BOOLEAN) 1444 1444 continue; 1445 - if ((arg->bool.value && type == FILTER_TRIVIAL_FALSE) || 1446 - (!arg->bool.value && type == FILTER_TRIVIAL_TRUE)) 1445 + if ((arg->boolean.value && type == FILTER_TRIVIAL_FALSE) || 1446 + (!arg->boolean.value && type == FILTER_TRIVIAL_TRUE)) 1447 1447 continue; 1448 1448 1449 1449 event = filter_type->event; ··· 1497 1497 continue; 1498 1498 switch (type) { 1499 1499 case FILTER_TRIVIAL_FALSE: 1500 - if (filter_type->filter->bool.value) 1500 + if (filter_type->filter->boolean.value) 1501 1501 continue; 1502 1502 case FILTER_TRIVIAL_TRUE: 1503 - if (!filter_type->filter->bool.value) 1503 + if (!filter_type->filter->boolean.value) 1504 1504 continue; 1505 1505 default: 1506 1506 break; ··· 1551 1551 1552 1552 switch (type) { 1553 1553 case FILTER_TRIVIAL_FALSE: 1554 - return !filter_type->filter->bool.value; 1554 + return !filter_type->filter->boolean.value; 1555 1555 1556 1556 case FILTER_TRIVIAL_TRUE: 1557 - return filter_type->filter->bool.value; 1557 + return filter_type->filter->boolean.value; 1558 1558 default: 1559 1559 return 1; 1560 1560 } ··· 1783 1783 switch (arg->type) { 1784 1784 case FILTER_ARG_BOOLEAN: 1785 1785 /* easy case */ 1786 - return arg->bool.value; 1786 + return arg->boolean.value; 1787 1787 1788 1788 case FILTER_ARG_OP: 1789 1789 return test_op(event, arg, record); ··· 2147 2147 switch (arg->type) { 2148 2148 case FILTER_ARG_BOOLEAN: 2149 2149 str = malloc_or_die(6); 2150 - if (arg->bool.value) 2150 + if (arg->boolean.value) 2151 2151 strcpy(str, "TRUE"); 2152 2152 else 2153 2153 strcpy(str, "FALSE");
+1
tools/lib/traceevent/trace-seq.c
··· 24 24 #include <stdarg.h> 25 25 26 26 #include "event-parse.h" 27 + #include "event-utils.h" 27 28 28 29 /* 29 30 * The TRACE_SEQ_POISON is to catch the use of using