diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/gdb/linux/dmesg.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/scripts/gdb/linux/dmesg.py b/scripts/gdb/linux/dmesg.py index f5a030333dfd..6d2e09a2ad2f 100644 --- a/scripts/gdb/linux/dmesg.py +++ b/scripts/gdb/linux/dmesg.py | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | # | 12 | # |
| 13 | 13 | ||
| 14 | import gdb | 14 | import gdb |
| 15 | import sys | ||
| 15 | 16 | ||
| 16 | from linux import utils | 17 | from linux import utils |
| 17 | 18 | ||
| @@ -52,13 +53,19 @@ class LxDmesg(gdb.Command): | |||
| 52 | continue | 53 | continue |
| 53 | 54 | ||
| 54 | text_len = utils.read_u16(log_buf[pos + 10:pos + 12]) | 55 | text_len = utils.read_u16(log_buf[pos + 10:pos + 12]) |
| 55 | text = log_buf[pos + 16:pos + 16 + text_len].decode() | 56 | text = log_buf[pos + 16:pos + 16 + text_len].decode( |
| 57 | encoding='utf8', errors='replace') | ||
| 56 | time_stamp = utils.read_u64(log_buf[pos:pos + 8]) | 58 | time_stamp = utils.read_u64(log_buf[pos:pos + 8]) |
| 57 | 59 | ||
| 58 | for line in text.splitlines(): | 60 | for line in text.splitlines(): |
| 59 | gdb.write("[{time:12.6f}] {line}\n".format( | 61 | msg = u"[{time:12.6f}] {line}\n".format( |
| 60 | time=time_stamp / 1000000000.0, | 62 | time=time_stamp / 1000000000.0, |
| 61 | line=line)) | 63 | line=line) |
| 64 | # With python2 gdb.write will attempt to convert unicode to | ||
| 65 | # ascii and might fail so pass an utf8-encoded str instead. | ||
| 66 | if sys.hexversion < 0x03000000: | ||
| 67 | msg = msg.encode(encoding='utf8', errors='replace') | ||
| 68 | gdb.write(msg) | ||
| 62 | 69 | ||
| 63 | pos += length | 70 | pos += length |
| 64 | 71 | ||
