Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1673657 > unrolled thread

Re: [PATCH 1/2] gdb/scripts: lx-dmesg: Cast log_buf to void* for addr fetch

Started byJan Kiszka <jan.kiszka@siemens.com>
First post2017-06-23 18:10 +0200
Last post2017-06-23 18:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 1/2] gdb/scripts: lx-dmesg: Cast log_buf to void* for addr  fetch Jan Kiszka <jan.kiszka@siemens.com> - 2017-06-23 18:10 +0200

#1673657 — Re: [PATCH 1/2] gdb/scripts: lx-dmesg: Cast log_buf to void* for addr fetch

FromJan Kiszka <jan.kiszka@siemens.com>
Date2017-06-23 18:10 +0200
SubjectRe: [PATCH 1/2] gdb/scripts: lx-dmesg: Cast log_buf to void* for addr fetch
Message-ID<tVzjI-4mL-19@gated-at.bofh.it>
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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web