Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751833AbdGGJPz (ORCPT ); Fri, 7 Jul 2017 05:15:55 -0400 Received: from thoth.sbs.de ([192.35.17.2]:33264 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750778AbdGGJPx (ORCPT ); Fri, 7 Jul 2017 05:15:53 -0400 Subject: Re: [PATCH v2 1/2] scripts/gdb: lx-dmesg: Cast log_buf to void* for addr fetch To: Leonard Crestez , Kieran Bingham , Andrew Morton Cc: linux-kernel@vger.kernel.org References: From: Jan Kiszka Message-ID: <7c6b5877-79f0-af01-f622-e5d7cd0bd866@siemens.com> Date: Fri, 7 Jul 2017 11:15:48 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1826 Lines: 51 On 2017-06-26 14:52, Leonard Crestez wrote: > 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 "", line 1, in > 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 > Reviewed-by: Jan Kiszka > > --- > 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 > --- > 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")) > Acked-by: Jan Kiszka Andrew, please pick this up. Jan -- Siemens AG, Corporate Technology, CT RDA ITP SES-DE Corporate Competence Center Embedded Linux