[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <ba6f85dbb02ca980ebd0e2399b0649423399b565.1498481469.git.leonard.crestez@nxp.com>
Date: Mon, 26 Jun 2017 15:52:21 +0300
From: Leonard Crestez <leonard.crestez@....com>
To: Jan Kiszka <jan.kiszka@...mens.com>,
Kieran Bingham <kieran@...uared.org.uk>
CC: <linux-kernel@...r.kernel.org>
Subject: [PATCH v2 1/2] scripts/gdb: lx-dmesg: Cast log_buf to void* for addr fetch
In some cases it is possible for the str() conversion here to throw
encoding errors because log_buf might not point to valid ascii. For
example:
(gdb) python print str(gdb.parse_and_eval("log_buf"))
Traceback (most recent call last):
File "<string>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0303' in
position 24: ordinal not in range(128)
Avoid this by explicitly casting to (void *) inside the gdb expression.
Signed-off-by: Leonard Crestez <leonard.crestez@....com>
Reviewed-by: Jan Kiszka <jan.kiszka@...mens.com>
---
Changes since v1:
* Fix title (use "scripts/gdb" header instead of "gdb/scripts")
* Use "void *" instead of "void*"
Link: https://lkml.org/lkml/2017/6/23/461
Signed-off-by: Leonard Crestez <leonard.crestez@....com>
---
scripts/gdb/linux/dmesg.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/gdb/linux/dmesg.py b/scripts/gdb/linux/dmesg.py
index 5afd109..f5a0303 100644
--- a/scripts/gdb/linux/dmesg.py
+++ b/scripts/gdb/linux/dmesg.py
@@ -24,7 +24,7 @@ class LxDmesg(gdb.Command):
def invoke(self, arg, from_tty):
log_buf_addr = int(str(gdb.parse_and_eval(
- "'printk.c'::log_buf")).split()[0], 16)
+ "(void *)'printk.c'::log_buf")).split()[0], 16)
log_first_idx = int(gdb.parse_and_eval("'printk.c'::log_first_idx"))
log_next_idx = int(gdb.parse_and_eval("'printk.c'::log_next_idx"))
log_buf_len = int(gdb.parse_and_eval("'printk.c'::log_buf_len"))
--
2.7.4
Powered by blists - more mailing lists