Commit b30f75eb authored by Howard Cochran's avatar Howard Cochran Committed by Arnaldo Carvalho de Melo

tools lib traceevent: Handle __print_hex(__get_dynamic_array(fieldname), len)

The kernel has a few events with a format similar to this excerpt:
        field:unsigned int len;     offset:12;      size:4; signed:0;
        field:__data_loc unsigned char[] data_array;  offset:16;      size:4; signed:0;
print fmt: "%s", __print_hex(__get_dynamic_array(data_array), REC->len)

trace-cmd could already parse that arg correctly, but print_str_arg()
was unable to handle the first parameter being a dynamic array. (It
just printed a "field not found" warning).

Teach print_str_arg's PRINT_HEX case to handle the nested
PRINT_DYNAMIC_ARRAY correctly. The output now matches the kernel's own
formatting for this case.
Signed-off-by: default avatarHoward Cochran <hcochran@lexmark.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1381503349-12271-1-git-send-email-hcochran@lexmark.com
[ Removed "polish compare", we don't do that here ]
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0970b5f4
...@@ -3588,15 +3588,23 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, ...@@ -3588,15 +3588,23 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
} }
break; break;
case PRINT_HEX: case PRINT_HEX:
field = arg->hex.field->field.field; if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) {
if (!field) { unsigned long offset;
str = arg->hex.field->field.name; offset = pevent_read_number(pevent,
field = pevent_find_any_field(event, str); data + arg->hex.field->dynarray.field->offset,
if (!field) arg->hex.field->dynarray.field->size);
goto out_warning_field; hex = data + (offset & 0xffff);
arg->hex.field->field.field = field; } else {
field = arg->hex.field->field.field;
if (!field) {
str = arg->hex.field->field.name;
field = pevent_find_any_field(event, str);
if (!field)
goto out_warning_field;
arg->hex.field->field.field = field;
}
hex = data + field->offset;
} }
hex = data + field->offset;
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)
......
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