virt-test icon indicating copy to clipboard operation
virt-test copied to clipboard

virt-test/RFE: Provide a way to run QEMU under gdb

Open dagrh opened this issue 11 years ago • 3 comments

It would be nice to provide a simple way to run the QEMUs that are started under gdb for those of us debugging/breaking qemu. It should be possible to do this to any test, and in the case of tests with multiple QEMUs (e.g. migration) to select which one you want to debug. When attached with gdb you probably want to stop timeouts/the test being killed.

dagrh avatar Jan 06 '14 12:01 dagrh

Thinking about the simplest case first (a single qemu), I wonder how useful would it be to just prefix the qemu command with: gdb -batch.

This implementation would be trivial but would only pop up gdb in case of an exception such as a segmentation fault IIRC.

@dagrh would you need to interact with gdb during the normal test run time?

clebergnu avatar Jan 06 '14 12:01 clebergnu

I guess with gdb -batch you'd have to get the set of parameters virt-test passes to gdb into the batch somehow.

I can see a few cases:

  1. If it fails you just want to get it to dump a backtrace etc - for that the batch would work ok
  2. If you want to have a bit of a dig about to see what's going on then batch wouldn't be as useful
  3. Lets say you had something like a ping-pong migration test and once in a while it seg'd - I think you'd probably want to start it off and then come back to it sitting in a gdb when it failed.

dagrh avatar Jan 06 '14 12:01 dagrh

One way of doing it which seems to work ok (in the migration test) but is a bit of a hack is a wrapper script like the following. The hack with the -S check causes only the main run of qemu to go through gdb so it doesn't upset the runs which just prod it to get the version/info out. Then I pass this in as the qemu binary

''' #!/bin/sh if [ $1 = '-S' ] then exec gdb --eval-command='set pagination off' --eval-command='set confirm no' --eval-command='handle SIGPIPE print pass nostop' --eval-command='handle SIGBUS print pass nostop' --eval-command=r --eval-command='thread apply all bt full' -- eval-command=q --args /fullpath/qemu-system-x86_64 "$@" else exec /fullpath/qemu-system-x86_64 "$@" fi '''

dagrh avatar Jan 10 '14 17:01 dagrh