How to debug the Linux kernel with GDB and QEMU?
I'd try:
(gdb) target remote localhost:1234
(gdb) continue
Using the '-s' option makes qemu listen on port tcp::1234, which you can connect to as localhost:1234 if you are on the same machine. Qemu's '-S' option makes Qemu stop execution until you give the continue command.
Best thing would probably be to have a look at a decent GDB tutorial to get along with what you are doing. This one looks quite nice.
debugging kernel with qemu and gdb, breakpoint not working?
This was solve not long after my posting the question and I forgot to put an answer.
It was because of the KASLR (kernel address space location randomization). You should disable it in the kernel configuration, or give option in the boot parameter. (without it, the kernel image is located in random location, causing mismach between debug symbol location and actual code location). This KASLR is turned on by default for aarch64.
In my case I did it with :
${QEMU_DIR}/qemu-system-aarch64 -M ${QMACHINE} -cpu cortex-a72 -kernel ${LINUX_DIR}/arch/arm64/boot/Image -initrd ${BUSYBOX_DIR}/initramfs.cpio.gz --append "root=/dev/ram init=/init nokaslr" -m 2048M -nographic
And I had to use 'hb'(or hbreak (hardware break)) instead of 'b'(or break).
How to debug Linux kernel modules with QEMU?
The easiest way in my opinion is to use buildroot
http://buildroot.uclibc.org/
clone it, configure it to use your custom kernel (default userspace is fine for a start, you might want to change it later).
it will build your kernel and root filesystem. the entire process takes about half an hour, twenty minutes of which is compiling the monster
my run line looks something:
qemu-system-i386
-hda rootfs.ext2
-kernel bzImage
-m 512M
-append "root=/dev/sda console=ttyS0"
-localtime
-serial stdio
and some more options regarding a tap device
Related Topics
Creating a Raw Printer Queue in Cups (Host) and Adding Them Through Cups (Client)
Adding a New System Call in Linux Kernel 3.3
How to Prefill Command Line Input
How to Capture Network Frames in a Kernel Module
The Meaning of Real, User, and Sys in Output of Linux Time Command
Systemd: "Environment" Directive to Set Path
Shell Script Working Fine Without Shebang Line? Why
How to Prevent Out of Memory (Oom) Freezes on Linux
Ssh Command Execution Hangs, Although Interactive Shell Functions Fine
How to Remove Warning About Storing Unencrypted Password After Committing File in Svn
Can't Run Uwsgi as Root, "Bind(): Permission Denied"
Find and Delete Files with Non-Ascii Names
How to Echo a Sum of a Variable and a Number
Trying to Find All the Kernel Modules Needed for My MAChine Using Shell Script
Linux Find Out Hyper-Threaded Core Id
Mmap: Will the Mapped File Be Loaded into Memory Immediately