To try debugging kernel using qemu and gdb (how nice it would be) for aarch64, I tried this.
build kernel with CONFIG_DEBUG_INFO
build qemu with 'configure --target-list=aarch64-softmmu --enable-debug' and 'make' and 'make install'.
then I ran,
qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -smp 1 -m 2048 -kernel arch/arm64/boot/Image -append "earlyprintk console=ttyAMA0 rootwait root=/dev/vda2" -drive if=none,file=/home/ckim/N1SDP/arm-reference-platforms/output/n1sdp/grub-ubuntu.img,id=disk1 -device virtio-blk-device,drive=disk1 -s -Sand ran in another shell, 'gdb-multiarch vmlinux -x gdbcmd'. gdbcmd contains
set architecture aarch64 set serial baud 115200 target remote :1234
Without -S option, qemu proceeds with linux booting. (it starts with
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x411fd070]
[ 0.000000] Linux version 5.4.21 (ckim@chan-ubuntu) (gcc version 9.2.1 20191025 (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10))) #6 SMP PREEMPT Fri Jan 22 11:43:52 JST 2021
[ 0.000000] Machine model: linux,dummy-virt
[ 0.000000] efi: Getting EFI parameters from FDT:
[ 0.000000] efi: UEFI not found.
....
but with -S, it stops and waits for the debugger to give continue command.
inside the debugger, I can set break point like b start_kernel and it responds. But if I type in 'cont', qemu start booting, without stopping at 'start_kernel'. I don't know what is wrong with this.
And I also don't know how to boot without giving the disk image above. how can I run it with vanilla linux kernel? (I used it but with the disk and disk image above, I tried it without them but it doesn't start).
Please help.