Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Tom Tromey <tromey@redhat.com>
Cc: Vimal <j.vimal@gmail.com>, gdb@sourceware.org
Subject: Re: Multiple breakpoint issue when debugging loadable kernel module
Date: Tue, 01 Nov 2011 15:32:00 -0000	[thread overview]
Message-ID: <4EB010D1.9050209@web.de> (raw)
In-Reply-To: <m3y5w051d6.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2636 bytes --]

On 2011-10-31 21:53, Tom Tromey wrote:
>>>>>> "Jan" == Jan Kiszka <jan.kiszka@siemens.com> writes:
> 
> Jan> Tom, do you still like to have a description of the full reproduction
> Jan> scenario or are you debugging via Vimal?
> 
> I'd still like a way to reproduce it myself.

Here we go:

The setup is not that simple, in fact (unless I miss a much simpler
scenario). You need a target Linux system on which you can install a
kernel (with modules) which has debug symbols enabled. Either (re-)build
your own or use a -debug package from a distro.

Then you need to decide which gdbserver to use: either kgdb on a live
system or (I think that's easier) qemu with it's gdb stub. Boot the
kernel on the target/guest for which you have the corresponding debug
objects on the host. If you feel brave, run qemu as root and let it pick
up your host's disk for the guest - in no-modification mode:

qemu-system-x86_64 /dev/sda -snapshot -m 1G -s

Don't forget the -snapshot or host and guest will use the same disk...

If you have VT-x/AMD-V on your host: modprobe kvm-intel/kvm-amd first,
and then append -enable-kvm to the qemu command line (the qemu fork
qemu-kvm will imply this and refuse to work with kvm modules).

Once the target is up, check /proc/modules for some used module and its
start address. Pick one, say mac80211, and note the address (or use my
script later on). Also pick some function in that module (see
/proc/kallsyms, e.g. ieee80211_register_hw in the mac80211 case).

Next fire up the debugger (the kernel comes with kgdb docbook section,
qemu just requires the "-s" command line switch) and attach to the
target (kgdb via serial console, qemu is listening on TCP port 1234 by
default).

Now we get to the point. Load the module symbols at the right address
(or use my script) and perform the following steps:

(gdb) add-symbol-file /path/to/some/module.ko 0x...
(gdb) l ieee80211_register_hw
624             return local_to_hw(local);
625     }
626     EXPORT_SYMBOL(ieee80211_alloc_hw);
627
628     int ieee80211_register_hw(struct ieee80211_hw *hw)
629     {
630             struct ieee80211_local *local = hw_to_local(hw);
631             int result;
632             enum ieee80211_band band;
633             int channels, max_bitrates;
(gdb) b ieee80211_register_hw
Breakpoint 1 at 0xffffffffa01b31a0: file
/data/linux/net/mac80211/main.c, line 646.
(gdb) l ieee80211_register_hw
No line number known for ieee80211_register_hw.

That's the bug.

Hope that's manageable - somehow. Feel free to ask if you run into
problems with the setup.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  reply	other threads:[~2011-11-01 15:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-24  2:20 Vimal
2011-10-24 14:11 ` Vimal
2011-10-26 12:25 ` Vimal
2011-10-27  0:22   ` Jan Kiszka
2011-10-27  0:43     ` Vimal
2011-10-27  7:21       ` Jan Kiszka
2011-10-27 14:59         ` Vimal
2011-10-27 16:12           ` Jan Kiszka
2011-10-28  0:16         ` Tom Tromey
2011-10-31 17:20           ` Jan Kiszka
2011-10-27 19:38     ` Tom Tromey
2011-10-28  3:40       ` Vimal
2011-10-28 21:07         ` Vimal
2011-10-31 17:18           ` Jan Kiszka
2011-10-31 21:33             ` Tom Tromey
2011-11-01 15:32               ` Jan Kiszka [this message]
2011-11-01 20:13                 ` Jan Kratochvil
2011-11-05  2:07                   ` Vimal
2011-11-05  5:39                     ` Jan Kratochvil
2011-11-08  0:33                   ` Jan Kratochvil
2011-11-05  2:10             ` Vimal

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=4EB010D1.9050209@web.de \
    --to=jan.kiszka@web.de \
    --cc=gdb@sourceware.org \
    --cc=j.vimal@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