Skip to content

Commit ca3e994

Browse files
author
Jyri Sarha
committed
tools: debug_stream.py: Add support for text messages
Add support for showing DEBUG_STREAM_RECORD_ID_TEXT_MSG messages that can be sent from firmware code with sd_msg() command. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 06f5dc8 commit ca3e994

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

tools/debug_stream/debug_stream.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class DebugStreamRecord(ctypes.Structure):
4646
("size_words", ctypes.c_uint),
4747
]
4848

49-
5049
class CPUInfo(ctypes.Structure):
5150
"""
5251
Thread Info record header
@@ -73,6 +72,17 @@ class ThreadInfo(ctypes.Structure):
7372
]
7473

7574

75+
class TextMsg(ctypes.Structure):
76+
"""
77+
Text Msg record header
78+
"""
79+
80+
_pack_ = 1
81+
_fields_ = [
82+
("hdr", DebugStreamRecord),
83+
]
84+
85+
7686
WSIZE = ctypes.sizeof(ctypes.c_uint)
7787

7888

@@ -83,6 +93,7 @@ class RecordPrinter:
8393

8494
RECORD_ID_UNINITIALIZED = 0
8595
RECORD_ID_THREAD_INFO = 1
96+
RECORD_ID_TEXT_MSG = 2
8697

8798
def print_record(self, record, cpu):
8899
"""prints debug-stream record"""
@@ -92,7 +103,9 @@ def print_record(self, record, cpu):
92103
)
93104
if recp.contents.id == self.RECORD_ID_THREAD_INFO:
94105
return self.print_thread_info(record, cpu)
95-
logging.warning("cpu %u: Unsupported recodrd type %u", cpu, recp.contents.id)
106+
if recp.contents.id == self.RECORD_ID_TEXT_MSG:
107+
return self.print_text_msg(record, cpu)
108+
logging.warning("cpu %u: Unsupported record type %u", cpu, recp.contents.id)
96109
return True
97110

98111
def print_thread_info(self, record, cpu):
@@ -141,6 +154,17 @@ def print_thread_info(self, record, cpu):
141154
)
142155
return True
143156

157+
def print_text_msg(self, record, cpu):
158+
"""prints text-msg record"""
159+
if len(record) - ctypes.sizeof(TextMsg) < 0:
160+
logging.info("Buffer end reached, parsing failed")
161+
return False
162+
buffer = (
163+
ctypes.c_ubyte * (len(record) - ctypes.sizeof(TextMsg))
164+
).from_address(ctypes.addressof(record) + ctypes.sizeof(TextMsg))
165+
msg = bytearray(buffer).decode("utf-8")
166+
print("CPU %u: %s" % (cpu, msg))
167+
return True
144168

145169
class DebugStreamSectionDescriptor(ctypes.Structure):
146170
"""

0 commit comments

Comments
 (0)