Bug 839263 - cannot set gdb breakpoints on kvm guest
cannot set gdb breakpoints on kvm guest
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
x86_64 Linux
unspecified Severity low
: pre-dev-freeze
: ---
Assigned To: Virtualization Maintenance
Virtualization Bugs
Depends On:
  Show dependency treegraph
Reported: 2012-07-11 08:06 EDT by Stefan Assmann
Modified: 2013-01-09 07:04 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-07-12 08:24:06 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Stefan Assmann 2012-07-11 08:06:46 EDT
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):

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 14:17:01 EDT
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 08:24:06 EDT
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 03:16:02 EDT
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
Remote 'g' packet reply is too long: 000000000000000096512d81ffffffff800000000000000000000000000000009c4e2c81ffffffff0900000000000000c03d6a070088ffff883d6a070088ffff8fac7781ffffffff9c4e2c81fffffffff017c3060088ffff90000000000000000900000000000000a09476070088ffff01000000000000000000000000000000f0aa0d81ffffffff4602000010000000180000001800000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f0300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f0000
(gdb) bt
Target is executing.

Any clues?
Comment 5 Avi Kivity 2012-07-15 05:10:46 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.