Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/perf: Add '__rel_loc' event field parsing support

Add new '__rel_loc' dynamic data location attribute support.
This type attribute is similar to the '__data_loc' but records the
offset from the field itself.
The libtraceevent adds TEP_FIELD_IS_RELATIVE to the
'tep_format_field::flags' with TEP_FIELD_IS_DYNAMIC for'__rel_loc'.

Link: https://lkml.kernel.org/r/163757344810.510314.12449413842136229871.stgit@devnote2

Cc: Beau Belgrave <beaub@linux.microsoft.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Masami Hiramatsu and committed by
Steven Rostedt (VMware)
7c689c83 cd772904

+14
+2
tools/perf/builtin-trace.c
··· 2726 2726 offset = format_field__intval(field, sample, evsel->needs_swap); 2727 2727 syscall_arg.len = offset >> 16; 2728 2728 offset &= 0xffff; 2729 + if (field->flags & TEP_FIELD_IS_RELATIVE) 2730 + offset += field->offset + field->size; 2729 2731 } 2730 2732 2731 2733 val = (uintptr_t)(sample->raw_data + offset);
+2
tools/perf/util/data-convert-bt.c
··· 318 318 offset = tmp_val; 319 319 len = offset >> 16; 320 320 offset &= 0xffff; 321 + if (flags & TEP_FIELD_IS_RELATIVE) 322 + offset += fmtf->offset + fmtf->size; 321 323 } 322 324 323 325 if (flags & TEP_FIELD_IS_ARRAY) {
+2
tools/perf/util/evsel.c
··· 2706 2706 if (field->flags & TEP_FIELD_IS_DYNAMIC) { 2707 2707 offset = *(int *)(sample->raw_data + field->offset); 2708 2708 offset &= 0xffff; 2709 + if (field->flags & TEP_FIELD_IS_RELATIVE) 2710 + offset += field->offset + field->size; 2709 2711 } 2710 2712 2711 2713 return sample->raw_data + offset;
+2
tools/perf/util/python.c
··· 428 428 offset = val; 429 429 len = offset >> 16; 430 430 offset &= 0xffff; 431 + if (field->flags & TEP_FIELD_IS_RELATIVE) 432 + offset += field->offset + field->size; 431 433 } 432 434 if (field->flags & TEP_FIELD_IS_STRING && 433 435 is_printable_array(data + offset, len)) {
+2
tools/perf/util/scripting-engines/trace-event-perl.c
··· 392 392 if (field->flags & TEP_FIELD_IS_DYNAMIC) { 393 393 offset = *(int *)(data + field->offset); 394 394 offset &= 0xffff; 395 + if (field->flags & TEP_FIELD_IS_RELATIVE) 396 + offset += field->offset + field->size; 395 397 } else 396 398 offset = field->offset; 397 399 XPUSHs(sv_2mortal(newSVpv((char *)data + offset, 0)));
+2
tools/perf/util/scripting-engines/trace-event-python.c
··· 942 942 offset = val; 943 943 len = offset >> 16; 944 944 offset &= 0xffff; 945 + if (field->flags & TEP_FIELD_IS_RELATIVE) 946 + offset += field->offset + field->size; 945 947 } 946 948 if (field->flags & TEP_FIELD_IS_STRING && 947 949 is_printable_array(data + offset, len)) {
+2
tools/perf/util/sort.c
··· 2365 2365 tep_read_number_field(field, a->raw_data, &dyn); 2366 2366 offset = dyn & 0xffff; 2367 2367 size = (dyn >> 16) & 0xffff; 2368 + if (field->flags & TEP_FIELD_IS_RELATIVE) 2369 + offset += field->offset + field->size; 2368 2370 2369 2371 /* record max width for output */ 2370 2372 if (size > hde->dynamic_len)