Red Hat Bugzilla – Bug 839263
cannot set gdb breakpoints on kvm guest
Last modified: 2013-01-09 07:04:53 EST
Description of problem:
Starting a guest with
# /usr/libexec/qemu-kvm -s -S -enable-kvm -kernel arch/x86/boot/bzImage -nographic --append "console=ttyS0 ignore_loglevel earlyprintk=ttyS0"
Then in a second window
# /usr/local/bin/gdb vmlinux -ex 'target remote localhost:1234' -ex 'b request_threaded_irq' -ex 'c'
The guest starts to run but it does not stop on the breakpoint.
However this works by using "-no-kvm" instead of "-enable-kvm"
Version-Release number of selected component (if applicable):
breakpoints don't work with kvm enabled
breakpoints work with kvm enabled
Also tried upstream qemu-kvm, but it didn't work either
You may have more luck with hardware breakpoints (hbreak in gdb). Moving to RHEL7: not a high priority and doesn't work on upstream yet.
Software breakpoints will not work in the scenario described, since the kernel is loaded after the breakpoints are set. The INT 3 instructions are overwritten by the kernel (well, actually the breakpoints aren't even set correctly because paging is enabled).
You'll have better luck with hbreak. You can also use break after the kernel has been loaded, but hbreak will be more reliable.
Closing as invalid.
Thanks Avi and Ademar! Now gdb stops at the hbreak, but shows the following error.
Reading symbols from /home/nfs/rhel6/vmlinux...done.
Remote debugging using localhost:1234
0x0000000000000000 in ?? ()
Hardware assisted breakpoint 1 at 0xffffffff810daaf0: file kernel/irq/manage.c, line 1041.
kvm: 26628: cpu0 disabled perfctr wrmsr: 0xc1 data 0xabcd
Target is executing.
This is a longstanding gdb bug, caused by target mode switches.
A workaround is to let the guest boot into 64-bit mode, stop it, set the hardware breakpoint, continue the guest, and issue system_reset.