--- wikisrc/kernel_debugging_with_qemu.mdwn 2015/02/18 16:23:11 1.7 +++ wikisrc/kernel_debugging_with_qemu.mdwn 2015/08/05 12:58:13 1.12 @@ -26,13 +26,12 @@ install the most recent anita package fr ## Building the target system -Check out the NetBSD-current sources from CVS and build a full -NetBSD-current/i386 release with debug symbols using the build.sh -script. The i386 port is the preferred test platform because the two +Check out the NetBSD-current sources from CVS and build a full release +of NetBSD-current/i386 with debug symbols using the build.sh script. +The i386 port is the preferred test platform because the two other ports supported by anita are affected by known bugs: amd64 by -[[PR 49276|http://gnats.NetBSD.org/49276]], and sparc by -[[qemu bug 1335444|https://bugs.launchpad.net/qemu/+bug/1335444]]. - +[[PR 50128|http://gnats.NetBSD.org/50128]], and sparc by +[[qemu bug 1399943|https://bugs.launchpad.net/qemu/+bug/1399943]]. If you do the build in a directory other than /usr/src, use the -fdebug-prefix-map option to ensure that the source file names embedded in the debug symbols point to /usr/src, which is where the sources will be @@ -61,15 +60,15 @@ Install the system in a virtual machine, ## Booting the VMs Next, start two qemu virtual machines, one to run the kernel being -debugged (the "kgdb target") and another to run gdb (the "kgdb host"). +debugged (the "target VM") and another to run gdb (the "gdb VM"). -The two VMS could be run on separate physical machines, but in this +The two VMs could be run on separate physical machines, but in this example, they are run on the same physical machine and share the same hard disk image. This sharing is made possible by the "-snapshot" option to qemu, which ensures that the disk image is not written to by either VM. -First start the kgdb target, enabling qemu's built-in GDB target stub +First start the target VM, enabling qemu's built-in GDB target stub on TCP port 1234: [[!template id=programlisting text=""" @@ -80,20 +79,20 @@ If you don't want everyone on the Intern target, make sure incoming connections on port 1234 are blocked in your firewall. -In a second terminal window, start the kgdb host: +In a second terminal window, start the gdb VM: [[!template id=programlisting text=""" $ qemu-system-i386 -nographic -snapshot -hda work/wd0.img """]] -Log in to the kgdb host as root and set up the network: +Log in to the gdb VM as root and set up the network: [[!template id=programlisting text=""" login: root # dhcpcd """]] -Start gdb on the kgdb host and connect to the target: +Start gdb on the gdb VM and connect to the target: [[!template id=programlisting text=""" # gdb /netbsd @@ -101,7 +100,7 @@ Start gdb on the kgdb host and connect t """]] where my.host.name is the domain name or IP address of the -physical machine running the kgdb target qemu VM. +host system. Now you should be able to get a stack trace and start debugging with full debug symbols and access to the source code: