Skip to content

Commit 7c689c8

Browse files
mhiramatrostedt
authored andcommitted
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 <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Tom Zanussi <[email protected]> Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent cd77290 commit 7c689c8

File tree

7 files changed

+14
-0
lines changed

7 files changed

+14
-0
lines changed

tools/perf/builtin-trace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,6 +2726,8 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
27262726
offset = format_field__intval(field, sample, evsel->needs_swap);
27272727
syscall_arg.len = offset >> 16;
27282728
offset &= 0xffff;
2729+
if (field->flags & TEP_FIELD_IS_RELATIVE)
2730+
offset += field->offset + field->size;
27292731
}
27302732

27312733
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
@@ -318,6 +318,8 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
318318
offset = tmp_val;
319319
len = offset >> 16;
320320
offset &= 0xffff;
321+
if (flags & TEP_FIELD_IS_RELATIVE)
322+
offset += fmtf->offset + fmtf->size;
321323
}
322324

323325
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
@@ -2706,6 +2706,8 @@ void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const char
27062706
if (field->flags & TEP_FIELD_IS_DYNAMIC) {
27072707
offset = *(int *)(sample->raw_data + field->offset);
27082708
offset &= 0xffff;
2709+
if (field->flags & TEP_FIELD_IS_RELATIVE)
2710+
offset += field->offset + field->size;
27092711
}
27102712

27112713
return sample->raw_data + offset;

tools/perf/util/python.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ tracepoint_field(struct pyrf_event *pe, struct tep_format_field *field)
428428
offset = val;
429429
len = offset >> 16;
430430
offset &= 0xffff;
431+
if (field->flags & TEP_FIELD_IS_RELATIVE)
432+
offset += field->offset + field->size;
431433
}
432434
if (field->flags & TEP_FIELD_IS_STRING &&
433435
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
@@ -392,6 +392,8 @@ static void perl_process_tracepoint(struct perf_sample *sample,
392392
if (field->flags & TEP_FIELD_IS_DYNAMIC) {
393393
offset = *(int *)(data + field->offset);
394394
offset &= 0xffff;
395+
if (field->flags & TEP_FIELD_IS_RELATIVE)
396+
offset += field->offset + field->size;
395397
} else
396398
offset = field->offset;
397399
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
@@ -942,6 +942,8 @@ static void python_process_tracepoint(struct perf_sample *sample,
942942
offset = val;
943943
len = offset >> 16;
944944
offset &= 0xffff;
945+
if (field->flags & TEP_FIELD_IS_RELATIVE)
946+
offset += field->offset + field->size;
945947
}
946948
if (field->flags & TEP_FIELD_IS_STRING &&
947949
is_printable_array(data + offset, len)) {

tools/perf/util/sort.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,6 +2365,8 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
23652365
tep_read_number_field(field, a->raw_data, &dyn);
23662366
offset = dyn & 0xffff;
23672367
size = (dyn >> 16) & 0xffff;
2368+
if (field->flags & TEP_FIELD_IS_RELATIVE)
2369+
offset += field->offset + field->size;
23682370

23692371
/* record max width for output */
23702372
if (size > hde->dynamic_len)

0 commit comments

Comments
 (0)