From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8rlr-0002Fj-0a for qemu-devel@nongnu.org; Sat, 17 Mar 2012 07:26:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8rlo-0004K4-Tr for qemu-devel@nongnu.org; Sat, 17 Mar 2012 07:26:02 -0400 Received: from moutng.kundenserver.de ([212.227.126.171]:64387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8rlo-0004J9-KN for qemu-devel@nongnu.org; Sat, 17 Mar 2012 07:26:00 -0400 From: Laurent Vivier In-Reply-To: <4F645124.7090001@web.de> References: <4F645124.7090001@web.de> Content-Type: text/plain; charset="UTF-8" Date: Sat, 17 Mar 2012 12:25:58 +0100 Message-ID: <1331983559.29216.1.camel@Quad> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: Jan Kiszka Cc: Wei Yang , qemu-devel@nongnu.org Le samedi 17 mars 2012 =C3=A0 09:53 +0100, Jan Kiszka a =C3=A9crit : > 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? >=20 > Two major issues with this procedure: >=20 > 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. >=20 > 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 You can also try my patch : http://patchwork.ozlabs.org/patch/137543/ Laurent