4 changes: 2 additions & 2 deletions target/ppc/gdbstub.c
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions tests/docker/Makefile.include
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion tests/docker/dockerfiles/debian-hexagon-cross.docker
Expand Up @@ -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 \
Expand All @@ -27,14 +28,20 @@ RUN apt-get update && \
python3-wheel && \
# 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

RUN /usr/bin/pip3 install tomli

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
Expand Down
2 changes: 2 additions & 0 deletions tests/guest-debug/run-test.py
Expand Up @@ -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
Expand Down
177 changes: 0 additions & 177 deletions tests/guest-debug/test-gdbstub.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/tcg/aarch64/Makefile.target
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions tests/tcg/aarch64/gdbstub/test-sve-ioctl.py
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions tests/tcg/aarch64/gdbstub/test-sve.py
Expand Up @@ -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:
Expand Down
97 changes: 97 additions & 0 deletions tests/tcg/multiarch/gdbstub/interrupt.py
@@ -0,0 +1,97 @@
from __future__ import print_function
#
# Test some of the softmmu debug features with the multiarch memory
# test. It is a port of the original vmlinux focused test case but
# using the "memory" test instead.
#
# This is launched via tests/guest-debug/run-test.py
#

import gdb
import sys

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_interrupt(thread):
"""
Check that, if thread is resumed, we go back to the same thread when the
program gets interrupted.
"""

# Switch to the thread we're going to be running the test in.
print("thread ", thread.num)
gdb.execute("thr %d" % thread.num)

# Enter the loop() function on this thread.
#
# While there are cleaner ways to do this, we want to minimize the number of
# side effects on the gdbstub's internal state, since those may mask bugs.
# Ideally, there should be no difference between what we're doing here and
# the program reaching the loop() function on its own.
#
# For this to be safe, we only need the prologue of loop() to not have
# instructions that may have problems with what we're doing here. We don't
# have to worry about anything else, as this function never returns.
gdb.execute("set $pc = loop")

# Continue and then interrupt the task.
gdb.post_event(lambda: gdb.execute("interrupt"))
gdb.execute("c")

# Check whether the thread we're in after the interruption is the same we
# ran continue from.
return (thread.num == gdb.selected_thread().num)


def run_test():
"""
Test if interrupting the code always lands us on the same thread when
running with scheduler-lock enabled.
"""

gdb.execute("set scheduler-locking on")
for thread in gdb.selected_inferior().threads():
report(check_interrupt(thread),
"thread %d resumes correctly on interrupt" % thread.num)


#
# This runs as the script it sourced (via -x, via run-test.py)
#
try:
inferior = gdb.selected_inferior()
arch = inferior.architecture()
print("ATTACHED: %s" % arch.name())
except (gdb.error, AttributeError):
print("SKIPPING (not connected)", file=sys.stderr)
exit(0)

if gdb.parse_and_eval('$pc') == 0:
print("SKIP: PC not set")
exit(0)
if len(gdb.selected_inferior().threads()) == 1:
print("SKIP: set to run on a single thread")
exit(0)

try:
# Run the actual tests
run_test()
except (gdb.error):
print("GDB Exception: %s" % (sys.exc_info()[0]))
failcount += 1
pass

# Finally kill the inferior and exit gdb with a count of failures
gdb.execute("kill")
exit(failcount)
3 changes: 0 additions & 3 deletions tests/tcg/multiarch/gdbstub/memory.py
Expand Up @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions tests/tcg/multiarch/gdbstub/sha1.py
Expand Up @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions tests/tcg/multiarch/gdbstub/test-proc-mappings.py
Expand Up @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py
Expand Up @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions tests/tcg/multiarch/gdbstub/test-thread-breakpoint.py
Expand Up @@ -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):
Expand Down
16 changes: 12 additions & 4 deletions tests/tcg/multiarch/system/Makefile.softmmu-target
Expand Up @@ -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) \
Expand All @@ -37,10 +45,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")
Expand All @@ -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
28 changes: 28 additions & 0 deletions tests/tcg/multiarch/system/interrupt.c
@@ -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;
}


4 changes: 0 additions & 4 deletions tests/tcg/s390x/gdbstub/test-signals-s390x.py
Expand Up @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions tests/tcg/s390x/gdbstub/test-svc.py
Expand Up @@ -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:
Expand Down