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

perf tools: Check if libtracevent has TEP_FIELD_IS_RELATIVE

Some distros have older versions of libtraceevent where
TEP_FIELD_IS_RELATIVE and its associated semantics are not present, so
we need to check if the version has it, it was introduced in
libtraceevent 1.5.0.

Reported-by: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Tested-by: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Cc: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+18 -1
+4
tools/perf/Makefile.config
··· 1197 1197 LIBTRACEEVENT_VERSION_CPP := $(shell expr $(LIBTRACEEVENT_VERSION_1) \* 255 \* 255 + $(LIBTRACEEVENT_VERSION_2) \* 255 + $(LIBTRACEEVENT_VERSION_3)) 1198 1198 CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP) 1199 1199 $(call detected,CONFIG_LIBTRACEEVENT) 1200 + LIBTRACEEVENT_VERSION_WITH_TEP_FIELD_IS_RELATIVE := $(shell expr 1 \* 255 \* 255 + 5 \* 255 + 0) # 1.5.0 1201 + ifeq ($(shell test $(LIBTRACEEVENT_VERSION_CPP) -gt $(LIBTRACEEVENT_VERSION_WITH_TEP_FIELD_IS_RELATIVE); echo $$?),0) 1202 + CFLAGS += -DHAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE 1203 + endif 1200 1204 else 1201 1205 dummy := $(warning Warning: libtraceevent is missing limiting functionality, please install libtraceevent-dev/libtraceevent-devel) 1202 1206 endif
+2
tools/perf/builtin-trace.c
··· 2729 2729 offset = format_field__intval(field, sample, evsel->needs_swap); 2730 2730 syscall_arg.len = offset >> 16; 2731 2731 offset &= 0xffff; 2732 + #ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE 2732 2733 if (field->flags & TEP_FIELD_IS_RELATIVE) 2733 2734 offset += field->offset + field->size; 2735 + #endif 2734 2736 } 2735 2737 2736 2738 val = (uintptr_t)(sample->raw_data + offset);
+2
tools/perf/util/data-convert-bt.c
··· 322 322 offset = tmp_val; 323 323 len = offset >> 16; 324 324 offset &= 0xffff; 325 + #ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE 325 326 if (flags & TEP_FIELD_IS_RELATIVE) 326 327 offset += fmtf->offset + fmtf->size; 328 + #endif 327 329 } 328 330 329 331 if (flags & TEP_FIELD_IS_ARRAY) {
+2
tools/perf/util/evsel.c
··· 2784 2784 if (field->flags & TEP_FIELD_IS_DYNAMIC) { 2785 2785 offset = *(int *)(sample->raw_data + field->offset); 2786 2786 offset &= 0xffff; 2787 + #ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE 2787 2788 if (field->flags & TEP_FIELD_IS_RELATIVE) 2788 2789 offset += field->offset + field->size; 2790 + #endif 2789 2791 } 2790 2792 2791 2793 return sample->raw_data + offset;
+2
tools/perf/util/python.c
··· 442 442 offset = val; 443 443 len = offset >> 16; 444 444 offset &= 0xffff; 445 + #ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE 445 446 if (field->flags & TEP_FIELD_IS_RELATIVE) 446 447 offset += field->offset + field->size; 448 + #endif 447 449 } 448 450 if (field->flags & TEP_FIELD_IS_STRING && 449 451 is_printable_array(data + offset, len)) {
+2
tools/perf/util/scripting-engines/trace-event-perl.c
··· 393 393 if (field->flags & TEP_FIELD_IS_DYNAMIC) { 394 394 offset = *(int *)(data + field->offset); 395 395 offset &= 0xffff; 396 + #ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE 396 397 if (field->flags & TEP_FIELD_IS_RELATIVE) 397 398 offset += field->offset + field->size; 399 + #endif 398 400 } else 399 401 offset = field->offset; 400 402 XPUSHs(sv_2mortal(newSVpv((char *)data + offset, 0)));
+2
tools/perf/util/scripting-engines/trace-event-python.c
··· 994 994 offset = val; 995 995 len = offset >> 16; 996 996 offset &= 0xffff; 997 + #ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE 997 998 if (field->flags & TEP_FIELD_IS_RELATIVE) 998 999 offset += field->offset + field->size; 1000 + #endif 999 1001 } 1000 1002 if (field->flags & TEP_FIELD_IS_STRING && 1001 1003 is_printable_array(data + offset, len)) {
+2 -1
tools/perf/util/sort.c
··· 2568 2568 tep_read_number_field(field, a->raw_data, &dyn); 2569 2569 offset = dyn & 0xffff; 2570 2570 size = (dyn >> 16) & 0xffff; 2571 + #ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE 2571 2572 if (field->flags & TEP_FIELD_IS_RELATIVE) 2572 2573 offset += field->offset + field->size; 2573 - 2574 + #endif 2574 2575 /* record max width for output */ 2575 2576 if (size > hde->dynamic_len) 2576 2577 hde->dynamic_len = size;