Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754104AbdFWQCk (ORCPT ); Fri, 23 Jun 2017 12:02:40 -0400 Received: from david.siemens.de ([192.35.17.14]:49630 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752776AbdFWQCj (ORCPT ); Fri, 23 Jun 2017 12:02:39 -0400 Subject: Re: [PATCH 1/2] gdb/scripts: lx-dmesg: Cast log_buf to void* for addr fetch To: Leonard Crestez , Kieran Bingham Cc: linux-kernel@vger.kernel.org References: <00d6621945ececb6c9fb360aef0efd5747439a38.1498227531.git.leonard.crestez@nxp.com> From: Jan Kiszka Message-ID: <2504bef6-0fab-32a9-9b41-db80cdcb354a@siemens.com> Date: Fri, 23 Jun 2017 18:02:27 +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: <00d6621945ececb6c9fb360aef0efd5747439a38.1498227531.git.leonard.crestez@nxp.com> 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: 1556 Lines: 45 On 2017-06-23 16:20, 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 > --- > 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) Nit: (void *) > 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")) > Looks good, makes sense to me. Reviewed-by: Jan Kiszka Jan -- Siemens AG, Corporate Technology, CT RDA ITP SES-DE Corporate Competence Center Embedded Linux