gdbstub and testing fixes for 8.2
cover gdbstub and testing fixes for 8.2
This is the current state for my maintainer queue for when the tree re-opens. It includes the previous testing/next fixes as well as some more cleanups to modernise the gdbstub tests and code. It also includes Matheus' fixes for SIGINT.
The following patches need review:
gdbstub: replace global gdb_has_xml with a function
gdbstub: refactor get_feature_xml
gdbstub: remove unused user_ctx field tests/tcg: clean-up gdb confirm/pagination settings
tests: remove test-gdbstub.py
tests/tcg: remove quoting for info output
Alex Bennée (7):
tests/docker: cleanup non-verbose output tests/tcg: remove quoting for info output
tests: remove test-gdbstub.py
tests/tcg: clean-up gdb confirm/pagination settings
gdbstub: remove unused user_ctx field
gdbstub: refactor get_feature_xml
gdbstub: replace global gdb_has_xml with a function
Daniel P. Berrangé (1):
gitlab: enable ccache for many build jobs
Matheus Branco Borella (1):
gdbstub: fixes cases where wrong threads were reported to GDB on
SIGINT
docs/devel/ci-jobs.rst.inc | 7 + gdbstub/internals.h | 3 +- include/exec/gdbstub.h | 10 +- gdbstub/gdbstub.c | 119 +++++++----- gdbstub/softmmu.c | 1 - gdbstub/user.c | 1 - target/arm/gdbstub.c | 8 +- target/ppc/gdbstub.c | 4 +- tests/tcg/multiarch/system/interrupt.c | 28 +++ .gitlab-ci.d/buildtest-template.yml | 11 ++ .gitlab-ci.d/crossbuild-template.yml | 26 +++ .gitlab-ci.d/windows.yml | 13 +- tests/docker/Makefile.include | 6 +- .../dockerfiles/debian-hexagon-cross.docker | 9 +- tests/guest-debug/run-test.py | 2 + tests/guest-debug/test-gdbstub.py | 177 ------------------ tests/tcg/aarch64/Makefile.target | 2 +- tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 3 - tests/tcg/aarch64/gdbstub/test-sve.py | 3 - tests/tcg/multiarch/gdbstub/interrupt.py | 97 ++++++++++ tests/tcg/multiarch/gdbstub/memory.py | 3 - tests/tcg/multiarch/gdbstub/sha1.py | 4 - .../multiarch/gdbstub/test-proc-mappings.py | 4 - .../multiarch/gdbstub/test-qxfer-auxv-read.py | 4 - .../gdbstub/test-thread-breakpoint.py | 4 - .../multiarch/system/Makefile.softmmu-target | 16 +- tests/tcg/s390x/gdbstub/test-signals-s390x.py | 4 - tests/tcg/s390x/gdbstub/test-svc.py | 4 - 28 files changed, 293 insertions(+), 280 deletions(-) create mode 100644 tests/tcg/multiarch/system/interrupt.c delete mode 100644 tests/guest-debug/test-gdbstub.py create mode 100644 tests/tcg/multiarch/gdbstub/interrupt.py
Signature · 1 line
2.39.2
PATCH 1/9 gitlab: enable ccache for many build jobs
From: Daniel P. Berrangé <[email protected]>
The ccache tool can be very effective at reducing compilation times when re-running pipelines with only minor changes each time. For example a fresh 'build-system-fedora' job will typically take 20 minutes on the gitlab.com shared runners. With ccache this is reduced to as little as 6 minutes.
Normally meson would auto-detect existance of ccache in $PATH and use it automatically, but the way we wrap meson from configure breaks this, as we're passing in an config file with explicitly set compiler paths. Thus we need to add $CCACHE_WRAPPERSPATH to the front of $PATH. For unknown reasons if doing this in msys though, gcc becomes unable to invoke 'cc1' when run from meson. For msys we thus set CC='ccache gcc' before invoking 'configure' instead.
A second problem with msys is that cache misses are incredibly expensive, so enabling ccache massively slows down the build when the cache isn't well populated. This is suspected to be a result of the cost of spawning processes under the msys architecture. To deal with this we set CCACHE_DEPEND=1 which enables ccache's 'depend_only' strategy. This avoids extra spawning of the pre-processor during cache misses, with the downside that is it less likely ccache will find a cache hit after semantically benign compiler flag changes. This is the lesser of two evils, as otherwise we can't use ccache at all under msys and remain inside the job time limit.
If people are finding ccache to hurt their pipelines, it can be disabled by setting the 'CCACHE_DISABLE=1' env variable against their gitlab fork CI settings.
Message-Id: <[email protected]>
--- docs/devel/ci-jobs.rst.inc | 7 +++++ .gitlab-ci.d/buildtest-template.yml | 11 ++++++++ .gitlab-ci.d/crossbuild-template.yml | 26 +++++++++++++++++++ .gitlab-ci.d/windows.yml | 13 ++++++++-- .../dockerfiles/debian-hexagon-cross.docker | 9 ++++++- 5 files changed, 63 insertions(+), 3 deletions(-)
docs/devel/ci-jobs.rst.inc +7 -0
@@ -188,3 +188,10 @@ If you've got access to a CentOS Stream 8 x86_64 host that can be used as a gitlab-CI runner, you can set this variable to enable the tests that require this kind of host. The runner should be tagged with both "centos_stream_8" and "x86_64". + +CCACHE_DISABLE +~~~~~~~~~~~~~~ +The jobs are configured to use "ccache" by default since this typically +reduces compilation time, at the cost of increased storage. If the +use of "ccache" is suspected to be hurting the overall job execution +time, setting the "CCACHE_DISABLE=1" env variable to disable it.
.gitlab-ci.d/buildtest-template.yml +11 -0
@@ -2,11 +2,21 @@ extends: .base_job_template stage: build image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG + cache: + paths: + - ccache + key: "$CI_JOB_NAME" + when: always before_script: - JOBS=$(expr $(nproc) + 1) script: + - export CCACHE_BASEDIR="$(pwd)" + - export CCACHE_DIR="$CCACHE_BASEDIR/ccache" + - export CCACHE_MAXSIZE="500M" + - export PATH="$CCACHE_WRAPPERSDIR:$PATH" - mkdir build - cd build + - ccache --zero-stats - ../configure --enable-werror --disable-docs --enable-fdt=system ${TARGETS:+--target-list="$TARGETS"} $CONFIGURE_ARGS ||
@@ -20,6 +30,7 @@ then make -j"$JOBS" $MAKE_CHECK_ARGS ; fi + - ccache --show-stats # We jump some hoops in common_test_job_template to avoid # rebuilding all the object files we skip in the artifacts
.gitlab-ci.d/crossbuild-template.yml +26 -0
@@ -2,10 +2,20 @@ extends: .base_job_template stage: build image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG + cache: + paths: + - ccache + key: "$CI_JOB_NAME" + when: always timeout: 80m script: + - export CCACHE_BASEDIR="$(pwd)" + - export CCACHE_DIR="$CCACHE_BASEDIR/ccache" + - export CCACHE_MAXSIZE="500M" + - export PATH="$CCACHE_WRAPPERSDIR:$PATH" - mkdir build - cd build + - ccache --zero-stats - ../configure --enable-werror --disable-docs --enable-fdt=system --disable-user $QEMU_CONFIGURE_OPTS $EXTRA_CONFIGURE_OPTS --target-list-exclude="arm-softmmu cris-softmmu
@@ -18,6 +28,7 @@ version="$(git describe --match v[0-9]* 2>/dev/null || git rev-parse --short HEAD)"; mv -v qemu-setup*.exe qemu-setup-${version}.exe; fi + - ccache --show-stats # Job to cross-build specific accelerators. #
@@ -29,7 +40,15 @@ stage: build image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG timeout: 30m + cache: + paths: + - ccache/ + key: "$CI_JOB_NAME" script: + - export CCACHE_BASEDIR="$(pwd)" + - export CCACHE_DIR="$CCACHE_BASEDIR/ccache" + - export CCACHE_MAXSIZE="500M" + - export PATH="$CCACHE_WRAPPERSDIR:$PATH" - mkdir build - cd build - ../configure --enable-werror --disable-docs $QEMU_CONFIGURE_OPTS
@@ -40,7 +59,14 @@ extends: .base_job_template stage: build image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG + cache: + paths: + - ccache/ + key: "$CI_JOB_NAME" script: + - export CCACHE_BASEDIR="$(pwd)" + - export CCACHE_DIR="$CCACHE_BASEDIR/ccache" + - export CCACHE_MAXSIZE="500M" - mkdir build - cd build - ../configure --enable-werror --disable-docs $QEMU_CONFIGURE_OPTS
.gitlab-ci.d/windows.yml +11 -2
@@ -5,13 +5,14 @@ - windows - windows-1809 cache: - key: "${CI_JOB_NAME}-cache" + key: "$CI_JOB_NAME" paths: - msys64/var/cache + - ccache when: always needs: [] stage: build - timeout: 80m + timeout: 100m variables: # This feature doesn't (currently) work with PowerShell, it stops # the echo'ing of commands being run and doesn't show any timing
@@ -72,6 +73,7 @@ bison diffutils flex git grep make sed $MINGW_TARGET-capstone + $MINGW_TARGET-ccache $MINGW_TARGET-curl $MINGW_TARGET-cyrus-sasl $MINGW_TARGET-dtc
@@ -101,11 +103,18 @@ - Write-Output "Running build at $(Get-Date -Format u)" - $env:CHERE_INVOKING = 'yes' # Preserve the current working directory - $env:MSYS = 'winsymlinks:native' # Enable native Windows symlink + - $env:CCACHE_BASEDIR = "$env:CI_PROJECT_DIR" + - $env:CCACHE_DIR = "$env:CCACHE_BASEDIR/ccache" + - $env:CCACHE_MAXSIZE = "500M" + - $env:CCACHE_DEPEND = 1 # cache misses are too expensive with preprocessor mode + - $env:CC = "ccache gcc" - mkdir build - cd build + - ..\msys64\usr\bin\bash -lc "ccache --zero-stats" - ..\msys64\usr\bin\bash -lc "../configure --enable-fdt=system $CONFIGURE_ARGS" - ..\msys64\usr\bin\bash -lc "make" - ..\msys64\usr\bin\bash -lc "make check MTESTARGS='$TEST_ARGS' || { cat meson-logs/testlog.txt; exit 1; } ;" + - ..\msys64\usr\bin\bash -lc "ccache --show-stats" - Write-Output "Finished build at $(Get-Date -Format u)" msys2-64bit:
tests/docker/dockerfiles/debian-hexagon-cross.docker +8 -1
@@ -15,6 +15,7 @@ RUN apt-get update && \ # Install common build utilities apt-get install -y --no-install-recommends \ curl \ + ccache \ xz-utils \ ca-certificates \ bison \
@@ -24,13 +25,19 @@ RUN apt-get update && \ python3-venv && \ # Install QEMU build deps for use in CI DEBIAN_FRONTEND=noninteractive eatmydata \ - apt build-dep -yy --arch-only qemu + apt build-dep -yy --arch-only qemu && \ + mkdir -p /usr/libexec/ccache-wrappers && \ + ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/c++ && \ + ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/cc && \ + ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/g++ && \ + ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/gcc ENV TOOLCHAIN_INSTALL /opt ENV TOOLCHAIN_RELEASE 16.0.0 ENV TOOLCHAIN_BASENAME "clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-linux-musl" ENV TOOLCHAIN_URL https://codelinaro.jfrog.io/artifactory/codelinaro-toolchain-for-hexagon/v${TOOLCHAIN_RELEASE}/${TOOLCHAIN_BASENAME}.tar.xz +ENV CCACHE_WRAPPERSDIR "/usr/libexec/ccache-wrappers" RUN curl -#SL "$TOOLCHAIN_URL" | tar -xJC "$TOOLCHAIN_INSTALL" ENV PATH $PATH:${TOOLCHAIN_INSTALL}/${TOOLCHAIN_BASENAME}/x86_64-linux-gnu/bin
Signature · 1 line
2.39.2
PATCH 2/9 tests/docker: cleanup non-verbose output
In reply to Alex BennéeEven with --quiet docker will spam the sha256 to the console. Avoid this by redirecting stdout. While we are at it fix the name we echo which was broken during 0b1a649047 (tests/docker: use direct RUNC call to build containers).
--- tests/docker/Makefile.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/docker/Makefile.include +3 -3
@@ -46,9 +46,9 @@ docker-image-%: $(DOCKER_FILES_DIR)/%.docker --build-arg BUILDKIT_INLINE_CACHE=1 \ $(if $(NOUSER),, \ --build-arg USER=$(USER) \ - --build-arg UID=$(UID)) \ - -t qemu/$* - < $<, \ - "BUILD", $1) + --build-arg UID=$(UID)) \ + -t qemu/$* - < $< $(if $V,,> /dev/null),\ + "BUILD", $*) # Special rule for debootstraped binfmt linux-user images docker-binfmt-image-debian-%: $(DOCKER_FILES_DIR)/debian-bootstrap.docker
Signature · 1 line
2.39.2
Re: [PATCH 2/9] tests/docker: cleanup non-verbose output
Quoted 10 lines · Alex Bennée
Even with --quiet docker will spam the sha256 to the console. Avoid this by redirecting stdout. While we are at it fix the name we echo which was broken during
0b1a649047(tests/docker: use direct RUNC call to build containers).Signed-off-by Alex Bennée <[email protected]>Reviewed-by Thomas Huth <[email protected]>--- tests/docker/Makefile.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
PATCH 3/9 tests/tcg: remove quoting for info output
In reply to Alex BennéeThis avoids ugly multi-line wrapping for the test on non V=1 builds.
--- tests/tcg/aarch64/Makefile.target | 2 +- tests/tcg/multiarch/system/Makefile.softmmu-target | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
tests/tcg/aarch64/Makefile.target +1 -1
@@ -14,7 +14,7 @@ AARCH64_TESTS=fcvt pcalign-a64 lse2-fault fcvt: LDFLAGS+=-lm run-fcvt: fcvt - $(call run-test,$<,$(QEMU) $<, "$< on $(TARGET_NAME)") + $(call run-test,$<,$(QEMU) $<) $(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref) config-cc.mak: Makefile
tests/tcg/multiarch/system/Makefile.softmmu-target +2 -2
@@ -37,10 +37,10 @@ run-gdbstub-untimely-packet: hello --qemu $(QEMU) \ --bin $< --qargs \ "-monitor none -display none -chardev file$(COMMA)path=untimely-packet.out$(COMMA)id=output $(QEMU_OPTS)", \ - "softmmu gdbstub untimely packets") + softmmu gdbstub untimely packets) $(call quiet-command, \ (! grep -Fq 'Packet instead of Ack, ignoring it' untimely-packet.gdb.err), \ - "GREP", "file untimely-packet.gdb.err") + "GREP", file untimely-packet.gdb.err) else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "no guest arch support")
Signature · 1 line
2.39.2
PATCH 4/9 tests: remove test-gdbstub.py
In reply to Alex BennéeThis isn't directly called by our CI and because it doesn't run via our run-test.py script does things slightly differently. Lets remove it as we have plenty of working in-tree tests now for various aspects of gdbstub.
--- tests/guest-debug/test-gdbstub.py | 177 ------------------------------ 1 file changed, 177 deletions(-) delete mode 100644 tests/guest-debug/test-gdbstub.py
tests/guest-debug/test-gdbstub.py deleted +0 -177
@@ -1,177 +0,0 @@ -# -# This script needs to be run on startup -# qemu -kernel ${KERNEL} -s -S -# and then: -# gdb ${KERNEL}.vmlinux -x ${QEMU_SRC}/tests/guest-debug/test-gdbstub.py - -import gdb - -failcount = 0 - - -def report(cond, msg): - "Report success/fail of test" - if cond: - print ("PASS: %s" % (msg)) - else: - print ("FAIL: %s" % (msg)) - global failcount - failcount += 1 - - -def check_step(): - "Step an instruction, check it moved." - start_pc = gdb.parse_and_eval('$pc') - gdb.execute("si") - end_pc = gdb.parse_and_eval('$pc') - - return not (start_pc == end_pc) - - -def check_break(sym_name): - "Setup breakpoint, continue and check we stopped." - sym, ok = gdb.lookup_symbol(sym_name) - bp = gdb.Breakpoint(sym_name) - - gdb.execute("c") - - # hopefully we came back - end_pc = gdb.parse_and_eval('$pc') - print ("%s == %s %d" % (end_pc, sym.value(), bp.hit_count)) - bp.delete() - - # can we test we hit bp? - return end_pc == sym.value() - - -# We need to do hbreak manually as the python interface doesn't export it -def check_hbreak(sym_name): - "Setup hardware breakpoint, continue and check we stopped." - sym, ok = gdb.lookup_symbol(sym_name) - gdb.execute("hbreak %s" % (sym_name)) - gdb.execute("c") - - # hopefully we came back - end_pc = gdb.parse_and_eval('$pc') - print ("%s == %s" % (end_pc, sym.value())) - - if end_pc == sym.value(): - gdb.execute("d 1") - return True - else: - return False - - -class WatchPoint(gdb.Breakpoint): - - def get_wpstr(self, sym_name): - "Setup sym and wp_str for given symbol." - self.sym, ok = gdb.lookup_symbol(sym_name) - wp_addr = gdb.parse_and_eval(sym_name).address - self.wp_str = '*(%(type)s)(&%(address)s)' % dict( - type = wp_addr.type, address = sym_name) - - return(self.wp_str) - - def __init__(self, sym_name, type): - wp_str = self.get_wpstr(sym_name) - super(WatchPoint, self).__init__(wp_str, gdb.BP_WATCHPOINT, type) - - def stop(self): - end_pc = gdb.parse_and_eval('$pc') - print ("HIT WP @ %s" % (end_pc)) - return True - - -def do_one_watch(sym, wtype, text): - - wp = WatchPoint(sym, wtype) - gdb.execute("c") - report_str = "%s for %s (%s)" % (text, sym, wp.sym.value()) - - if wp.hit_count > 0: - report(True, report_str) - wp.delete() - else: - report(False, report_str) - - -def check_watches(sym_name): - "Watch a symbol for any access." - - # Should hit for any read - do_one_watch(sym_name, gdb.WP_ACCESS, "awatch") - - # Again should hit for reads - do_one_watch(sym_name, gdb.WP_READ, "rwatch") - - # Finally when it is written - do_one_watch(sym_name, gdb.WP_WRITE, "watch") - - -class CatchBreakpoint(gdb.Breakpoint): - def __init__(self, sym_name): - super(CatchBreakpoint, self).__init__(sym_name) - self.sym, ok = gdb.lookup_symbol(sym_name) - - def stop(self): - end_pc = gdb.parse_and_eval('$pc') - print ("CB: %s == %s" % (end_pc, self.sym.value())) - if end_pc == self.sym.value(): - report(False, "Hit final catchpoint") - - -def run_test(): - "Run through the tests one by one" - - print ("Checking we can step the first few instructions") - step_ok = 0 - for i in range(3): - if check_step(): - step_ok += 1 - - report(step_ok == 3, "single step in boot code") - - print ("Checking HW breakpoint works") - break_ok = check_hbreak("kernel_init") - report(break_ok, "hbreak @ kernel_init") - - # Can't set this up until we are in the kernel proper - # if we make it to run_init_process we've over-run and - # one of the tests failed - print ("Setup catch-all for run_init_process") - cbp = CatchBreakpoint("run_init_process") - cpb2 = CatchBreakpoint("try_to_run_init_process") - - print ("Checking Normal breakpoint works") - break_ok = check_break("wait_for_completion") - report(break_ok, "break @ wait_for_completion") - - print ("Checking watchpoint works") - check_watches("system_state") - -# -# This runs as the script it sourced (via -x) -# - -try: - print ("Connecting to remote") - gdb.execute("target remote localhost:1234") - - # These are not very useful in scripts - gdb.execute("set pagination off") - gdb.execute("set confirm off") - - # Run the actual tests - run_test() - -except: - print ("GDB Exception: %s" % (sys.exc_info()[0])) - failcount += 1 - import code - code.InteractiveConsole(locals=globals()).interact() - raise - -# Finally kill the inferior and exit gdb with a count of failures -gdb.execute("kill") -exit(failcount)
Signature · 1 line
2.39.2
Re: [PATCH 4/9] tests: remove test-gdbstub.py
Quoted 11 lines · Alex Bennée
This isn't directly called by our CI and because it doesn't run via our
run-test.pyscript does things slightly differently. Lets remove it as we have plenty of working in-tree tests now for various aspects of gdbstub.Signed-off-by Alex Bennée <[email protected]>---
tests/guest-debug/test-gdbstub.py | 177 ---------------------------- --1 file changed, 177 deletions(-)delete mode 100644
tests/guest-debug/test-gdbstub.py
There doesn't seem to be a hbreak test elsewhere, but according to a comment in tcg/multiarch/gdbstub/memory.py it would be mapped to a normal break anyway.
Re: [PATCH 4/9] tests: remove test-gdbstub.py
Quoted 13 lines · Ilya Leoshkevich
Quoted 11 lines · Alex Bennée
This isn't directly called by our CI and because it doesn't run via our
run-test.pyscript does things slightly differently. Lets remove it as we have plenty of working in-tree tests now for various aspects of gdbstub.Signed-off-by Alex Bennée <[email protected]>---
tests/guest-debug/test-gdbstub.py | 177 ---------------------------- --1 file changed, 177 deletions(-)delete mode 100644
tests/guest-debug/test-gdbstub.py
Quoted 3 lines
There doesn't seem to be a hbreak test elsewhere, but according to a comment in
tcg/multiarch/gdbstub/memory.pyit would be mapped to a normal break anyway.
It is for TCG but for other accelerators there will be different handling (although I'm fairly sure only x86 and aarch64 are currently plumbed to use the CPUs hbreak bits on KVM).
However this particular script was a very early addition when I was testing stuff manually with images I'd built on my system. If we want to exercise the gdbstub for accelerators it might be better porting the test to avocado?
Quoted 2 lines
Acked-by Ilya Leoshkevich <[email protected]>
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Re: [PATCH 4/9] tests: remove test-gdbstub.py
Quoted 29 lines · Alex Bennée
Quoted 17 lines · Ilya Leoshkevich
Quoted 8 lines · Alex Bennée
This isn't directly called by our CI and because it doesn't run via
ourrun-test.pyscript does things slightly differently. Lets remove
it as we have plenty of working in-tree tests now for various aspects
of gdbstub.Quoted 7 lines
Signed-off-by Alex Bennée <[email protected]>---
tests/guest-debug/test-gdbstub.py | 177 ------------------------
----
--1 file changed, 177 deletions(-)delete mode 100644
tests/guest-debug/test-gdbstub.pyQuoted 4 lines
There doesn't seem to be a hbreak test elsewhere, but according to a
comment intcg/multiarch/gdbstub/memory.pyit would be mapped to a normal break anyway.It is for TCG but for other accelerators there will be different handling (although I'm fairly sure only x86 and aarch64 are currently plumbed to use the CPUs hbreak bits on KVM).
Quoted 5 lines
However this particular script was a very early addition when I was testing stuff manually with images I'd built on my system. If we want to
exercise the gdbstub for accelerators it might be better porting the test to avocado?
That would be good, yes.
I was always wondering if the TCG sotfmmu tests could be used to test the other accelerators? At least for s390x there is nothing TCG-specific there (besides that they try to trigger TCG-specific problems), and I sometimes run them manually with KVM as a sanity check.
Quoted 5 lines
Quoted 3 lines
Acked-by Ilya Leoshkevich <[email protected]>
PATCH 5/9 tests/tcg: clean-up gdb confirm/pagination settings
In reply to Alex BennéeWe can do this all in the run-test.py script so remove the extraneous bits from the individual tests which got copied from the original non-CI gdb tests.
--- tests/guest-debug/run-test.py | 2 ++ tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 3 --- tests/tcg/aarch64/gdbstub/test-sve.py | 3 --- tests/tcg/multiarch/gdbstub/memory.py | 3 --- tests/tcg/multiarch/gdbstub/sha1.py | 4 ---- tests/tcg/multiarch/gdbstub/test-proc-mappings.py | 4 ---- tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py | 4 ---- tests/tcg/multiarch/gdbstub/test-thread-breakpoint.py | 4 ---- tests/tcg/s390x/gdbstub/test-signals-s390x.py | 4 ---- tests/tcg/s390x/gdbstub/test-svc.py | 4 ---- 10 files changed, 2 insertions(+), 33 deletions(-)
tests/guest-debug/run-test.py +2 -0
@@ -83,6 +83,8 @@ def log(output, msg): gdb_cmd += " %s" % (args.gdb_args) # run quietly and ignore .gdbinit gdb_cmd += " -q -n -batch" + # disable pagination + gdb_cmd += " -ex 'set pagination off'" # disable prompts in case of crash gdb_cmd += " -ex 'set confirm off'" # connect to remote
tests/tcg/aarch64/gdbstub/test-sve-ioctl.py +0 -3
@@ -76,9 +76,6 @@ def run_test(): exit(0) try: - # These are not very useful in scripts - gdb.execute("set pagination off") - # Run the actual tests run_test() except:
tests/tcg/aarch64/gdbstub/test-sve.py +0 -3
@@ -66,9 +66,6 @@ def run_test(): exit(0) try: - # These are not very useful in scripts - gdb.execute("set pagination off") - # Run the actual tests run_test() except:
tests/tcg/multiarch/gdbstub/memory.py +0 -3
@@ -115,9 +115,6 @@ def run_test(): exit(0) try: - # These are not very useful in scripts - gdb.execute("set pagination off") - # Run the actual tests run_test() except (gdb.error):
tests/tcg/multiarch/gdbstub/sha1.py +0 -4
@@ -73,10 +73,6 @@ def run_test(): exit(0) try: - # These are not very useful in scripts - gdb.execute("set pagination off") - gdb.execute("set confirm off") - # Run the actual tests run_test() except (gdb.error):
tests/tcg/multiarch/gdbstub/test-proc-mappings.py +0 -4
@@ -51,10 +51,6 @@ def main(): exit(0) try: - # These are not very useful in scripts - gdb.execute("set pagination off") - gdb.execute("set confirm off") - # Run the actual tests run_test() except gdb.error:
tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py +0 -4
@@ -42,10 +42,6 @@ def run_test(): exit(0) try: - # These are not very useful in scripts - gdb.execute("set pagination off") - gdb.execute("set confirm off") - # Run the actual tests run_test() except (gdb.error):
tests/tcg/multiarch/gdbstub/test-thread-breakpoint.py +0 -4
@@ -45,10 +45,6 @@ def run_test(): exit(0) try: - # These are not very useful in scripts - gdb.execute("set pagination off") - gdb.execute("set confirm off") - # Run the actual tests run_test() except (gdb.error):
tests/tcg/s390x/gdbstub/test-signals-s390x.py +0 -4
@@ -61,10 +61,6 @@ def run_test(): exit(0) try: - # These are not very useful in scripts - gdb.execute("set pagination off") - gdb.execute("set confirm off") - # Run the actual tests run_test() except (gdb.error):
tests/tcg/s390x/gdbstub/test-svc.py +0 -4
@@ -49,10 +49,6 @@ def main(): exit(0) try: - # These are not very useful in scripts - gdb.execute("set pagination off") - gdb.execute("set confirm off") - # Run the actual tests run_test() except gdb.error:
Signature · 1 line
2.39.2
Re: [PATCH 5/9] tests/tcg: clean-up gdb confirm/pagination settings
Quoted 16 lines · Alex Bennée
We can do this all in the
run-test.pyscript so remove the extraneous bits from the individual tests which got copied from the original non-CI gdb tests.Signed-off-by Alex Bennée <[email protected]>---
tests/guest-debug/run-test.py | 2 ++ tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 3 --- tests/tcg/aarch64/gdbstub/test-sve.py | 3 --- tests/tcg/multiarch/gdbstub/memory.py | 3 --- tests/tcg/multiarch/gdbstub/sha1.py | 4 ---- tests/tcg/multiarch/gdbstub/test-proc-mappings.py | 4 ---- tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py | 4 ----tests/tcg/multiarch/gdbstub/test-thread-breakpoint.py| 4 ---- tests/tcg/s390x/gdbstub/test-signals-s390x.py | 4 ---- tests/tcg/s390x/gdbstub/test-svc.py | 4 ----
Quoted 1 line
10 files changed, 2 insertions(+), 33 deletions(-)
Re: [PATCH 5/9] tests/tcg: clean-up gdb confirm/pagination settings
In reply to Alex BennéeQuoted 5 lines · Alex Bennée
We can do this all in the
run-test.pyscript so remove the extraneous bits from the individual tests which got copied from the original non-CI gdb tests.Signed-off-by Alex Bennée <[email protected]>
Quoted 12 lines
--- tests/guest-debug/run-test.py | 2 ++ tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 3 --- tests/tcg/aarch64/gdbstub/test-sve.py | 3 --- tests/tcg/multiarch/gdbstub/memory.py | 3 --- tests/tcg/multiarch/gdbstub/sha1.py | 4 ---- tests/tcg/multiarch/gdbstub/test-proc-mappings.py | 4 ---- tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py | 4 ---- tests/tcg/multiarch/gdbstub/test-thread-breakpoint.py | 4 ---- tests/tcg/s390x/gdbstub/test-signals-s390x.py | 4 ---- tests/tcg/s390x/gdbstub/test-svc.py | 4 ---- 10 files changed, 2 insertions(+), 33 deletions(-)
No change since previous version ([*]), so:
PATCH 6/9 gdbstub: fixes cases where wrong threads were reported to GDB on SIGINT
In reply to Alex BennéeFrom: Matheus Branco Borella <[email protected]>
This fix is implemented by having the vCont handler set the value of gdbserver_state.c_cpu if any threads are to be resumed. The specific CPU picked is arbitrarily from the ones to be resumed, but it should be okay, as all GDB cares about is that it is a resumed thread.
Message-Id: <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1725
---
v2
- fix up some whitespace
--- gdbstub/gdbstub.c | 29 ++++++ tests/tcg/multiarch/system/interrupt.c | 28 ++++++ tests/tcg/multiarch/gdbstub/interrupt.py | 97 +++++++++++++++++++ .../multiarch/system/Makefile.softmmu-target | 12 ++- 4 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/multiarch/system/interrupt.c create mode 100644 tests/tcg/multiarch/gdbstub/interrupt.py
gdbstub/gdbstub.c +29 -0
@@ -597,6 +597,15 @@ static int gdb_handle_vcont(const char *p)* or incorrect parameters passed. */ res =0 ; + +/* +* target_count and last_target keep track of how many CPUs we are going to +* step or resume, and a pointer to the state structure of one of them, +* respectivelly +*/ +int target_count =0 ; +CPUState *last_target =NULL ; +while (*p) {if (*p++ !=';' ) {return -ENOTSUP ;
@@ -637,6 +646,9 @@ static int gdb_handle_vcont(const char *p)while (cpu) {if (newstates[cpu->cpu_index] ==1 ) { newstates[cpu->cpu_index] = cur_action; + + target_count++; + last_target = cpu; } cpu =gdb_next_attached_cpu (cpu);
@@ -654,6 +666,9 @@ static int gdb_handle_vcont(const char *p)while (cpu) {if (newstates[cpu->cpu_index] ==1 ) { newstates[cpu->cpu_index] = cur_action; + + target_count++; + last_target = cpu; } cpu =gdb_next_cpu_in_process (cpu);
@@ -671,11 +686,25 @@ static int gdb_handle_vcont(const char *p)/* only use if no previous match occourred */ if (newstates[cpu->cpu_index] ==1 ) { newstates[cpu->cpu_index] = cur_action; + + target_count++; + last_target = cpu; }break ; } } +/* +* if we're about to resume a specific set of CPUs/threads, make it so that +* in case execution gets interrupted, we can send GDB a stop reply with a +* correct value. it doesn't really matter which CPU we tell GDB the signal +* happened in (VM pauses stop all of them anyway), so long as it is one of +* the ones we resumed/single stepped here. +*/ +if (target_count >0 ) { + gdbserver_state.c_cpu = last_target; + } + gdbserver_state.signal = signal;gdb_continue_partial (newstates);return res;
tests/tcg/multiarch/system/interrupt.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* External interruption test. This test is structured in such a way that it +* passes the cases that require it to exit, but we can make it enter an +* infinite loop from GDB. +* +* We don't have the benefit of libc, just builtin C primitives and +* whatever is in minilib. +*/ + +#include <minilib.h> + +void loop (void ) +{ +do { +/* +* Loop forever. Just make sure the condition is always a constant +* expression, so that this loop is not UB, as per the C +* standard. +*/ + }while (1 ); +} + +int main (void ) +{ +return 0 ; +} + +
tests/tcg/multiarch/gdbstub/interrupt.py new file +97 -0
97 lines not on this page · raw message
tests/tcg/multiarch/system/Makefile.softmmu-target +10 -2
@@ -27,7 +27,15 @@ run-gdbstub-memory: memory "-monitor none -display none -chardev file$(COMMA)path=$<.out$(COMMA)id=output $(QEMU_OPTS)" \ --bin $< --test $(MULTIARCH_SRC)/gdbstub/memory.py, \ softmmu gdbstub support) - +run-gdbstub-interrupt: interrupt + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) \ + --output $<.gdb.out \ + --qargs \ + "-smp 2 -monitor none -display none -chardev file$(COMMA)path=$<.out$(COMMA)id=output $(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/interrupt.py, \ + softmmu gdbstub support) run-gdbstub-untimely-packet: hello $(call run-test, $@, $(GDB_SCRIPT) \ --gdb $(HAVE_GDB_BIN) \
@@ -50,4 +58,4 @@ run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb") endif -MULTIARCH_RUNS += run-gdbstub-memory run-gdbstub-untimely-packet +MULTIARCH_RUNS += run-gdbstub-memory run-gdbstub-interrupt run-gdbstub-untimely-packet
Signature · 1 line
2.39.2
PATCH 7/9 gdbstub: remove unused user_ctx field
In reply to Alex BennéeThis was always NULL so drop it.
--- gdbstub/gdbstub.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
gdbstub/gdbstub.c +8 -8
@@ -836,7 +836,7 @@ static inline int startswith(const char *string, const char *pattern)return !strncmp (string, pattern,strlen (pattern)); } -static int process_string_cmd (void *user_ctx,const char *data, +static int process_string_cmd (const char *data,const GdbCmdParseEntry *cmds,int num_cmds) {int i;
@@ -863,7 +863,7 @@ static int process_string_cmd(void *user_ctx, const char *data, } gdbserver_state.allow_stop_reply = cmd->allow_stop_reply; - cmd->handler (params, user_ctx); + cmd->handler (params,NULL );return 0 ; }
@@ -881,7 +881,7 @@ static void run_cmd_parser(const char *data, const GdbCmdParseEntry *cmd)/* In case there was an error during the command parsing we must * send a NULL packet to indicate the command is not supported */ -if (process_string_cmd (NULL , data, cmd,1 )) { +if (process_string_cmd (data, cmd,1 )) {gdb_put_packet ("" ); } }
@@ -1394,7 +1394,7 @@ static void handle_v_commands(GArray *params, void *user_ctx)return ; } -if (process_string_cmd (NULL ,get_param (params,0 )->data, +if (process_string_cmd (get_param (params,0 )->data, gdb_v_commands_table,ARRAY_SIZE (gdb_v_commands_table))) {gdb_put_packet ("" );
@@ -1738,13 +1738,13 @@ static void handle_gen_query(GArray *params, void *user_ctx)return ; } -if (!process_string_cmd (NULL ,get_param (params,0 )->data, +if (!process_string_cmd (get_param (params,0 )->data, gdb_gen_query_set_common_table,ARRAY_SIZE (gdb_gen_query_set_common_table))) {return ; } -if (process_string_cmd (NULL ,get_param (params,0 )->data, +if (process_string_cmd (get_param (params,0 )->data, gdb_gen_query_table,ARRAY_SIZE (gdb_gen_query_table))) {gdb_put_packet ("" );
@@ -1757,13 +1757,13 @@ static void handle_gen_set(GArray *params, void *user_ctx)return ; } -if (!process_string_cmd (NULL ,get_param (params,0 )->data, +if (!process_string_cmd (get_param (params,0 )->data, gdb_gen_query_set_common_table,ARRAY_SIZE (gdb_gen_query_set_common_table))) {return ; } -if (process_string_cmd (NULL ,get_param (params,0 )->data, +if (process_string_cmd (get_param (params,0 )->data, gdb_gen_set_table,ARRAY_SIZE (gdb_gen_set_table))) {gdb_put_packet ("" );
Signature · 1 line
2.39.2
Re: [PATCH 7/9] gdbstub: remove unused user_ctx field
Quoted 6 lines · Alex Bennée
This was always NULL so drop it.
Signed-off-by Alex Bennée <[email protected]>---
gdbstub/gdbstub.c | 16 ++++++++--------1 file changed, 8 insertions(+), 8 deletions(-)
PATCH 8/9 gdbstub: refactor get_feature_xml
In reply to Alex BennéeTry to bring up the code to more modern standards by:
- use dynamic GString built xml over a fixed buffer
- use autofree to save on explicit g_free() calls
- don't hand hack strstr to find the delimiter
--- gdbstub/internals.h | 2 +- gdbstub/gdbstub.c | 62 ++++++++++++++++++++++----------------------- 2 files changed, 31 insertions(+), 33 deletions(-)
gdbstub/internals.h +1 -1
@@ -33,7 +33,7 @@ typedef struct GDBProcess {uint32_t pid;bool attached; -char target_xml[1024 ]; +char *target_xml; } GDBProcess;enum RSState {
gdbstub/gdbstub.c +30 -32
90 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH 9/9 gdbstub: replace global gdb_has_xml with a function
In reply to Alex BennéeTry and make the self reported global hack a little less hackish by providing a query function instead. As gdb_has_xml was always set if we negotiated XML we can now use the presence of ->target_xml as the test instead.
--- gdbstub/internals.h | 1 + include/exec/gdbstub.h | 10 +++++----- gdbstub/gdbstub.c | 12 +++++++----- gdbstub/softmmu.c | 1 - gdbstub/user.c | 1 - target/arm/gdbstub.c | 8 ++++---- target/ppc/gdbstub.c | 4 ++-- 7 files changed, 19 insertions(+), 18 deletions(-)
gdbstub/internals.h +1 -0
@@ -33,6 +33,7 @@ typedef struct GDBProcess {uint32_t pid;bool attached; +/* If gdb sends qXfer:features:read:target.xml this will be populated */ char *target_xml; } GDBProcess;
include/exec/gdbstub.h +5 -5
@@ -31,12 +31,12 @@ int gdbserver_start(const char *port_or_device);void gdb_set_stop_cpu (CPUState *cpu);/** -* gdb_has_xml: -* This is an ugly hack to cope with both new and old gdb. -* If gdb sends qXfer:features:read then assume we're talking to a newish -* gdb that understands target descriptions. +* gdb_has_xml() - report of gdb supports modern target descriptions +* +* This will report true if the gdb negotiated qXfer:features:read +* target descriptions. */ -extern bool gdb_has_xml; +bool gdb_has_xml (void );/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ extern const char *const xml_builtin[][2 ];
gdbstub/gdbstub.c +7 -5
@@ -75,8 +75,6 @@ void gdb_init_gdbserver_state(void) gdbserver_state.sstep_flags &= gdbserver_state.supported_sstep_flags; } -bool gdb_has_xml; -/* writes 2*len+1 bytes in buf */ void gdb_memtohex (GString *buf,const uint8_t *mem,int len) {
@@ -351,6 +349,11 @@ static CPUState *gdb_get_cpu(uint32_t pid, uint32_t tid) } } +bool gdb_has_xml (void ) +{ +return !!gdb_get_cpu_process (gdbserver_state.g_cpu)->target_xml; +} +static const char *get_feature_xml (const char *p,const char **newp,GDBProcess *process) {
@@ -1079,7 +1082,7 @@ static void handle_set_reg(GArray *params, void *user_ctx) {int reg_size; -if (!gdb_has_xml) { +if (!gdb_get_cpu_process (gdbserver_state.g_cpu)->target_xml) {gdb_put_packet ("" );return ; }
@@ -1100,7 +1103,7 @@ static void handle_get_reg(GArray *params, void *user_ctx) {int reg_size; -if (!gdb_has_xml) { +if (!gdb_get_cpu_process (gdbserver_state.g_cpu)->target_xml) {gdb_put_packet ("" );return ; }
@@ -1567,7 +1570,6 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx)return ; } - gdb_has_xml = true; p =get_param (params,0 )->data; xml =get_feature_xml (p, &p, process);if (!xml) {
gdbstub/softmmu.c +0 -1
@@ -97,7 +97,6 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event)vm_stop (RUN_STATE_PAUSED );replay_gdb_attached (); - gdb_has_xml = false;break ;default :break ;
gdbstub/user.c +0 -1
@@ -198,7 +198,6 @@ static void gdb_accept_init(int fd) gdbserver_state.c_cpu =gdb_first_attached_cpu (); gdbserver_state.g_cpu = gdbserver_state.c_cpu; gdbserver_user_state.fd = fd; - gdb_has_xml = false; }static bool gdb_accept_socket (int gdb_fd)
target/arm/gdbstub.c +4 -4
@@ -48,7 +48,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) }if (n <24 ) {/* FPA registers. */ -if (gdb_has_xml) { +if (gdb_has_xml ()) {return 0 ; }return gdb_get_zeroes (mem_buf,12 );
@@ -56,7 +56,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)switch (n) {case 24 :/* FPA status register. */ -if (gdb_has_xml) { +if (gdb_has_xml ()) {return 0 ; }return gdb_get_reg32 (mem_buf,0 );
@@ -102,7 +102,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) }if (n <24 ) {/* 16-23 */ /* FPA registers (ignored). */ -if (gdb_has_xml) { +if (gdb_has_xml ()) {return 0 ; }return 12 ;
@@ -110,7 +110,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)switch (n) {case 24 :/* FPA status register (ignored). */ -if (gdb_has_xml) { +if (gdb_has_xml ()) {return 0 ; }return 4 ;
target/ppc/gdbstub.c +2 -2
@@ -56,7 +56,7 @@ static int ppc_gdb_register_len(int n)return sizeof (target_ulong); case 32 ... 63:/* fprs */ -if (gdb_has_xml) { +if (gdb_has_xml ()) {return 0 ; }return 8 ;
@@ -76,7 +76,7 @@ static int ppc_gdb_register_len(int n)return sizeof (target_ulong);case 70 :/* fpscr */ -if (gdb_has_xml) { +if (gdb_has_xml ()) {return 0 ; }return sizeof (target_ulong);
Signature · 1 line
2.39.2