[PATCH 10/20 v2] tracing: Make func_type enums for easier comparing of arg types
From: Steven Rostedt
Date: Wed Feb 07 2018 - 15:32:17 EST
From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>
For the function based event args, knowing quickly what type they are is
advantageous, as decisions can be made quickly based on them. Having an
enum for the types is useful for this purpose.
Use macros to create both the func_type array as well as enums that
match the type to the index into that array.
Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
kernel/trace/trace_event_ftrace.c | 47 +++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/kernel/trace/trace_event_ftrace.c b/kernel/trace/trace_event_ftrace.c
index 1fa281386fa0..6e48361643c0 100644
--- a/kernel/trace/trace_event_ftrace.c
+++ b/kernel/trace/trace_event_ftrace.c
@@ -24,6 +24,7 @@ struct func_arg {
short size;
s8 arg;
u8 sign;
+ u8 func_type;
};
struct func_event {
@@ -79,31 +80,42 @@ typedef u8 x8;
#define TYPE_TUPLE(type) \
{ #type, sizeof(type), is_signed_type(type) }
+#define FUNC_TYPES \
+ TYPE_TUPLE(long), \
+ TYPE_TUPLE(int), \
+ TYPE_TUPLE(short), \
+ TYPE_TUPLE(char), \
+ TYPE_TUPLE(size_t), \
+ TYPE_TUPLE(u64), \
+ TYPE_TUPLE(s64), \
+ TYPE_TUPLE(x64), \
+ TYPE_TUPLE(u32), \
+ TYPE_TUPLE(s32), \
+ TYPE_TUPLE(x32), \
+ TYPE_TUPLE(u16), \
+ TYPE_TUPLE(s16), \
+ TYPE_TUPLE(x16), \
+ TYPE_TUPLE(u8), \
+ TYPE_TUPLE(s8), \
+ TYPE_TUPLE(x8)
+
static struct func_type {
char *name;
int size;
int sign;
} func_types[] = {
- TYPE_TUPLE(long),
- TYPE_TUPLE(int),
- TYPE_TUPLE(short),
- TYPE_TUPLE(char),
- TYPE_TUPLE(size_t),
- TYPE_TUPLE(u64),
- TYPE_TUPLE(s64),
- TYPE_TUPLE(x64),
- TYPE_TUPLE(u32),
- TYPE_TUPLE(s32),
- TYPE_TUPLE(x32),
- TYPE_TUPLE(u16),
- TYPE_TUPLE(s16),
- TYPE_TUPLE(x16),
- TYPE_TUPLE(u8),
- TYPE_TUPLE(s8),
- TYPE_TUPLE(x8),
+ FUNC_TYPES,
{ NULL, 0, 0 }
};
+#undef TYPE_TUPLE
+#define TYPE_TUPLE(type) FUNC_TYPE_##type
+
+enum {
+ FUNC_TYPES,
+ FUNC_TYPE_MAX
+};
+
static int max_args __read_mostly = -1;
/**
@@ -230,6 +242,7 @@ static int add_arg(struct func_event *fevent, int ftype, int unsign)
if (!unsign)
arg->sign = func_type->sign;
arg->offset = ALIGN(fevent->arg_offset, arg->size);
+ arg->func_type = ftype;
arg->arg = fevent->arg_cnt;
fevent->arg_offset = arg->offset + arg->size;
--
2.15.1