mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Leonard Crestez <leonard.crestez@nxp.com>,
	Kieran Bingham <kieran@ksquared.org.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] gdb/scripts: lx-dmesg: Cast log_buf to void* for addr fetch
Date: Fri, 23 Jun 2017 18:02:27 +0200	[thread overview]
Message-ID: <2504bef6-0fab-32a9-9b41-db80cdcb354a@siemens.com> (raw)
In-Reply-To: <00d6621945ececb6c9fb360aef0efd5747439a38.1498227531.git.leonard.crestez@nxp.com>

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 "<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)

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.kiszka@siemens.com>

Jan

-- 
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux

      parent reply	other threads:[~2017-06-23 16:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Jan Kiszka
2017-06-23 17:29     ` Leonard Crestez
2017-06-23 20:04       ` Jan Kiszka
2017-06-23 16:02 ` Jan Kiszka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2504bef6-0fab-32a9-9b41-db80cdcb354a@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=kieran@ksquared.org.uk \
    --cc=leonard.crestez@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®