2025-04-14 13:30:17 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
#
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
# Reverse debugging test
|
|
|
|
|
#
|
2020-10-03 20:14:06 +03:00
|
|
|
# Copyright (c) 2020 ISP RAS
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
# Copyright (c) 2025 Linaro Limited
|
2020-10-03 20:14:06 +03:00
|
|
|
#
|
|
|
|
|
# Author:
|
|
|
|
|
# Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
# Gustavo Romero <gustavo.romero@linaro.org> (Run without Avocado)
|
2020-10-03 20:14:06 +03:00
|
|
|
#
|
|
|
|
|
# This work is licensed under the terms of the GNU GPL, version 2 or
|
|
|
|
|
# later. See the COPYING file in the top-level directory.
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
|
2020-10-03 20:14:06 +03:00
|
|
|
import logging
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
import os
|
2025-10-03 14:18:16 +00:00
|
|
|
from subprocess import check_output
|
2020-10-03 20:14:06 +03:00
|
|
|
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
from qemu_test import LinuxKernelTest, get_qemu_img, GDB, \
|
|
|
|
|
skipIfMissingEnv, skipIfMissingImports
|
2025-04-14 13:30:17 +02:00
|
|
|
from qemu_test.ports import Ports
|
|
|
|
|
|
2020-10-03 20:14:06 +03:00
|
|
|
|
|
|
|
|
class ReverseDebugging(LinuxKernelTest):
|
|
|
|
|
"""
|
|
|
|
|
Test GDB reverse debugging commands: reverse step and reverse continue.
|
|
|
|
|
Recording saves the execution of some instructions and makes an initial
|
|
|
|
|
VM snapshot to allow reverse execution.
|
|
|
|
|
Replay saves the order of the first instructions and then checks that they
|
|
|
|
|
are executed backwards in the correct order.
|
|
|
|
|
After that the execution is replayed to the end, and reverse continue
|
|
|
|
|
command is checked by setting several breakpoints, and asserting
|
|
|
|
|
that the execution is stopped at the last of them.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
STEPS = 10
|
|
|
|
|
|
2020-10-21 17:31:36 +01:00
|
|
|
def run_vm(self, record, shift, args, replay_path, image_path, port):
|
2025-04-14 13:30:17 +02:00
|
|
|
vm = self.get_vm(name='record' if record else 'replay')
|
2020-10-03 20:14:06 +03:00
|
|
|
vm.set_console()
|
|
|
|
|
if record:
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('recording the execution...')
|
2020-10-03 20:14:06 +03:00
|
|
|
mode = 'record'
|
|
|
|
|
else:
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('replaying the execution...')
|
2020-10-03 20:14:06 +03:00
|
|
|
mode = 'replay'
|
2020-10-21 17:31:36 +01:00
|
|
|
vm.add_args('-gdb', 'tcp::%d' % port, '-S')
|
2020-10-03 20:14:06 +03:00
|
|
|
vm.add_args('-icount', 'shift=%s,rr=%s,rrfile=%s,rrsnapshot=init' %
|
|
|
|
|
(shift, mode, replay_path),
|
|
|
|
|
'-net', 'none')
|
|
|
|
|
vm.add_args('-drive', 'file=%s,if=none' % image_path)
|
|
|
|
|
if args:
|
|
|
|
|
vm.add_args(*args)
|
|
|
|
|
vm.launch()
|
|
|
|
|
return vm
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
def get_pc(gdb: GDB):
|
|
|
|
|
return gdb.cli("print $pc").get_addr()
|
2020-10-03 20:14:06 +03:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def vm_get_icount(vm):
|
|
|
|
|
return vm.qmp('query-replay')['return']['icount']
|
|
|
|
|
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
@skipIfMissingImports("pygdbmi") # Required by GDB class
|
|
|
|
|
@skipIfMissingEnv("QEMU_TEST_GDB")
|
|
|
|
|
def reverse_debugging(self, gdb_arch, shift=7, args=None):
|
|
|
|
|
from qemu_test import GDB
|
2025-04-14 13:30:17 +02:00
|
|
|
|
2020-10-03 20:14:06 +03:00
|
|
|
# create qcow2 for snapshots
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('creating qcow2 image for VM snapshots')
|
2020-10-03 20:14:06 +03:00
|
|
|
image_path = os.path.join(self.workdir, 'disk.qcow2')
|
2025-04-14 13:30:17 +02:00
|
|
|
qemu_img = get_qemu_img(self)
|
|
|
|
|
if qemu_img is None:
|
|
|
|
|
self.skipTest('Could not find "qemu-img", which is required to '
|
|
|
|
|
'create the temporary qcow2 image')
|
2025-10-03 14:18:16 +00:00
|
|
|
out = check_output([qemu_img, 'create', '-f', 'qcow2', image_path, '128M'],
|
|
|
|
|
encoding='utf8')
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info("qemu-img: %s" % out)
|
2020-10-03 20:14:06 +03:00
|
|
|
|
|
|
|
|
replay_path = os.path.join(self.workdir, 'replay.bin')
|
|
|
|
|
|
|
|
|
|
# record the log
|
2025-04-14 13:30:17 +02:00
|
|
|
vm = self.run_vm(True, shift, args, replay_path, image_path, -1)
|
2020-10-03 20:14:06 +03:00
|
|
|
while self.vm_get_icount(vm) <= self.STEPS:
|
|
|
|
|
pass
|
|
|
|
|
last_icount = self.vm_get_icount(vm)
|
|
|
|
|
vm.shutdown()
|
|
|
|
|
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info("recorded log with %s+ steps" % last_icount)
|
2020-10-03 20:14:06 +03:00
|
|
|
|
|
|
|
|
# replay and run debug commands
|
2025-04-14 13:30:17 +02:00
|
|
|
with Ports() as ports:
|
|
|
|
|
port = ports.find_free_port()
|
|
|
|
|
vm = self.run_vm(False, shift, args, replay_path, image_path, port)
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
|
|
|
|
|
try:
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('Connecting to gdbstub...')
|
2025-10-14 15:00:47 +01:00
|
|
|
gdb_cmd = os.getenv('QEMU_TEST_GDB')
|
|
|
|
|
gdb = GDB(gdb_cmd)
|
|
|
|
|
try:
|
|
|
|
|
self.reverse_debugging_run(gdb, vm, port, gdb_arch, last_icount)
|
|
|
|
|
finally:
|
|
|
|
|
self.log.info('exiting gdb and qemu')
|
|
|
|
|
gdb.exit()
|
|
|
|
|
vm.shutdown()
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('Test passed.')
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
except GDB.TimeoutError:
|
|
|
|
|
# Convert a GDB timeout exception into a unittest failure exception.
|
|
|
|
|
raise self.failureException("Timeout while connecting to or "
|
|
|
|
|
"communicating with gdbstub...") from None
|
|
|
|
|
except Exception:
|
|
|
|
|
# Re-throw exceptions from unittest, like the ones caused by fail(),
|
|
|
|
|
# skipTest(), etc.
|
|
|
|
|
raise
|
|
|
|
|
|
2025-10-14 15:00:47 +01:00
|
|
|
def reverse_debugging_run(self, gdb, vm, port, gdb_arch, last_icount):
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
r = gdb.cli("set architecture").get_log()
|
|
|
|
|
if gdb_arch not in r:
|
|
|
|
|
self.skipTest(f"GDB does not support arch '{gdb_arch}'")
|
|
|
|
|
|
|
|
|
|
gdb.cli("set debug remote 1")
|
|
|
|
|
|
|
|
|
|
c = gdb.cli(f"target remote localhost:{port}").get_console()
|
|
|
|
|
if not f"Remote debugging using localhost:{port}" in c:
|
|
|
|
|
self.fail("Could not connect to gdbstub!")
|
|
|
|
|
|
|
|
|
|
# Remote debug messages are in 'log' payloads.
|
|
|
|
|
r = gdb.get_log()
|
|
|
|
|
if 'ReverseStep+' not in r:
|
2020-10-03 20:14:06 +03:00
|
|
|
self.fail('Reverse step is not supported by QEMU')
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
if 'ReverseContinue+' not in r:
|
2020-10-03 20:14:06 +03:00
|
|
|
self.fail('Reverse continue is not supported by QEMU')
|
|
|
|
|
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
gdb.cli("set debug remote 0")
|
|
|
|
|
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('stepping forward')
|
2020-10-03 20:14:06 +03:00
|
|
|
steps = []
|
|
|
|
|
# record first instruction addresses
|
|
|
|
|
for _ in range(self.STEPS):
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
pc = self.get_pc(gdb)
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('saving position %x' % pc)
|
2020-10-03 20:14:06 +03:00
|
|
|
steps.append(pc)
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
gdb.cli("stepi")
|
2020-10-03 20:14:06 +03:00
|
|
|
|
|
|
|
|
# visit the recorded instruction in reverse order
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('stepping backward')
|
2020-10-03 20:14:06 +03:00
|
|
|
for addr in steps[::-1]:
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('found position %x' % addr)
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
gdb.cli("reverse-stepi")
|
|
|
|
|
pc = self.get_pc(gdb)
|
|
|
|
|
if pc != addr:
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('Invalid PC (read %x instead of %x)' % (pc, addr))
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
self.fail('Reverse stepping failed!')
|
2020-10-03 20:14:06 +03:00
|
|
|
|
2023-08-08 14:20:00 +10:00
|
|
|
# visit the recorded instruction in forward order
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('stepping forward')
|
2023-08-08 14:20:00 +10:00
|
|
|
for addr in steps:
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('found position %x' % addr)
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
pc = self.get_pc(gdb)
|
|
|
|
|
if pc != addr:
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('Invalid PC (read %x instead of %x)' % (pc, addr))
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
self.fail('Forward stepping failed!')
|
|
|
|
|
gdb.cli("stepi")
|
2020-10-03 20:14:06 +03:00
|
|
|
|
2023-08-08 14:20:00 +10:00
|
|
|
# set breakpoints for the instructions just stepped over
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('setting breakpoints')
|
2020-10-03 20:14:06 +03:00
|
|
|
for addr in steps:
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
gdb.cli(f"break *{hex(addr)}")
|
2020-10-03 20:14:06 +03:00
|
|
|
|
2023-08-08 14:20:00 +10:00
|
|
|
# this may hit a breakpoint if first instructions are executed
|
|
|
|
|
# again
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('continuing execution')
|
2023-08-08 14:20:00 +10:00
|
|
|
vm.qmp('replay-break', icount=last_icount - 1)
|
|
|
|
|
# continue - will return after pausing
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
# This can stop at the end of the replay-break and gdb gets a SIGINT,
|
|
|
|
|
# or by re-executing one of the breakpoints and gdb stops at a
|
|
|
|
|
# breakpoint.
|
|
|
|
|
gdb.cli("continue")
|
|
|
|
|
|
2023-08-08 14:20:00 +10:00
|
|
|
if self.vm_get_icount(vm) == last_icount - 1:
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('reached the end (icount %s)' % (last_icount - 1))
|
2023-08-08 14:20:00 +10:00
|
|
|
else:
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('hit a breakpoint again at %x (icount %s)' %
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
(self.get_pc(gdb), self.vm_get_icount(vm)))
|
2023-08-08 14:20:00 +10:00
|
|
|
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('running reverse continue to reach %x' % steps[-1])
|
2020-10-03 20:14:06 +03:00
|
|
|
# reverse continue - will return after stopping at the breakpoint
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
gdb.cli("reverse-continue")
|
2020-10-03 20:14:06 +03:00
|
|
|
|
|
|
|
|
# assume that none of the first instructions is executed again
|
|
|
|
|
# breaking the order of the breakpoints
|
tests/functional: Adapt reverse_debugging to run w/o Avocado
This commit removes Avocado as a dependency for running the
reverse_debugging test.
The main benefit, beyond eliminating an extra dependency, is that there
is no longer any need to handle GDB packets manually. This removes the
need for ad-hoc functions dealing with endianness and arch-specific
register numbers, making the test easier to read. The timeout variable
is also removed, since Meson now manages timeouts automatically.
reverse_debugging now uses the pygdbmi module to interact with GDB, if
it is available in the test environment, otherwise the test is skipped.
GDB is detect via the QEMU_TEST_GDB env. variable.
This commit also significantly improves the output for the test and
now prints all the GDB commands used in sequence. It also adds
some clarifications to existing comments, for example, clarifying that
once the replay-break is reached, a SIGINT is captured in GDB.
reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so
won't run unless QEMU_TEST_FLAKY_TESTS=1 is set in the test environment,
before running 'make check-functional' or 'meson test [...]'.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Message-ID: <20251003141820.85278-9-gustavo.romero@linaro.org>
[AJB: it is and broke long line]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Thomas Huth <thuth@redhat.com>
2025-10-03 14:18:19 +00:00
|
|
|
pc = self.get_pc(gdb)
|
|
|
|
|
if pc != steps[-1]:
|
|
|
|
|
self.fail("'reverse-continue' did not hit the first PC in reverse order!")
|
|
|
|
|
|
2025-10-14 15:00:46 +01:00
|
|
|
self.log.info('successfully reached %x' % steps[-1])
|