gdb/dmesg: replace non-printable NULL terminator

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
xuxingliang
2024-10-16 12:23:20 +08:00
committed by Xiang Xiao
parent 472b49e11f
commit 4e6026efe6
+3
View File
@@ -44,5 +44,8 @@ class Dmesg(gdb.Command):
inf = gdb.selected_inferior()
buf = bytes(inf.read_memory(rl_head["rl_buffer"], rl_bufsize))
buf = buf.replace(
b"\0", "".encode("utf-8")
) # NULL is valid utf-8 but not printable
gdb.write(buf.decode("utf-8", errors="replace"))
gdb.write("\n")