Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
551 views
in Technique[技术] by (71.8m points)

Cannot insert break point when debugging linux kernel with qemu and gdb

Hi I'm trying to debug linux kernel for some code and learn.

I compiled with the following on:

  1. Compile the kernel with debug info
  2. RAM block device support
  3. 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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...