Jerry
Jerry

Reputation: 11

How to use QEMUn and GDB to debug Kernel

I would like to know how to debug the linux kernel using QEMU and gdb. I have compiled new kernel linux-3.18.6 in my VM. My VM environment is centos and kernel version is 3.10.0-327.el7.x86_64. I use the command "qemu-system-x86_64 -kernel /usr/src/linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img -s -S" to run the new kernel. Then, I use another shell window to run "gdb ./vmlinux", everything is good until now. But, when I keep going to input "target remote localhost:1234". It prints some weird messages.Like this

(gdb) target remote localhost:1234

Remote debugging using localhost:1234

Remote 'g' packet reply is too long: 

00000000000000000000000000000000000000000000000063060000000000000000000000000000  
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000f0ff0000000000000200000000f0000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000007f0300000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000801f0000

(gdb) c

The program is not being run.

Then, when I type 'c'. It will show "The program is not being run.". I have been confused by this problem for several days. Can anybody help me to fix it and let the program run. Thanks a lot.

Upvotes: 1

Views: 890

Answers (1)

ks1322
ks1322

Reputation: 35708

This is gdb bug 13984. There is a patch attached to it which resolves this bug.

Upvotes: 1

Related Questions