Commit 668fe01f authored by Steven Rostedt's avatar Steven Rostedt Committed by Frederic Weisbecker

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: default avatarSteven 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: default avatarFrederic Weisbecker <fweisbec@gmail.com>
parent d0e7b850
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <errno.h> #include <errno.h>
#include "event-parse.h" #include "event-parse.h"
#include "event-utils.h"
static const char *input_buf; static const char *input_buf;
static unsigned long long input_buf_ptr; static unsigned long long input_buf_ptr;
......
...@@ -167,6 +167,8 @@ enum format_flags { ...@@ -167,6 +167,8 @@ enum format_flags {
FIELD_IS_STRING = 8, FIELD_IS_STRING = 8,
FIELD_IS_DYNAMIC = 16, FIELD_IS_DYNAMIC = 16,
FIELD_IS_LONG = 32, FIELD_IS_LONG = 32,
FIELD_IS_FLAG = 64,
FIELD_IS_SYMBOLIC = 128,
}; };
struct format_field { struct format_field {
...@@ -406,22 +408,6 @@ struct pevent { ...@@ -406,22 +408,6 @@ struct pevent {
struct event_format *last_event; struct event_format *last_event;
}; };
/* Can be overridden */
void die(const char *fmt, ...);
void *malloc_or_die(unsigned int size);
void warning(const char *fmt, ...);
void pr_stat(const char *fmt, ...);
void vpr_stat(const char *fmt, va_list ap);
/* Always available */
void __die(const char *fmt, ...);
void __warning(const char *fmt, ...);
void __pr_stat(const char *fmt, ...);
void __vdie(const char *fmt, ...);
void __vwarning(const char *fmt, ...);
void __vpr_stat(const char *fmt, ...);
static inline unsigned short static inline unsigned short
__data2host2(struct pevent *pevent, unsigned short data) __data2host2(struct pevent *pevent, unsigned short data)
{ {
...@@ -734,7 +720,7 @@ struct filter_arg_str { ...@@ -734,7 +720,7 @@ struct filter_arg_str {
struct filter_arg { struct filter_arg {
enum filter_arg_type type; enum filter_arg_type type;
union { union {
struct filter_arg_boolean bool; struct filter_arg_boolean boolean;
struct filter_arg_field field; struct filter_arg_field field;
struct filter_arg_value value; struct filter_arg_value value;
struct filter_arg_op op; struct filter_arg_op op;
......
...@@ -23,6 +23,22 @@ ...@@ -23,6 +23,22 @@
#include <ctype.h> #include <ctype.h>
/* Can be overridden */
void die(const char *fmt, ...);
void *malloc_or_die(unsigned int size);
void warning(const char *fmt, ...);
void pr_stat(const char *fmt, ...);
void vpr_stat(const char *fmt, va_list ap);
/* Always available */
void __die(const char *fmt, ...);
void __warning(const char *fmt, ...);
void __pr_stat(const char *fmt, ...);
void __vdie(const char *fmt, ...);
void __vwarning(const char *fmt, ...);
void __vpr_stat(const char *fmt, ...);
static inline char *strim(char *string) static inline char *strim(char *string)
{ {
char *ret; char *ret;
......
...@@ -359,7 +359,7 @@ create_arg_item(struct event_format *event, ...@@ -359,7 +359,7 @@ create_arg_item(struct event_format *event,
if (strcmp(token, COMM) != 0) { if (strcmp(token, COMM) != 0) {
/* not a field, Make it false */ /* not a field, Make it false */
arg->type = FILTER_ARG_BOOLEAN; arg->type = FILTER_ARG_BOOLEAN;
arg->bool.value = FILTER_FALSE; arg->boolean.value = FILTER_FALSE;
break; break;
} }
/* If token is 'COMM' then it is special */ /* If token is 'COMM' then it is special */
...@@ -487,7 +487,7 @@ static int add_right(struct filter_arg *op, struct filter_arg *arg, ...@@ -487,7 +487,7 @@ static int add_right(struct filter_arg *op, struct filter_arg *arg,
free_arg(left); free_arg(left);
free_arg(arg); free_arg(arg);
op->type = FILTER_ARG_BOOLEAN; op->type = FILTER_ARG_BOOLEAN;
op->bool.value = FILTER_FALSE; op->boolean.value = FILTER_FALSE;
break; break;
} }
...@@ -772,7 +772,7 @@ enum filter_vals test_arg(struct filter_arg *parent, struct filter_arg *arg) ...@@ -772,7 +772,7 @@ enum filter_vals test_arg(struct filter_arg *parent, struct filter_arg *arg)
/* bad case */ /* bad case */
case FILTER_ARG_BOOLEAN: case FILTER_ARG_BOOLEAN:
return FILTER_VAL_FALSE + arg->bool.value; return FILTER_VAL_FALSE + arg->boolean.value;
/* good cases: */ /* good cases: */
case FILTER_ARG_STR: case FILTER_ARG_STR:
...@@ -871,7 +871,7 @@ static struct filter_arg *collapse_tree(struct filter_arg *arg) ...@@ -871,7 +871,7 @@ static struct filter_arg *collapse_tree(struct filter_arg *arg)
free_arg(arg); free_arg(arg);
arg = allocate_arg(); arg = allocate_arg();
arg->type = FILTER_ARG_BOOLEAN; arg->type = FILTER_ARG_BOOLEAN;
arg->bool.value = ret == FILTER_VAL_TRUE; arg->boolean.value = ret == FILTER_VAL_TRUE;
} }
return arg; return arg;
...@@ -1116,7 +1116,7 @@ process_event(struct event_format *event, const char *filter_str, ...@@ -1116,7 +1116,7 @@ process_event(struct event_format *event, const char *filter_str,
if (!*parg) { if (!*parg) {
*parg = allocate_arg(); *parg = allocate_arg();
(*parg)->type = FILTER_ARG_BOOLEAN; (*parg)->type = FILTER_ARG_BOOLEAN;
(*parg)->bool.value = FILTER_FALSE; (*parg)->boolean.value = FILTER_FALSE;
} }
return 0; return 0;
...@@ -1139,7 +1139,7 @@ static int filter_event(struct event_filter *filter, ...@@ -1139,7 +1139,7 @@ static int filter_event(struct event_filter *filter,
/* just add a TRUE arg */ /* just add a TRUE arg */
arg = allocate_arg(); arg = allocate_arg();
arg->type = FILTER_ARG_BOOLEAN; arg->type = FILTER_ARG_BOOLEAN;
arg->bool.value = FILTER_TRUE; arg->boolean.value = FILTER_TRUE;
} }
filter_type = add_filter_type(filter, event->id); filter_type = add_filter_type(filter, event->id);
...@@ -1369,9 +1369,9 @@ static int copy_filter_type(struct event_filter *filter, ...@@ -1369,9 +1369,9 @@ static int copy_filter_type(struct event_filter *filter,
arg = allocate_arg(); arg = allocate_arg();
arg->type = FILTER_ARG_BOOLEAN; arg->type = FILTER_ARG_BOOLEAN;
if (strcmp(str, "TRUE") == 0) if (strcmp(str, "TRUE") == 0)
arg->bool.value = 1; arg->boolean.value = 1;
else else
arg->bool.value = 0; arg->boolean.value = 0;
filter_type = add_filter_type(filter, event->id); filter_type = add_filter_type(filter, event->id);
filter_type->filter = arg; filter_type->filter = arg;
...@@ -1442,8 +1442,8 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source ...@@ -1442,8 +1442,8 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
arg = filter_type->filter; arg = filter_type->filter;
if (arg->type != FILTER_ARG_BOOLEAN) if (arg->type != FILTER_ARG_BOOLEAN)
continue; continue;
if ((arg->bool.value && type == FILTER_TRIVIAL_FALSE) || if ((arg->boolean.value && type == FILTER_TRIVIAL_FALSE) ||
(!arg->bool.value && type == FILTER_TRIVIAL_TRUE)) (!arg->boolean.value && type == FILTER_TRIVIAL_TRUE))
continue; continue;
event = filter_type->event; event = filter_type->event;
...@@ -1497,10 +1497,10 @@ void pevent_filter_clear_trivial(struct event_filter *filter, ...@@ -1497,10 +1497,10 @@ void pevent_filter_clear_trivial(struct event_filter *filter,
continue; continue;
switch (type) { switch (type) {
case FILTER_TRIVIAL_FALSE: case FILTER_TRIVIAL_FALSE:
if (filter_type->filter->bool.value) if (filter_type->filter->boolean.value)
continue; continue;
case FILTER_TRIVIAL_TRUE: case FILTER_TRIVIAL_TRUE:
if (!filter_type->filter->bool.value) if (!filter_type->filter->boolean.value)
continue; continue;
default: default:
break; break;
...@@ -1551,10 +1551,10 @@ int pevent_filter_event_has_trivial(struct event_filter *filter, ...@@ -1551,10 +1551,10 @@ int pevent_filter_event_has_trivial(struct event_filter *filter,
switch (type) { switch (type) {
case FILTER_TRIVIAL_FALSE: case FILTER_TRIVIAL_FALSE:
return !filter_type->filter->bool.value; return !filter_type->filter->boolean.value;
case FILTER_TRIVIAL_TRUE: case FILTER_TRIVIAL_TRUE:
return filter_type->filter->bool.value; return filter_type->filter->boolean.value;
default: default:
return 1; return 1;
} }
...@@ -1783,7 +1783,7 @@ static int test_filter(struct event_format *event, ...@@ -1783,7 +1783,7 @@ static int test_filter(struct event_format *event,
switch (arg->type) { switch (arg->type) {
case FILTER_ARG_BOOLEAN: case FILTER_ARG_BOOLEAN:
/* easy case */ /* easy case */
return arg->bool.value; return arg->boolean.value;
case FILTER_ARG_OP: case FILTER_ARG_OP:
return test_op(event, arg, record); return test_op(event, arg, record);
...@@ -2147,7 +2147,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg) ...@@ -2147,7 +2147,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
switch (arg->type) { switch (arg->type) {
case FILTER_ARG_BOOLEAN: case FILTER_ARG_BOOLEAN:
str = malloc_or_die(6); str = malloc_or_die(6);
if (arg->bool.value) if (arg->boolean.value)
strcpy(str, "TRUE"); strcpy(str, "TRUE");
else else
strcpy(str, "FALSE"); strcpy(str, "FALSE");
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <stdarg.h> #include <stdarg.h>
#include "event-parse.h" #include "event-parse.h"
#include "event-utils.h"
/* /*
* The TRACE_SEQ_POISON is to catch the use of using * The TRACE_SEQ_POISON is to catch the use of using
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment