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: Daniel Borkmann <daniel@iogearbox.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Daniel Borkmann 2017-01-25 02:28:17 +01:00 committed by David S. Miller
parent 2acae0d5b0
commit 0fe0559179
4 changed files with 34 additions and 3 deletions

View file

@ -831,6 +831,7 @@ static void free_arg(struct print_arg *arg)
free_flag_sym(arg->symbol.symbols);
break;
case PRINT_HEX:
case PRINT_HEX_STR:
free_arg(arg->hex.field);
free_arg(arg->hex.size);
break;
@ -2629,10 +2630,11 @@ process_symbols(struct event_format *event, struct print_arg *arg, char **tok)
}
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));
arg->type = PRINT_HEX;
arg->type = type;
if (alloc_and_process_delim(event, ",", &arg->hex.field))
goto out;
@ -2650,6 +2652,19 @@ process_hex(struct event_format *event, struct print_arg *arg, char **tok)
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
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,
free_token(token);
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) {
free_token(token);
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
case PRINT_SYMBOL:
case PRINT_INT_ARRAY:
case PRINT_HEX:
case PRINT_HEX_STR:
break;
case PRINT_TYPE:
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,
}
break;
case PRINT_HEX:
case PRINT_HEX_STR:
if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) {
unsigned long offset;
offset = pevent_read_number(pevent,
@ -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);
for (i = 0; i < len; i++) {
if (i)
if (i && arg->type == PRINT_HEX)
trace_seq_putc(s, ' ');
trace_seq_printf(s, "%02x", hex[i]);
}
@ -5727,6 +5748,13 @@ static void print_args(struct print_arg *args)
print_args(args->hex.size);
printf(")");
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:
printf("__print_array(");
print_args(args->int_array.field);

View file

@ -292,6 +292,7 @@ enum print_arg_type {
PRINT_FUNC,
PRINT_BITMASK,
PRINT_DYNAMIC_ARRAY_LEN,
PRINT_HEX_STR,
};
struct print_arg {

View file

@ -217,6 +217,7 @@ static void define_event_symbols(struct event_format *event,
cur_field_name);
break;
case PRINT_HEX:
case PRINT_HEX_STR:
define_event_symbols(event, ev_name, args->hex.field);
define_event_symbols(event, ev_name, args->hex.size);
break;

View file

@ -236,6 +236,7 @@ static void define_event_symbols(struct event_format *event,
cur_field_name);
break;
case PRINT_HEX:
case PRINT_HEX_STR:
define_event_symbols(event, ev_name, args->hex.field);
define_event_symbols(event, ev_name, args->hex.size);
break;