mbox series

[v5,00/15] Reverse debugging

Message ID 160077693745.10249.9707329107813662236.stgit@pasha-ThinkPad-X280
Headers show
Series Reverse debugging | expand

Message

Pavel Dovgalyuk Sept. 22, 2020, 12:15 p.m. UTC
GDB remote protocol supports reverse debugging of the targets.
It includes 'reverse step' and 'reverse continue' operations.
The first one finds the previous step of the execution,
and the second one is intended to stop at the last breakpoint that
would happen when the program is executed normally.

Reverse debugging is possible in the replay mode, when at least
one snapshot was created at the record or replay phase.
QEMU can use these snapshots for travelling back in time with GDB.

Running the execution in replay mode allows using GDB reverse debugging
commands:
 - reverse-stepi (or rsi): Steps one instruction to the past.
   QEMU loads on of the prior snapshots and proceeds to the desired
   instruction forward. When that step is reaches, execution stops.
 - reverse-continue (or rc): Runs execution "backwards".
   QEMU tries to find breakpoint or watchpoint by loaded prior snapshot
   and replaying the execution. Then QEMU loads snapshots again and
   replays to the latest breakpoint. When there are no breakpoints in
   the examined section of the execution, QEMU finds one more snapshot
   and tries again. After the first snapshot is processed, execution
   stops at this snapshot.

The set of patches include the following modifications:
 - gdbstub update for reverse debugging support
 - functions that automatically perform reverse step and reverse
   continue operations
 - hmp/qmp commands for manipulating the replay process
 - improvement of the snapshotting for saving the execution step
   in the snapshot parameters
 - avocado-based acceptance tests for reverse debugging

The patches are available in the repository:
https://github.com/ispras/qemu/tree/rr-200901

v5 changes:
 - disabled reverse debugging tests for gitlab-based testing
   due to the unidentified timeout problem
v4 changes:
 - added VM snapshot creation on gdb connect (suggested by Alex Bennée)
 - removed useless calls to error_free
 - updated poll interrupt processing
 - minor changes
v3 changes:
 - rebased to support the new build system
 - bumped avocado framework version for using fixed remote gdb client
v2 changes:
 - rebased to the latest upstream version
 - fixed replaying of the POLL interrupts after the latest debug changes

---

Pavel Dovgaluk (11):
      replay: provide an accessor for rr filename
      qcow2: introduce icount field for snapshots
      qapi: introduce replay.json for record/replay-related stuff
      replay: introduce info hmp/qmp command
      replay: introduce breakpoint at the specified step
      replay: implement replay-seek command
      replay: flush rr queue before loading the vmstate
      gdbstub: add reverse step support in replay mode
      gdbstub: add reverse continue support in replay mode
      replay: describe reverse debugging in docs/replay.txt
      tests/acceptance: add reverse debugging test

Pavel Dovgalyuk (4):
      replay: don't record interrupt poll
      migration: introduce icount field for snapshots
      docs: convert replay.txt to rst
      replay: create temporary snapshot at debugger connection


 MAINTAINERS                           |    2 
 accel/tcg/cpu-exec.c                  |   21 +-
 accel/tcg/translator.c                |    1 
 block/qapi.c                          |   18 +
 block/qcow2-snapshot.c                |    9 +
 block/qcow2.h                         |    3 
 blockdev.c                            |   10 +
 docs/interop/qcow2.txt                |    5 
 docs/replay.txt                       |  364 -----------------------------
 docs/system/index.rst                 |    1 
 docs/system/replay.rst                |  410 +++++++++++++++++++++++++++++++++
 exec.c                                |    8 +
 gdbstub.c                             |   64 +++++
 hmp-commands-info.hx                  |   11 +
 hmp-commands.hx                       |   50 ++++
 include/block/snapshot.h              |    1 
 include/monitor/hmp.h                 |    4 
 include/sysemu/replay.h               |   26 ++
 migration/savevm.c                    |   17 +
 qapi/block-core.json                  |   11 +
 qapi/meson.build                      |    1 
 qapi/misc.json                        |   18 -
 qapi/qapi-schema.json                 |    1 
 qapi/replay.json                      |  121 ++++++++++
 replay/meson.build                    |    1 
 replay/replay-debugging.c             |  334 +++++++++++++++++++++++++++
 replay/replay-events.c                |    4 
 replay/replay-internal.h              |    6 
 replay/replay.c                       |   22 ++
 softmmu/cpus.c                        |   19 +-
 stubs/replay.c                        |   15 +
 tests/acceptance/reverse_debugging.py |  208 +++++++++++++++++
 tests/qemu-iotests/267.out            |   48 ++--
 33 files changed, 1406 insertions(+), 428 deletions(-)
 delete mode 100644 docs/replay.txt
 create mode 100644 docs/system/replay.rst
 create mode 100644 qapi/replay.json
 create mode 100644 replay/replay-debugging.c
 create mode 100644 tests/acceptance/reverse_debugging.py

--
Pavel Dovgalyuk

Comments

no-reply@patchew.org Sept. 22, 2020, 6:48 p.m. UTC | #1
Patchew URL: https://patchew.org/QEMU/160077693745.10249.9707329107813662236.stgit@pasha-ThinkPad-X280/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 160077693745.10249.9707329107813662236.stgit@pasha-ThinkPad-X280
Subject: [PATCH v5 00/15] Reverse debugging

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
bfcc6f4 tests/acceptance: add reverse debugging test
343ce83 replay: create temporary snapshot at debugger connection
4df10da docs: convert replay.txt to rst
67714f2 replay: describe reverse debugging in docs/replay.txt
472afd4 gdbstub: add reverse continue support in replay mode
b92fa55 gdbstub: add reverse step support in replay mode
0990f34 replay: flush rr queue before loading the vmstate
2281821 replay: implement replay-seek command
30da319 replay: introduce breakpoint at the specified step
fdb8eb0 replay: introduce info hmp/qmp command
a3d1495 qapi: introduce replay.json for record/replay-related stuff
122d3a3 migration: introduce icount field for snapshots
75fe2f9 qcow2: introduce icount field for snapshots
d44e026 replay: provide an accessor for rr filename
d9d8c65 replay: don't record interrupt poll

=== OUTPUT BEGIN ===
1/15 Checking commit d9d8c659f280 (replay: don't record interrupt poll)
2/15 Checking commit d44e026c50f1 (replay: provide an accessor for rr filename)
3/15 Checking commit 75fe2f9d5334 (qcow2: introduce icount field for snapshots)
4/15 Checking commit 122d3a303369 (migration: introduce icount field for snapshots)
ERROR: trailing whitespace
#226: FILE: tests/qemu-iotests/267.out:37:
+--        snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

ERROR: trailing whitespace
#237: FILE: tests/qemu-iotests/267.out:48:
+--        snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

ERROR: trailing whitespace
#248: FILE: tests/qemu-iotests/267.out:73:
+--        snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

ERROR: trailing whitespace
#259: FILE: tests/qemu-iotests/267.out:98:
+--        snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

ERROR: trailing whitespace
#270: FILE: tests/qemu-iotests/267.out:109:
+--        snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

ERROR: trailing whitespace
#281: FILE: tests/qemu-iotests/267.out:123:
+--        snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

ERROR: trailing whitespace
#292: FILE: tests/qemu-iotests/267.out:138:
+--        snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

ERROR: trailing whitespace
#303: FILE: tests/qemu-iotests/267.out:149:
+--        snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

ERROR: trailing whitespace
#312: FILE: tests/qemu-iotests/267.out:156:
+1         snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

ERROR: trailing whitespace
#323: FILE: tests/qemu-iotests/267.out:170:
+--        snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

ERROR: trailing whitespace
#332: FILE: tests/qemu-iotests/267.out:177:
+1         snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

ERROR: trailing whitespace
#338: FILE: tests/qemu-iotests/267.out:181:
+1         snap0                SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000           $

total: 12 errors, 0 warnings, 259 lines checked

Patch 4/15 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

5/15 Checking commit a3d1495605ea (qapi: introduce replay.json for record/replay-related stuff)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#93: 
new file mode 100644

total: 0 errors, 1 warnings, 78 lines checked

Patch 5/15 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
6/15 Checking commit fdb8eb04a86b (replay: introduce info hmp/qmp command)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#122: 
new file mode 100644

total: 0 errors, 1 warnings, 120 lines checked

Patch 6/15 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
7/15 Checking commit 30da319e1bf0 (replay: introduce breakpoint at the specified step)
8/15 Checking commit 22818212bd8f (replay: implement replay-seek command)
9/15 Checking commit 0990f341c806 (replay: flush rr queue before loading the vmstate)
10/15 Checking commit b92fa55d0e24 (gdbstub: add reverse step support in replay mode)
WARNING: line over 80 characters
#220: FILE: replay/replay-debugging.c:237:
+        replay_seek(replay_get_current_icount() - 1, replay_stop_vm_debug, &err);

total: 0 errors, 1 warnings, 201 lines checked

Patch 10/15 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
11/15 Checking commit 472afd426332 (gdbstub: add reverse continue support in replay mode)
WARNING: line over 80 characters
#150: FILE: replay/replay-debugging.c:300:
+        replay_seek(replay_get_current_icount() - 1, replay_continue_stop, &err);

total: 0 errors, 1 warnings, 146 lines checked

Patch 11/15 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
12/15 Checking commit 67714f2b1ac6 (replay: describe reverse debugging in docs/replay.txt)
13/15 Checking commit 4df10da3b04d (docs: convert replay.txt to rst)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#26: 
rename from docs/replay.txt

total: 0 errors, 1 warnings, 15 lines checked

Patch 13/15 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
14/15 Checking commit 343ce83ab1d4 (replay: create temporary snapshot at debugger connection)
15/15 Checking commit bfcc6f489986 (tests/acceptance: add reverse debugging test)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#39: 
new file mode 100644

total: 0 errors, 1 warnings, 215 lines checked

Patch 15/15 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/160077693745.10249.9707329107813662236.stgit@pasha-ThinkPad-X280/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
no-reply@patchew.org Sept. 22, 2020, 6:53 p.m. UTC | #2
Patchew URL: https://patchew.org/QEMU/160077693745.10249.9707329107813662236.stgit@pasha-ThinkPad-X280/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===

Host machine cpu: x86_64
Target machine cpu family: x86
Target machine cpu: x86_64
../src/meson.build:10: WARNING: Module unstable-keyval has no backwards or forwards compatibility and might not exist in future releases.
Program sh found: YES
Program python3 found: YES (/usr/bin/python3)
Configuring ninjatool using configuration
---
Compiling C object libqemuutil.a.p/meson-generated_.._trace_trace-io.c.obj
Compiling C object libqemuutil.a.p/meson-generated_.._qapi_qapi-commands-block.c.obj

Warning, treated as error:
/tmp/qemu-test/src/docs/system/replay.rst:43:Definition list ends without a blank line; unexpected unindent.
Compiling C object libqemuutil.a.p/meson-generated_.._qapi_qapi-visit-crypto.c.obj
Compiling C object libqemuutil.a.p/meson-generated_.._qapi_qapi-events-machine.c.obj
---
Compiling C object libqemuutil.a.p/meson-generated_.._qapi_qapi-events-net.c.obj
Compiling C object libqemuutil.a.p/meson-generated_.._qapi_qapi-events-introspect.c.obj
Compiling C object libqemuutil.a.p/meson-generated_.._qapi_qapi-commands-net.c.obj
make: *** [Makefile.ninja:2244: docs/system.stamp] Error 2
make: *** Deleting file 'docs/system.stamp'
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--rm', '--label', 'com.qemu.instance.uuid=66bc903af9564d7683484a0f9a98a6cd', '-u', '1001', '--security-opt', 'seccomp=unconfined', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-ardjhm1b/src/docker-src.2020-09-22-14.49.35.7205:/var/tmp/qemu:z,ro', 'qemu/fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=66bc903af9564d7683484a0f9a98a6cd
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-ardjhm1b/src'
make: *** [docker-run-test-mingw@fedora] Error 2

real    3m22.684s
user    0m16.087s


The full log is available at
http://patchew.org/logs/160077693745.10249.9707329107813662236.stgit@pasha-ThinkPad-X280/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com