Skip to content

Commit 5443169

Browse files
author
Jyri Sarha
committed
tools: debug_stream.py: Cut text msg when first '\0' is encountered
The utf-8 decoder does not appear to be sensitive to '\0' in the buffer so cut from word boundary may produce unwanted characters at the end of the message. Make also the text message always star from the beginning of the line and not from the same line with "CPU X:" tag. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent ec9812c commit 5443169

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/debug_stream/debug_stream.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ def print_text_msg(self, record, cpu):
162162
buffer = (
163163
ctypes.c_ubyte * (len(record) - ctypes.sizeof(TextMsg))
164164
).from_address(ctypes.addressof(record) + ctypes.sizeof(TextMsg))
165-
msg = bytearray(buffer).decode("utf-8")
166-
print("CPU %u: %s" % (cpu, msg))
165+
payload = bytes(buffer)
166+
msg = payload.split(b"\0", 1)[0].decode("utf-8", errors="replace")
167+
print("CPU %u:\n%s" % (cpu, msg))
167168
return True
168169

169170
class DebugStreamSectionDescriptor(ctypes.Structure):

0 commit comments

Comments
 (0)