Skip to content

Commit 7832931

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 bbc7cd5 commit 7832931

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

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)