* [PATCH 0/1] perf script python: Garbled text in tracepoint fields
@ 2017-08-11 20:38 Arun Kalyanasundaram
2017-08-11 20:38 ` [PATCH 1/1] " Arun Kalyanasundaram
0 siblings, 1 reply; 2+ messages in thread
From: Arun Kalyanasundaram @ 2017-08-11 20:38 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, linux-kernel
Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin,
Arun Kalyanasundaram, Jiri Olsa, Daniel Borkmann,
David S . Miller, SeongJae Park, davidcc, Stephane Eranian,
Arun Kalyanasundaram
The string stored in some of the fields of tracepoint handlers has unused non-ascii characters beyond the first null ternimating character. As a result the call to is_printable_array fails and the python handlers receive the entire field as a byte array instead of just the subset of chars that represent the string.
This change calls is_printable_array with the correct length of the string instead of the entire field size.
Bug report: lkml/2017/7/18/228
Arun Kalyanasundaram (1):
perf script python: Garbled text in tracepoint fields
tools/perf/util/scripting-engines/trace-event-python.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--
2.14.0.434.g98096fd7a8-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/1] perf script python: Garbled text in tracepoint fields
2017-08-11 20:38 [PATCH 0/1] perf script python: Garbled text in tracepoint fields Arun Kalyanasundaram
@ 2017-08-11 20:38 ` Arun Kalyanasundaram
0 siblings, 0 replies; 2+ messages in thread
From: Arun Kalyanasundaram @ 2017-08-11 20:38 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, linux-kernel
Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin,
Arun Kalyanasundaram, Jiri Olsa, Daniel Borkmann,
David S . Miller, SeongJae Park, davidcc, Stephane Eranian,
Arun Kalyanasundaram
Pass the exact length of the string to is_printable_array instead of the
entire field size.
Signed-off-by: Arun Kalyanasundaram <arunkaly@google.com>
---
tools/perf/util/scripting-engines/trace-event-python.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index c7187f067d31..45cc0c6635bb 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -601,6 +601,7 @@ static void python_process_tracepoint(struct perf_sample *sample,
for (field = event->format.fields; field; field = field->next) {
unsigned int offset, len;
unsigned long long val;
+ char *end_ptr = NULL;
if (field->flags & FIELD_IS_ARRAY) {
offset = field->offset;
@@ -612,8 +613,12 @@ static void python_process_tracepoint(struct perf_sample *sample,
len = offset >> 16;
offset &= 0xffff;
}
- if (field->flags & FIELD_IS_STRING &&
- is_printable_array(data + offset, len)) {
+ /* field may contain unused chars after the null char */
+ if (field->flags & FIELD_IS_STRING)
+ end_ptr = memchr(data + offset, '\0', len);
+ if (end_ptr &&
+ is_printable_array(data + offset,
+ (int)(end_ptr - ((char *)data + offset)) + 1)) {
obj = PyString_FromString((char *) data + offset);
} else {
obj = PyByteArray_FromStringAndSize((const char *) data + offset, len);
--
2.14.0.434.g98096fd7a8-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-11 20:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-11 20:38 [PATCH 0/1] perf script python: Garbled text in tracepoint fields Arun Kalyanasundaram
2017-08-11 20:38 ` [PATCH 1/1] " Arun Kalyanasundaram
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®