From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8pOk-0003MM-7u for qemu-devel@nongnu.org; Sat, 17 Mar 2012 04:54:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8pOi-0003IV-4I for qemu-devel@nongnu.org; Sat, 17 Mar 2012 04:54:01 -0400 Received: from fmmailgate06.web.de ([217.72.192.247]:56641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8pOh-0003IC-RK for qemu-devel@nongnu.org; Sat, 17 Mar 2012 04:54:00 -0400 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate06.web.de (Postfix) with ESMTP id A98BCF3DF4C for ; Sat, 17 Mar 2012 09:53:57 +0100 (CET) Message-ID: <4F645124.7090001@web.de> Date: Sat, 17 Mar 2012 09:53:56 +0100 From: Jan Kiszka MIME-Version: 1.0 References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig055BC1A99C2603FEF9716C83" Subject: Re: [Qemu-devel] Failed to set a breakpoint on start_kernel List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wei Yang Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig055BC1A99C2603FEF9716C83 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2012-03-16 03:43, Wei Yang wrote: > All >=20 > I like qemu very much and know it could debug the kernel. >=20 > I tried what I searched on web but couldn't stop at the break point. > Below is what I did. >=20 > 1. Both host and guest installed the same OS, Fedora16 x86_64. >=20 > 2. Compile the qemu with > ./configure --target-list=3Dx86_64-softmmu --enable-kvm > --enable-debug-tcg --enable-debug --enable-trace-backend=3Dsimple >=20 > 3. With this command I can boot up my guest. > ./../qemu/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -smp 4 -m > 1024 -boot dc fedora16.img -monitor stdio >=20 > 4. I git clone the kernel source in the guest and make a new kernel and= initrd. > I start the guest with this new kernel successfully >=20 > 5. I copy out the initrd.img and the .config of kernel to host. > compile the kernel on host. > the kernel source code is identical on host and gueset, >=20 > 6. I start the guest with the kernel and initrd on host > ./../qemu/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -smp 4 -m > 1024 -boot dc fedora16.img -monitor stdio -kernel > ~/git/linux-yinghai/arch/x86_64/boot/bzImage -initrd > ~/git/debug/initramfs-3.0.0.img -append > "root=3D/dev/mapper/vg_wizard-lv_root ro rd.lvm.lv=3Dvg_wizard/lv_root > rd.md=3D0 rd.lvm.lv=3Dvg_wizard/lv_swap" >=20 > This works fine. >=20 > 7. Then I start the guest with gdbstub option > ./../qemu/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -smp 4 -m > 1024 -boot dc fedora16.img -monitor stdio -kernel > /home/ywywyang/git/linux-yinghai/arch/x86_64/boot/bzImage -initrd > /home/ywywyang/git/debug/initramfs-3.0.0.img -append > "root=3D/dev/mapper/vg_wizard-lv_root ro rd.lvm.lv=3Dvg_wizard/lv_root > rd.md=3D0 rd.lvm.lv=3Dvg_wizard/lv_swap" -S -gdb tcp::4321 >=20 > Then the guest stop at the beginning. >=20 > 8. Attach the gdb in the kernel source directory > gdb > file vmlinux > target remote localhost:4321 > b start_kernel > c >=20 > Then the guest will run very happily.... >=20 > Also use the "info b " could show the break point is set. >=20 > Which step I made a mistake? Two major issues with this procedure: 1. When using kvm, a soft breakpoint (as set by 'b') will inject a trap instruction into the guest image - which is not yet loaded after the bios ran. You need to use a hardware breakpoint in this case. 2. Due to gdb limitations, you cannot switch between 16/32-bit mode (the CPU starts in 16 bit) and the 64-bit mode of kernel within the same gdb session. Therefore: - let the target run into Linux is active - attach gdb - issue "hw start_kernel" - reboot (e.g. "monitor system_reset") - you will hit the breakpoint, and gdb will be usable Jan --------------enig055BC1A99C2603FEF9716C83 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk9kUSQACgkQitSsb3rl5xQGRACePdRuBFyocfuZtn5wUDcZ7tRI 3icAoOQbSk0vV4RHYgWW58tjV07lwCRl =Ja1K -----END PGP SIGNATURE----- --------------enig055BC1A99C2603FEF9716C83--