Debugging GRUB with gdb
Based on my experience following GNU GRUB 2 Debugging with GDB HOWTO by Ľubomír Kundrák <lkundrak@skosi.org>.
Using an ISO image
patch -p0 < ../grub-gdb-1.patch sh ../configure --prefix=$HOME/bin/grub2 CFLAGS="-O0 -g" && make -j3 ./grub-mkrescue \ --pkglibdir=. \ --grub-mkimage=./grub-mkimage \ --modules="vbe gfxterm" \ --overlay="$HOME/grub/test/overlay" \ grub.iso qemu -cdrom grub.iso -s
in another shell session (make sure you have .gdbinit and gmodule.pl in the current directory):
gdb load_all_modules
Building and using a core.img
./grub-mkimage -d . -o $HOME/tftproot/tftproot/core.img hello qemu -boot a -fda grub-0.97-net.floppy -tftp $HOME/tftproot -s