Skip to content

Commit b9a49f8

Browse files
committed
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>
1 parent 4171925 commit b9a49f8

File tree

8 files changed

+18
-1
lines changed

8 files changed

+18
-1
lines changed

tools/perf/Makefile.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,10 @@ ifneq ($(NO_LIBTRACEEVENT),1)
11971197
LIBTRACEEVENT_VERSION_CPP := $(shell expr $(LIBTRACEEVENT_VERSION_1) \* 255 \* 255 + $(LIBTRACEEVENT_VERSION_2) \* 255 + $(LIBTRACEEVENT_VERSION_3))
11981198
CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP)
11991199
$(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
12001204
else
12011205
dummy := $(warning Warning: libtraceevent is missing limiting functionality, please install libtraceevent-dev/libtraceevent-devel)
12021206
endif

tools/perf/builtin-trace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,8 +2729,10 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
27292729
offset = format_field__intval(field, sample, evsel->needs_swap);
27302730
syscall_arg.len = offset >> 16;
27312731
offset &= 0xffff;
2732+
#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
27322733
if (field->flags & TEP_FIELD_IS_RELATIVE)
27332734
offset += field->offset + field->size;
2735+
#endif
27342736
}
27352737

27362738
val = (uintptr_t)(sample->raw_data + offset);

tools/perf/util/data-convert-bt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,10 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
322322
offset = tmp_val;
323323
len = offset >> 16;
324324
offset &= 0xffff;
325+
#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
325326
if (flags & TEP_FIELD_IS_RELATIVE)
326327
offset += fmtf->offset + fmtf->size;
328+
#endif
327329
}
328330

329331
if (flags & TEP_FIELD_IS_ARRAY) {

tools/perf/util/evsel.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,8 +2784,10 @@ void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const char
27842784
if (field->flags & TEP_FIELD_IS_DYNAMIC) {
27852785
offset = *(int *)(sample->raw_data + field->offset);
27862786
offset &= 0xffff;
2787+
#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
27872788
if (field->flags & TEP_FIELD_IS_RELATIVE)
27882789
offset += field->offset + field->size;
2790+
#endif
27892791
}
27902792

27912793
return sample->raw_data + offset;

tools/perf/util/python.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,10 @@ tracepoint_field(struct pyrf_event *pe, struct tep_format_field *field)
442442
offset = val;
443443
len = offset >> 16;
444444
offset &= 0xffff;
445+
#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
445446
if (field->flags & TEP_FIELD_IS_RELATIVE)
446447
offset += field->offset + field->size;
448+
#endif
447449
}
448450
if (field->flags & TEP_FIELD_IS_STRING &&
449451
is_printable_array(data + offset, len)) {

tools/perf/util/scripting-engines/trace-event-perl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,10 @@ static void perl_process_tracepoint(struct perf_sample *sample,
393393
if (field->flags & TEP_FIELD_IS_DYNAMIC) {
394394
offset = *(int *)(data + field->offset);
395395
offset &= 0xffff;
396+
#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
396397
if (field->flags & TEP_FIELD_IS_RELATIVE)
397398
offset += field->offset + field->size;
399+
#endif
398400
} else
399401
offset = field->offset;
400402
XPUSHs(sv_2mortal(newSVpv((char *)data + offset, 0)));

tools/perf/util/scripting-engines/trace-event-python.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,8 +994,10 @@ static void python_process_tracepoint(struct perf_sample *sample,
994994
offset = val;
995995
len = offset >> 16;
996996
offset &= 0xffff;
997+
#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
997998
if (field->flags & TEP_FIELD_IS_RELATIVE)
998999
offset += field->offset + field->size;
1000+
#endif
9991001
}
10001002
if (field->flags & TEP_FIELD_IS_STRING &&
10011003
is_printable_array(data + offset, len)) {

tools/perf/util/sort.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2568,9 +2568,10 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
25682568
tep_read_number_field(field, a->raw_data, &dyn);
25692569
offset = dyn & 0xffff;
25702570
size = (dyn >> 16) & 0xffff;
2571+
#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
25712572
if (field->flags & TEP_FIELD_IS_RELATIVE)
25722573
offset += field->offset + field->size;
2573-
2574+
#endif
25742575
/* record max width for output */
25752576
if (size > hde->dynamic_len)
25762577
hde->dynamic_len = size;

0 commit comments

Comments
 (0)