public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Jason Wessel <jason.wessel@windriver.com>,
	kgdb-bugreport@lists.sourceforge.net,
	Andi Kleen <andi@firstfloor.org>, Tom Tromey <tromey@redhat.com>,
	Ben Widawsky <ben@bwidawsk.net>, Borislav Petkov <bp@suse.de>,
	Tatiana Al-Chueyr Martins <tatiana.alchueyr@gmail.com>,
	Rob Landley <rob@landley.net>,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH v6 21/21] scripts/gdb: Add basic documentation
Date: Wed, 30 Oct 2013 12:22:15 +0100	[thread overview]
Message-ID: <5270EBE7.4010103@siemens.com> (raw)
In-Reply-To: <20131030111725.GA13298@pd.tnic>

On 2013-10-30 12:17, Borislav Petkov wrote:
> On Mon, Oct 28, 2013 at 09:58:58AM +0100, Jan Kiszka wrote:
>> CC: Rob Landley <rob@landley.net>
>> CC: linux-doc@vger.kernel.org
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>  Documentation/gdb-kernel-debugging.txt | 159 +++++++++++++++++++++++++++++++++
>>  1 file changed, 159 insertions(+)
>>  create mode 100644 Documentation/gdb-kernel-debugging.txt
>>
>> diff --git a/Documentation/gdb-kernel-debugging.txt b/Documentation/gdb-kernel-debugging.txt
>> new file mode 100644
>> index 0000000..944f2d2
>> --- /dev/null
>> +++ b/Documentation/gdb-kernel-debugging.txt
>> @@ -0,0 +1,159 @@
>> +Debugging kernel and modules via gdb
>> +====================================
>> +
>> +The kernel debugger kgdb, hypervisors like QEMU or JTAG-based hardware
>> +interfaces allow to debug the Linux kernel and its modules during runtime
>> +using gdb. Gdb comes with a powerful scripting interface for python. The
>> +kernel provides a collection of helper scripts that can simplify typical
>> +kernel debugging steps. This is a short tutorial about how to enable and use
>> +them. It focuses on QEMU/KVM virtual machines as target, but the examples can
>> +be transferred to the other gdb stubs as well.
>> +
>> +
>> +Requirements
>> +------------
>> +
>> + o gdb 7.2+ (recommended: 7.4+) with python support enabled (typically true
>> +   for distributions)
>> +
>> +
>> +Setup
>> +-----
>> +
>> + o Create a virtual Linux machine for QEMU/KVM (see www.linux-kvm.org and
>> +   www.qemu.org for more details). For cross-development,
>> +   http://landley.net/aboriginal/bin keeps a pool of machine images and
>> +   toolchains that can be helpful to start from.
>> +
>> + o Build the kernel with CONFIG_DEBUG_INFO and CONFIG_KALLSYMS enabled, but
>> +   leave CONFIG_DEBUG_INFO_REDUCED off.
>> +
>> + o Install that kernel on the guest.
>> +
>> +   Alternatively, QEMU allows to boot the kernel directly using -kernel,
>> +   -append, -initrd command line switches. This is generally only useful if
>> +   you do not depend on modules. See QEMU documentation for more details on
>> +   this mode.
>> +
>> + o Enable the gdb stub of QEMU/KVM, either
>> +    - at VM startup time by appending "-s" to the QEMU command line
>> +   or
>> +    - during runtime by issuing "gdbserver" from the QEMU monitor
>> +      console
>> +
>> + o cd /path/to/linux-build
>> +
>> + o Start gdb: gdb vmlinux
>> +
>> +   Note: Some distros may restrict auto-loading of gdb scripts to known safe
>> +   directories. In case gdb reports to refuse loading vmlinux-gdb.py, add
>> +
>> +    add-add-auto-load-safe-path /path/to/linux-build
> 
> Only one "add-" should be enough :)

Thanks, fixed. Need to update this file anyway.

> 
> Btw, gdb is nice enough to tell me:
> 
> $ gdb vmlinux
> Reading symbols from /w/kernel/linux-2.6/vmlinux...done.
> warning: File "/w/kernel/linux-2.6/scripts/gdb/vmlinux-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
> To enable execution of this file add
>         add-auto-load-safe-path /w/kernel/linux-2.6/scripts/gdb/vmlinux-gdb.py

Is that sufficient to be able to import all the sub-scripts as well?

> line to your configuration file "/home/boris/.gdbinit".
> To completely disable this security protection add
>         set auto-load safe-path /
> line to your configuration file "/home/boris/.gdbinit".
> For more information about this security protection see the
> "Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
>         info "(gdb)Auto-loading safe path"
> 
> Other than that, that's a very cool stuff and I'll make sure to be using
> it the next time.
> 
> Acked-by: Borislav Petkov <bp@suse.de>
> 

Thanks!

Jan

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

  reply	other threads:[~2013-10-30 11:23 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-28  8:58 [PATCH v6 00/21] Add gdb python scripts as kernel debugging helpers Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 01/21] scripts/gdb: Add infrastructure Jan Kiszka
2013-10-30  5:35   ` Andi Kleen
2013-10-30 10:28     ` Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 02/21] scripts/gdb: Add cache for type objects Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 03/21] scripts/gdb: Add container_of helper and convenience function Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 04/21] scripts/gdb: Add module iteration class Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 05/21] scripts/gdb: Add lx-symbols command Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 06/21] module: Do not inline do_init_module Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 07/21] scripts/gdb: Add automatic symbol reloading on module insertion Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 08/21] scripts/gdb: Add internal helper and convenience function to look up a module Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 09/21] scripts/gdb: Add get_target_endianness helper Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 10/21] scripts/gdb: Add read_u16/32/64 helpers Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 11/21] scripts/gdb: Add lx-dmesg command Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 12/21] scripts/gdb: Add task iteration class Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 13/21] scripts/gdb: Add helper and convenience function to look up tasks Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 14/21] scripts/gdb: Add is_target_arch helper Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 15/21] scripts/gdb: Add internal helper and convenience function to retrieve thread_info Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 16/21] scripts/gdb: Add get_gdbserver_type helper Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 17/21] scripts/gdb: Add internal helper and convenience function for per-cpu lookup Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 18/21] scripts/gdb: Add lx_current convenience function Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 19/21] scripts/gdb: Add class to iterate over CPU masks Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 20/21] scripts/gdb: Add lx-lsmod command Jan Kiszka
2013-10-28  8:58 ` [PATCH v6 21/21] scripts/gdb: Add basic documentation Jan Kiszka
2013-10-30 11:17   ` Borislav Petkov
2013-10-30 11:22     ` Jan Kiszka [this message]
2013-10-30 11:46       ` Borislav Petkov

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=5270EBE7.4010103@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=ben@bwidawsk.net \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=jason.wessel@windriver.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rob@landley.net \
    --cc=tatiana.alchueyr@gmail.com \
    --cc=tromey@redhat.com \
    /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