From: Kieran Bingham <kieran@ksquared.org.uk>
To: "Jan Kiszka" <jan.kiszka@siemens.com>,
"André Draszik" <git@andred.net>,
linux-kernel@vger.kernel.org,
"Andrew Morton" <akpm@linux-foundation.org>
Subject: Re: [PATCH v3] scripts/gdb: make lx-dmesg command work (reliably)
Date: Wed, 31 May 2017 14:10:08 +0900 [thread overview]
Message-ID: <ae8caff8-0fc9-da0d-8468-1f139a0a67df@bingham.xyz> (raw)
In-Reply-To: <8291f1da-e902-4050-3ab7-5f669ba78fcd@siemens.com>
Hi André, Jan, Andrew,
On 26/05/17 20:28, Jan Kiszka wrote:
> On 2017-05-26 13:22, André Draszik wrote:
>> lx-dmesg needs access to the log_buf symbol from printk.c.
>> Unfortunately, the symbol log_buf also exists in BPF's
>> verifier.c and hence gdb can pick one or the other. If it
>> happens to pick BPF's log_buf, lx-dmesg doesn't work:
>>
>> (gdb) lx-dmesg
>> Python Exception <class 'gdb.MemoryError'> Cannot access memory at address 0x0:
>> Error occurred in Python command: Cannot access memory at address 0x0
>> (gdb) p log_buf
>> $15 = 0x0
>>
>> Luckily, GDB has a way to deal with this, see
>> https://sourceware.org/gdb/onlinedocs/gdb/Symbols.html
>>
>> (gdb) info variables ^log_buf$
>> All variables matching regular expression "^log_buf$":
>>
>> File <linux.git>/kernel/bpf/verifier.c:
>> static char *log_buf;
>>
>> File <linux.git>/kernel/printk/printk.c:
>> static char *log_buf;
>> (gdb) p 'verifier.c'::log_buf
>> $1 = 0x0
>> (gdb) p 'printk.c'::log_buf
>> $2 = 0x811a6aa0 <__log_buf> ""
>> (gdb) p &log_buf
>> $3 = (char **) 0x8120fe40 <log_buf>
>> (gdb) p &'verifier.c'::log_buf
>> $4 = (char **) 0x8120fe40 <log_buf>
>> (gdb) p &'printk.c'::log_buf
>> $5 = (char **) 0x8048b7d0 <log_buf>
>>
>> By being explicit about the location of the symbol, we
>> can make lx-dmesg work again. While at it, do the same
>> for the other symbols we need from printk.c
>>
>> Signed-off-by: André Draszik <git@andred.net>
Nice to see you again André :D
>> ---
>> v3: pep8 compliant
>> v2: Commit message slightly updated
>> ---
>> scripts/gdb/linux/dmesg.py | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/scripts/gdb/linux/dmesg.py b/scripts/gdb/linux/dmesg.py
>> index f9b92ece7834..5afd1098e33a 100644
>> --- a/scripts/gdb/linux/dmesg.py
>> +++ b/scripts/gdb/linux/dmesg.py
>> @@ -23,10 +23,11 @@ class LxDmesg(gdb.Command):
>> super(LxDmesg, self).__init__("lx-dmesg", gdb.COMMAND_DATA)
>>
>> def invoke(self, arg, from_tty):
>> - log_buf_addr = int(str(gdb.parse_and_eval("log_buf")).split()[0], 16)
>> - log_first_idx = int(gdb.parse_and_eval("log_first_idx"))
>> - log_next_idx = int(gdb.parse_and_eval("log_next_idx"))
>> - log_buf_len = int(gdb.parse_and_eval("log_buf_len"))
>> + log_buf_addr = int(str(gdb.parse_and_eval(
>> + "'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"))
>>
>> inf = gdb.inferiors()[0]
>> start = log_buf_addr + log_first_idx
>>
>
> Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Sorry for the delay - I'm in Tokyo for Linux OSS Japan.
This looks good to me and I've verified it locally.
Tested-by: Kieran Bingham <kieran@bingham.xyz>
>
> Andrew, please include in your queue.
>
> Jan
>
--
Regards
Kieran Bingham
prev parent reply other threads:[~2017-05-31 5:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-26 11:04 [PATCH] scripts/gdb: make lx-dmesg command work (reliably) André Draszik
2017-05-26 11:12 ` Jan Kiszka
2017-05-27 14:01 ` Andy Shevchenko
2017-05-28 16:29 ` Jan Kiszka
2017-05-26 11:13 ` [PATCH v2] " André Draszik
2017-05-26 11:22 ` [PATCH v3] " André Draszik
2017-05-26 11:28 ` Jan Kiszka
2017-05-31 5:10 ` Kieran Bingham [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=ae8caff8-0fc9-da0d-8468-1f139a0a67df@bingham.xyz \
--to=kieran@ksquared.org.uk \
--cc=akpm@linux-foundation.org \
--cc=git@andred.net \
--cc=jan.kiszka@siemens.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;
as well as URLs for NNTP newsgroup(s).