From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HgkBw-0001WD-MZ for qemu-devel@nongnu.org; Wed, 25 Apr 2007 12:18:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HgkBu-0001Tu-S0 for qemu-devel@nongnu.org; Wed, 25 Apr 2007 12:18:04 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HgkBu-0001TZ-MC for qemu-devel@nongnu.org; Wed, 25 Apr 2007 12:18:02 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hgk6G-0004IN-1B for qemu-devel@nongnu.org; Wed, 25 Apr 2007 12:12:12 -0400 Message-ID: <462F7D45.9000505@web.de> Date: Wed, 25 Apr 2007 18:09:41 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <5d649bdb0704241811s301aa41bg2a93b8b4c923b023@mail.gmail.com> <462EEF7A.5040708@web.de> <5d649bdb0704242329x587bbfc4qe9feefd037e24f60@mail.gmail.com> <462EF6D5.1040504@web.de> <5d649bdb0704250854w3b7f413jae5241e9d229011e@mail.gmail.com> In-Reply-To: <5d649bdb0704250854w3b7f413jae5241e9d229011e@mail.gmail.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigCA1F52D3F8C12D3FF53F8DD5" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: How to debug Linux kernel on qemu with kgdb? Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Neo Jia Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigCA1F52D3F8C12D3FF53F8DD5 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Neo Jia wrote: > On 4/25/07, Jan Kiszka wrote: >> Neo Jia wrote: >> > On 4/25/07, Jan Kiszka wrote: >> >> Neo Jia wrote: >> >> > hi, >> >> > >> >> > I am trying to use debug kgdb patched linux kernel on my qemu. Bo= th >> >> > 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=3DttyS0 root=3D/dev/hda sb=3D0x220,5,1,5 ide2=3Dnoprobe ide3= =3Dnoprobe >> > ide4=3Dnoprobe ide5=3Dnoprobe" >> > >> > Do you know where can I get the console output? >> > >> >> Use "... -serial stdio -serial pty ..." and attached kgdb to the secon= d >> 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, qe= mu >> -s + gdb is enough. >=20 > Jan, >=20 > 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. >=20 > The following is the output: >=20 >> 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 yo= u > 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 deta= ils. > This GDB was configured as "i686-pc-linux-gnu"...Using host > libthread_db library "/lib/tls/libthread_db.so.1". >=20 > (gdb) target remote localhost:1234 > Remote debugging using localhost:1234 > 0x0000fff0 in ?? () > warning: shared library handler failed to enable breakpoint > (gdb) c > Continuing. >=20 > Program received signal SIGINT, Interrupt. > default_idle () at include/asm/bitops.h:252 > 252 return ((1UL << (nr & 31)) & (addr[nr >> 5])) !=3D 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. >=20 > Breakpoint 1, sys_execve (regs=3D > {ebx =3D 135197704, ecx =3D 135197864, edx =3D 135244936, esi =3D > 135197704, edi =3D 135197704, ebp =3D -1079176984, eax =3D 11, xds =3D = 123, > xes =3D 123, orig_eax =3D 11, eip =3D -1208835017, xcs =3D 115, eflags = =3D 582, > esp =3D -1079177012, xss =3D 123}) > at arch/i386/kernel/process.c:791 > 791 filename =3D 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. --------------enigCA1F52D3F8C12D3FF53F8DD5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGL31FniDOoMHTA+kRAukOAJ474nHvSoRl0oSNDFF/0l70zMc7cACfXNUB Rlac3aqVL1x5n+R8o8Zsoio= =7adK -----END PGP SIGNATURE----- --------------enigCA1F52D3F8C12D3FF53F8DD5--