Bug 839263

Summary: cannot set gdb breakpoints on kvm guest
Product: Red Hat Enterprise Linux 7 Reporter: Stefan Assmann <sassmann>
Component: qemu-kvmAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, areis, bsarathy, dyasny, juzhang, knoel, mkenneth, sluo
Target Milestone: pre-dev-freeze   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-07-12 12:24:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Stefan Assmann 2012-07-11 12:06:46 UTC
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):
kernel-2.6.32-279.el6.x86_64
qemu-kvm-0.12.1.2-2.295.el6.x86_64
gdb-7.2-56.el6.x86_64

Actual results:
breakpoints don't work with kvm enabled

Expected results:
breakpoints work with kvm enabled

Additional info:
Also tried upstream qemu-kvm, but it didn't work either

Comment 2 Ademar Reis 2012-07-11 18:17:01 UTC
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.

Comment 3 Avi Kivity 2012-07-12 12:24:06 UTC
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.

Comment 4 Stefan Assmann 2012-07-13 07:16:02 UTC
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.
Continuing.
kvm: 26628: cpu0 disabled perfctr wrmsr: 0xc1 data 0xabcd
Remote 'g' packet reply is too long: 000000000000000096512d81ffffffff800000000000000000000000000000009c4e2c81ffffffff0900000000000000c03d6a070088ffff883d6a070088ffff8fac7781ffffffff9c4e2c81fffffffff017c3060088ffff90000000000000000900000000000000a09476070088ffff01000000000000000000000000000000f0aa0d81ffffffff4602000010000000180000001800000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f0300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f0000
(gdb) bt
Target is executing.

Any clues?

Comment 5 Avi Kivity 2012-07-15 09:10:46 UTC
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.