Hi I'm trying to debug linux kernel for some code and learn.
I compiled with the following on:
- Compile the kernel with debug info
- RAM block device support
- Initial RAM filesystem and RAM disk support
And turn off the "Randomize the address of the kernel image (KASLR)" option.
The command that I'm running qemu is:
qemu-system-x86_64 -machine q35 -cpu EPYC -accel kvm -smp 4 -m 8G -append "nokaslr" -append "root=/dev/ram init=/linuxrc" -serial stdio -S -s -kernel linux/arch/x86/boot/bzImage -initrd rootfs.img.gz
However, when trying to insert a breakpoint, the following error shows up
[shore@shore-82b6 Linux_Relate]$ gdb linux/vmlinux
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from linux/vmlinux...
(gdb) target remote:1234
Remote debugging using :1234
0x000000000000fff0 in exception_stacks ()
(gdb) b start_kernel
Breakpoint 1 at 0xffffffff82b3caa9: file init/main.c, line 850.
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff82b3caa9
Command aborted.
(gdb)
At this point the only thing I could do is to insert a hardware breakpoint, but it will only break at the hb, any further operation (step for example) will jump into timer interrupt.
Can anyone be so kind to help me on that, thanks a lot!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…