diff options
Diffstat (limited to 'tools/perf/util/scripting-engines/trace-event-python.c')
-rw-r--r-- | tools/perf/util/scripting-engines/trace-event-python.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index ff134700bf30..e0203b979474 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c | |||
@@ -273,7 +273,7 @@ static PyObject *get_field_numeric_entry(struct event_format *event, | |||
273 | struct format_field *field, void *data) | 273 | struct format_field *field, void *data) |
274 | { | 274 | { |
275 | bool is_array = field->flags & FIELD_IS_ARRAY; | 275 | bool is_array = field->flags & FIELD_IS_ARRAY; |
276 | PyObject *obj, *list = NULL; | 276 | PyObject *obj = NULL, *list = NULL; |
277 | unsigned long long val; | 277 | unsigned long long val; |
278 | unsigned int item_size, n_items, i; | 278 | unsigned int item_size, n_items, i; |
279 | 279 | ||
@@ -386,13 +386,12 @@ exit: | |||
386 | return pylist; | 386 | return pylist; |
387 | } | 387 | } |
388 | 388 | ||
389 | |||
390 | static void python_process_tracepoint(struct perf_sample *sample, | 389 | static void python_process_tracepoint(struct perf_sample *sample, |
391 | struct perf_evsel *evsel, | 390 | struct perf_evsel *evsel, |
392 | struct addr_location *al) | 391 | struct addr_location *al) |
393 | { | 392 | { |
394 | struct event_format *event = evsel->tp_format; | 393 | struct event_format *event = evsel->tp_format; |
395 | PyObject *handler, *context, *t, *obj, *callchain; | 394 | PyObject *handler, *context, *t, *obj = NULL, *callchain; |
396 | PyObject *dict = NULL; | 395 | PyObject *dict = NULL; |
397 | static char handler_name[256]; | 396 | static char handler_name[256]; |
398 | struct format_field *field; | 397 | struct format_field *field; |
@@ -457,14 +456,26 @@ static void python_process_tracepoint(struct perf_sample *sample, | |||
457 | pydict_set_item_string_decref(dict, "common_callchain", callchain); | 456 | pydict_set_item_string_decref(dict, "common_callchain", callchain); |
458 | } | 457 | } |
459 | for (field = event->format.fields; field; field = field->next) { | 458 | for (field = event->format.fields; field; field = field->next) { |
460 | if (field->flags & FIELD_IS_STRING) { | 459 | unsigned int offset, len; |
461 | int offset; | 460 | unsigned long long val; |
461 | |||
462 | if (field->flags & FIELD_IS_ARRAY) { | ||
463 | offset = field->offset; | ||
464 | len = field->size; | ||
462 | if (field->flags & FIELD_IS_DYNAMIC) { | 465 | if (field->flags & FIELD_IS_DYNAMIC) { |
463 | offset = *(int *)(data + field->offset); | 466 | val = pevent_read_number(scripting_context->pevent, |
467 | data + offset, len); | ||
468 | offset = val; | ||
469 | len = offset >> 16; | ||
464 | offset &= 0xffff; | 470 | offset &= 0xffff; |
465 | } else | 471 | } |
466 | offset = field->offset; | 472 | if (field->flags & FIELD_IS_STRING && |
467 | obj = PyString_FromString((char *)data + offset); | 473 | is_printable_array(data + offset, len)) { |
474 | obj = PyString_FromString((char *) data + offset); | ||
475 | } else { | ||
476 | obj = PyByteArray_FromStringAndSize((const char *) data + offset, len); | ||
477 | field->flags &= ~FIELD_IS_STRING; | ||
478 | } | ||
468 | } else { /* FIELD_IS_NUMERIC */ | 479 | } else { /* FIELD_IS_NUMERIC */ |
469 | obj = get_field_numeric_entry(event, field, data); | 480 | obj = get_field_numeric_entry(event, field, data); |
470 | } | 481 | } |