I used T_PAGEFLT’s blog post as a reference for setting my NetBSD kernel development environment since his website is down I’m putting down the steps here so it would be helpful for starters.
This is an overview of my setup:
- Linux Host With Qemu Target
- Tracing and Debugging using qemu’s built-in gdb server.
- Use a cronjob with rsync to keep my files updated b/w host and guest.
- pkgin for simpicity.(Sometimes have to use pkg_add to get stuff done)
Make sure you have the latest version of qemu installed as we will be using x86-64 NetBSD guests.
We will be needing GDB that is configured with NetBSD x86_64 abi. So we need to compile it ourself.
First step get the files.
mkdir netbsd && cd netbsd
Now for the time taking part, compiling the sources.
./build.sh -m amd64 -T ../tooldir -D ../destdir -R ../releasedir -O ../objdir -U -j6 release iso-image
Upon completion the directories will have the following files:
- Cross-compilation toolchain in “tooldir”
- Bootable image in “releasedir/images”
qemu-img create ~/vhd/netbsd-current.img 10G
No go through the standard installation without unnecessary clutter like x11,games etc.
Configure all the necessary things such as ssh, users, sheel preference.
After the completion of installation
qemu-system-x86_64 -smp 4 -drive file=vhd/netbsd-current.img,format=raw \
This should drop you a vm instance.
Once you are up and running better to install pkgin. It makes package management easier.
Use the text editor of your choice and fiddle with the configuration.
make sure you have
makeoptions DEBUG="-g" # compile full symbol table for CTF
Now all that is left is compiling.
./build.sh -m amd64 -T ../tooldir -D ../destdir -R ../releasedir -O ../objdir -U -u -j6 kernel=QEMU
Now scp the files to vm and repace the old kernel
scp -P 5022 ~/netbsd/objdir/sys/arch/amd64/compile/QEMU/netbsd [email protected]:~
Start VM with qemu’s gdb stub forwarding tcp through port 1234.
qemu-system-x86_64 -drive file=vhd/netbsd-current.img,format=raw \
We already compiled netbsd kernel with complete symbol table.
Now just simply enter
(gdb) target remote localhost:1234