Commit 0fe05591 authored by Daniel Borkmann's avatar Daniel Borkmann Committed by David S. Miller

lib, traceevent: add PRINT_HEX_STR variant

Add support for the __print_hex_str() macro that was added for
tracing, so that user space tools such as perf can understand
it as well.
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2acae0d5
...@@ -831,6 +831,7 @@ static void free_arg(struct print_arg *arg) ...@@ -831,6 +831,7 @@ static void free_arg(struct print_arg *arg)
free_flag_sym(arg->symbol.symbols); free_flag_sym(arg->symbol.symbols);
break; break;
case PRINT_HEX: case PRINT_HEX:
case PRINT_HEX_STR:
free_arg(arg->hex.field); free_arg(arg->hex.field);
free_arg(arg->hex.size); free_arg(arg->hex.size);
break; break;
...@@ -2629,10 +2630,11 @@ process_symbols(struct event_format *event, struct print_arg *arg, char **tok) ...@@ -2629,10 +2630,11 @@ process_symbols(struct event_format *event, struct print_arg *arg, char **tok)
} }
static enum event_type static enum event_type
process_hex(struct event_format *event, struct print_arg *arg, char **tok) process_hex_common(struct event_format *event, struct print_arg *arg,
char **tok, enum print_arg_type type)
{ {
memset(arg, 0, sizeof(*arg)); memset(arg, 0, sizeof(*arg));
arg->type = PRINT_HEX; arg->type = type;
if (alloc_and_process_delim(event, ",", &arg->hex.field)) if (alloc_and_process_delim(event, ",", &arg->hex.field))
goto out; goto out;
...@@ -2650,6 +2652,19 @@ process_hex(struct event_format *event, struct print_arg *arg, char **tok) ...@@ -2650,6 +2652,19 @@ process_hex(struct event_format *event, struct print_arg *arg, char **tok)
return EVENT_ERROR; return EVENT_ERROR;
} }
static enum event_type
process_hex(struct event_format *event, struct print_arg *arg, char **tok)
{
return process_hex_common(event, arg, tok, PRINT_HEX);
}
static enum event_type
process_hex_str(struct event_format *event, struct print_arg *arg,
char **tok)
{
return process_hex_common(event, arg, tok, PRINT_HEX_STR);
}
static enum event_type static enum event_type
process_int_array(struct event_format *event, struct print_arg *arg, char **tok) process_int_array(struct event_format *event, struct print_arg *arg, char **tok)
{ {
...@@ -3009,6 +3024,10 @@ process_function(struct event_format *event, struct print_arg *arg, ...@@ -3009,6 +3024,10 @@ process_function(struct event_format *event, struct print_arg *arg,
free_token(token); free_token(token);
return process_hex(event, arg, tok); return process_hex(event, arg, tok);
} }
if (strcmp(token, "__print_hex_str") == 0) {
free_token(token);
return process_hex_str(event, arg, tok);
}
if (strcmp(token, "__print_array") == 0) { if (strcmp(token, "__print_array") == 0) {
free_token(token); free_token(token);
return process_int_array(event, arg, tok); return process_int_array(event, arg, tok);
...@@ -3547,6 +3566,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg ...@@ -3547,6 +3566,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
case PRINT_SYMBOL: case PRINT_SYMBOL:
case PRINT_INT_ARRAY: case PRINT_INT_ARRAY:
case PRINT_HEX: case PRINT_HEX:
case PRINT_HEX_STR:
break; break;
case PRINT_TYPE: case PRINT_TYPE:
val = eval_num_arg(data, size, event, arg->typecast.item); val = eval_num_arg(data, size, event, arg->typecast.item);
...@@ -3962,6 +3982,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, ...@@ -3962,6 +3982,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
} }
break; break;
case PRINT_HEX: case PRINT_HEX:
case PRINT_HEX_STR:
if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) { if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) {
unsigned long offset; unsigned long offset;
offset = pevent_read_number(pevent, offset = pevent_read_number(pevent,
...@@ -3981,7 +4002,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, ...@@ -3981,7 +4002,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
} }
len = eval_num_arg(data, size, event, arg->hex.size); len = eval_num_arg(data, size, event, arg->hex.size);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
if (i) if (i && arg->type == PRINT_HEX)
trace_seq_putc(s, ' '); trace_seq_putc(s, ' ');
trace_seq_printf(s, "%02x", hex[i]); trace_seq_printf(s, "%02x", hex[i]);
} }
...@@ -5727,6 +5748,13 @@ static void print_args(struct print_arg *args) ...@@ -5727,6 +5748,13 @@ static void print_args(struct print_arg *args)
print_args(args->hex.size); print_args(args->hex.size);
printf(")"); printf(")");
break; break;
case PRINT_HEX_STR:
printf("__print_hex_str(");
print_args(args->hex.field);
printf(", ");
print_args(args->hex.size);
printf(")");
break;
case PRINT_INT_ARRAY: case PRINT_INT_ARRAY:
printf("__print_array("); printf("__print_array(");
print_args(args->int_array.field); print_args(args->int_array.field);
......
...@@ -292,6 +292,7 @@ enum print_arg_type { ...@@ -292,6 +292,7 @@ enum print_arg_type {
PRINT_FUNC, PRINT_FUNC,
PRINT_BITMASK, PRINT_BITMASK,
PRINT_DYNAMIC_ARRAY_LEN, PRINT_DYNAMIC_ARRAY_LEN,
PRINT_HEX_STR,
}; };
struct print_arg { struct print_arg {
......
...@@ -217,6 +217,7 @@ static void define_event_symbols(struct event_format *event, ...@@ -217,6 +217,7 @@ static void define_event_symbols(struct event_format *event,
cur_field_name); cur_field_name);
break; break;
case PRINT_HEX: case PRINT_HEX:
case PRINT_HEX_STR:
define_event_symbols(event, ev_name, args->hex.field); define_event_symbols(event, ev_name, args->hex.field);
define_event_symbols(event, ev_name, args->hex.size); define_event_symbols(event, ev_name, args->hex.size);
break; break;
......
...@@ -236,6 +236,7 @@ static void define_event_symbols(struct event_format *event, ...@@ -236,6 +236,7 @@ static void define_event_symbols(struct event_format *event,
cur_field_name); cur_field_name);
break; break;
case PRINT_HEX: case PRINT_HEX:
case PRINT_HEX_STR:
define_event_symbols(event, ev_name, args->hex.field); define_event_symbols(event, ev_name, args->hex.field);
define_event_symbols(event, ev_name, args->hex.size); define_event_symbols(event, ev_name, args->hex.size);
break; break;
......
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