The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/2] gdb/scripts: lx-dmesg: Cast log_buf to void* for addr fetch
@ 2017-06-23 14:20 Leonard Crestez
  2017-06-23 14:20 ` [PATCH 2/2] scripts/gdb: lx-dmesg: Use errors=replace for decoding Leonard Crestez
  2017-06-23 16:02 ` [PATCH 1/2] gdb/scripts: lx-dmesg: Cast log_buf to void* for addr fetch Jan Kiszka
  0 siblings, 2 replies; 6+ messages in thread
From: Leonard Crestez @ 2017-06-23 14:20 UTC (permalink / raw)
  To: Kieran Bingham, Jan Kiszka; +Cc: linux-kernel

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@nxp.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..6f8d2b2 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-06-23 20:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-23 14:20 [PATCH 1/2] gdb/scripts: lx-dmesg: Cast log_buf to void* for addr fetch Leonard Crestez
2017-06-23 14:20 ` [PATCH 2/2] scripts/gdb: lx-dmesg: Use errors=replace for decoding Leonard Crestez
2017-06-23 16:02   ` Jan Kiszka
2017-06-23 17:29     ` Leonard Crestez
2017-06-23 20:04       ` Jan Kiszka
2017-06-23 16:02 ` [PATCH 1/2] gdb/scripts: lx-dmesg: Cast log_buf to void* for addr fetch Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox