From: "Neo Jia" <neojia@gmail.com>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: How to debug Linux kernel on qemu with kgdb?
Date: Wed, 25 Apr 2007 12:07:26 -0500 [thread overview]
Message-ID: <5d649bdb0704251007q771d7e92o288a4ea9319ced09@mail.gmail.com> (raw)
In-Reply-To: <462F7D45.9000505@web.de>
On 4/25/07, Jan Kiszka <jan.kiszka@web.de> wrote:
> Neo Jia wrote:
> > On 4/25/07, Jan Kiszka <jan.kiszka@web.de> wrote:
> >> Neo Jia wrote:
> >> > On 4/25/07, Jan Kiszka <jan.kiszka@web.de> wrote:
> >> >> Neo Jia wrote:
> >> >> > hi,
> >> >> >
> >> >> > I am trying to use debug kgdb patched linux kernel on my qemu. Both
> >> >> > the native and target platform are IA32. I am wondering if there is
> >> >> > anyone can show me the procedure?
> >> >>
> >> >> Yep, see
> >> https://mail.gna.org/public/xenomai-core/2006-09/msg00202.html
> >> >>
> >> >> (BTW, I think that kgdb bug is still unfixed - I never got a
> >> feedback.)
> >> >
> >> > I can connect gdb through /dev/pts/XX. My qemu is lanuched by
> >> >
> >> > qemu -nographic -hda linux.img -kernel
> >> > ./2.6.15.5-kgdb/vmlinuz-2.6.15.5-kgdb -serial pty -append "kgdbwait
> >> > console=ttyS0 root=/dev/hda sb=0x220,5,1,5 ide2=noprobe ide3=noprobe
> >> > ide4=noprobe ide5=noprobe"
> >> >
> >> > Do you know where can I get the console output?
> >> >
> >>
> >> Use "... -serial stdio -serial pty ..." and attached kgdb to the second
> >> serial port (I think to recall that is default anyway). The first one is
> >> then used for the kernel console.
> >>
> >> > I would like to work out kgdb + qemu to debug linux kernel.
> >>
> >> ??? So you really want to debug the kernel when kgdb is applied, ie.
> >> actually debug kgdb? If you only intend to debug the kernel itself, qemu
> >> -s + gdb is enough.
> >
> > Jan,
> >
> > I just would like to debug kernel itself. I have tried qemu -s + gdb
> > but it keeps
> > getting "apic_timer_interrupt" when I am using "n" command.
> >
> > The following is the output:
> >
> >> gdb vmlinux
> > GNU gdb 6.5.50.20060621-cvs
> > Copyright (C) 2006 Free Software Foundation, Inc.
> > GDB is free software, covered by the GNU General Public License, and you
> > are
> > welcome to change it and/or distribute copies of it under certain
> > conditions.
> > Type "show copying" to see the conditions.
> > There is absolutely no warranty for GDB. Type "show warranty" for details.
> > This GDB was configured as "i686-pc-linux-gnu"...Using host
> > libthread_db library "/lib/tls/libthread_db.so.1".
> >
> > (gdb) target remote localhost:1234
> > Remote debugging using localhost:1234
> > 0x0000fff0 in ?? ()
> > warning: shared library handler failed to enable breakpoint
> > (gdb) c
> > Continuing.
> >
> > Program received signal SIGINT, Interrupt.
> > default_idle () at include/asm/bitops.h:252
> > 252 return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0;
> > (gdb) b sys_ex
> > sys_execve sys_exit sys_exit_group
> > (gdb) b sys_execve
> > Breakpoint 1 at 0xc0101ac1: file arch/i386/kernel/process.c, line 791.
> > (gdb) c
> > Continuing.
> >
> > Breakpoint 1, sys_execve (regs=
> > {ebx = 135197704, ecx = 135197864, edx = 135244936, esi =
> > 135197704, edi = 135197704, ebp = -1079176984, eax = 11, xds = 123,
> > xes = 123, orig_eax = 11, eip = -1208835017, xcs = 115, eflags = 582,
> > esp = -1079177012, xss = 123})
> > at arch/i386/kernel/process.c:791
> > 791 filename = getname((char __user *) regs.ebx);
> > (gdb) n
> > 0xc0103666 in apic_timer_interrupt () at include/asm/current.h:9
> > 9 {
>
> That's normal. You stopped the kernel in sys_execve with interrupts
> enabled. When continuing, qemu replays any pending interrupts, here the
> timer. Thus your next instruction is not in sys_execve, but in the
> interrupt handler. You can try finish then and hope that you will return
> to the next line in sys_execve, or you put another breakpoint at the
> next interesting spot and just issue continue.
>
> Jan
>
>
> PS: Using kgdb from inside qemu should work (at least it once did for
> me), but it is really sloooow.
>
Could you show me the procedure you did? I just want to use this to
learn kernel code.
Thanks,
Neo
>
>
--
I would remember that if researchers were not ambitious
probably today we haven't the technology we are using!
next prev parent reply other threads:[~2007-04-25 17:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-25 1:11 [Qemu-devel] How to debug Linux kernel on qemu with kgdb? Neo Jia
2007-04-25 6:04 ` [Qemu-devel] " Jan Kiszka
2007-04-25 6:29 ` Neo Jia
2007-04-25 6:32 ` Neo Jia
2007-04-25 6:36 ` Jan Kiszka
2007-04-25 15:54 ` Neo Jia
2007-04-25 16:09 ` Jan Kiszka
2007-04-25 17:07 ` Neo Jia [this message]
2007-04-25 20:05 ` Jan Kiszka
2007-04-25 22:01 ` Neo Jia
2007-04-25 16:02 ` Neo Jia
2007-04-25 6:29 ` Jan Kiszka
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=5d649bdb0704251007q771d7e92o288a4ea9319ced09@mail.gmail.com \
--to=neojia@gmail.com \
--cc=jan.kiszka@web.de \
--cc=qemu-devel@nongnu.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).