Wednesday, October 23, 2019

Error while running "lx-dmesg" in gdb

The error that I saw with on kernel 5.3.1 with Python 2.7.5 is the following:

(gdb) lx-dmesg
Python Exception argument 1 must be string without null bytes, not str:
Error occurred in Python: argument 1 must be string without null bytes, not str
(gdb)


The reason of this is because the ascii string "msg" in dmesg.py get from the memory has the embedded null bytes. The fix is to replace these bytes with space or whatever you want, like this:

msg = msg.encode(encoding='utf8', errors='replace').replace('\x00', ' ')