Skip to content

Commit

Permalink
scripts/gdb: decode bytestream on dmesg for Python3
Browse files Browse the repository at this point in the history
The recent fixes to lx-dmesg, now allow the command to print
successfully on Python3, however the python interpreter wraps the bytes
for each line with a b'<text>' marker.

To remove this, we need to decode the line, where .decode() will default
to 'UTF-8'

Link: http://lkml.kernel.org/r/d67ccf93f2479c94cb3399262b9b796e0dbefcf2.1462865983.git.jan.kiszka@siemens.com
Signed-off-by: Kieran Bingham <[email protected]>
Acked-by: Dom Cote <[email protected]>
Tested-by: Dom Cote <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kbingham authored and torvalds committed May 24, 2016
1 parent d21d5b9 commit b3b0842
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/gdb/linux/dmesg.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def invoke(self, arg, from_tty):
continue

text_len = utils.read_u16(log_buf[pos + 10:pos + 12])
text = log_buf[pos + 16:pos + 16 + text_len]
text = log_buf[pos + 16:pos + 16 + text_len].decode()
time_stamp = utils.read_u64(log_buf[pos:pos + 8])

for line in memoryview(text).tobytes().splitlines():
for line in text.splitlines():
gdb.write("[{time:12.6f}] {line}\n".format(
time=time_stamp / 1000000000.0,
line=line))
Expand Down

0 comments on commit b3b0842

Please sign in to comment.