Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/stsquad/tags/pull-6.0-rc2-fixes…
Browse files Browse the repository at this point in the history
…-060421-1' into staging

Testing updates:

  - fix x86_64 cross compilers
  - don't use registry for non-x86 containers
  - add valid host types for given cross compile containers
  - clean up i386 code16 test with explicit -no-pie
  - relax sha1.py gdbstub test
  - add more gdbstub documentation
  - remove annoying warning on gitlab
  - test dtrace backend in gitlab

# gpg: Signature made Tue 06 Apr 2021 15:55:53 BST
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-6.0-rc2-fixes-060421-1:
  gitlab-ci.yml: Test the dtrace backend in one of the jobs
  gitlab-ci.yml: Fix the filtering for the git submodules
  docs/system/gdb.rst: Document how to debug multicore machines
  docs/system/gdb.rst: Add some more heading structure
  tests/tcg: relax the next step precision of the gdb sha1 test
  tests/tcg/i386: force -fno-pie for test-i386
  tests/tcg/i386: expand .data sections for system tests
  tests/tcg/configure.sh: make sure we pick up x86_64 cross compilers
  tests/tcg: add concept of container_hosts
  tests/docker: don't set DOCKER_REGISTRY on non-x86_64
  tests/tcg: update the defaults for x86 compilers

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Apr 6, 2021
2 parents 4216ba1 + a2e5bbf commit d5be106
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Expand Up @@ -42,7 +42,7 @@ include:
image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:latest
script:
- scripts/git-submodule.sh update
$(grep GIT_SUBMODULES build/config-host.mak | sed 's/GIT_SUBMODULES=//')
$(sed -n '/GIT_SUBMODULES=/ s/.*=// p' build/config-host.mak)
- cd build
- find . -type f -exec touch {} +
# Avoid recompiling by hiding ninja with NINJA=":"
Expand Down Expand Up @@ -223,7 +223,7 @@ build-system-centos:
variables:
IMAGE: centos8
CONFIGURE_ARGS: --disable-nettle --enable-gcrypt --enable-fdt=system
--enable-modules
--enable-modules --enable-trace-backends=dtrace
TARGETS: ppc64-softmmu or1k-softmmu s390x-softmmu
x86_64-softmmu rx-softmmu sh4-softmmu nios2-softmmu
MAKE_CHECK_ARGS: check-build
Expand Down
2 changes: 1 addition & 1 deletion configure
Expand Up @@ -6299,7 +6299,7 @@ done
(for i in $cross_cc_vars; do
export $i
done
export target_list source_path use_containers
export target_list source_path use_containers ARCH
$source_path/tests/tcg/configure.sh)

# temporary config to build submodules
Expand Down
63 changes: 62 additions & 1 deletion docs/system/gdb.rst
Expand Up @@ -45,7 +45,66 @@ Here are some useful tips in order to use gdb on system code:
3. Use ``set architecture i8086`` to dump 16 bit code. Then use
``x/10i $cs*16+$eip`` to dump the code at the PC position.

Advanced debugging options:
Debugging multicore machines
============================

GDB's abstraction for debugging targets with multiple possible
parallel flows of execution is a two layer one: it supports multiple
"inferiors", each of which can have multiple "threads". When the QEMU
machine has more than one CPU, QEMU exposes each CPU cluster as a
separate "inferior", where each CPU within the cluster is a separate
"thread". Most QEMU machine types have identical CPUs, so there is a
single cluster which has all the CPUs in it. A few machine types are
heterogenous and have multiple clusters: for example the ``sifive_u``
machine has a cluster with one E51 core and a second cluster with four
U54 cores. Here the E51 is the only thread in the first inferior, and
the U54 cores are all threads in the second inferior.

When you connect gdb to the gdbstub, it will automatically
connect to the first inferior; you can display the CPUs in this
cluster using the gdb ``info thread`` command, and switch between
them using gdb's usual thread-management commands.

For multi-cluster machines, unfortunately gdb does not by default
handle multiple inferiors, and so you have to explicitly connect
to them. First, you must connect with the ``extended-remote``
protocol, not ``remote``::

(gdb) target extended-remote localhost:1234

Once connected, gdb will have a single inferior, for the
first cluster. You need to create inferiors for the other
clusters and attach to them, like this::

(gdb) add-inferior
Added inferior 2
(gdb) inferior 2
[Switching to inferior 2 [<null>] (<noexec>)]
(gdb) attach 2
Attaching to process 2
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x00000000 in ?? ()

Once you've done this, ``info threads`` will show CPUs in
all the clusters you have attached to::

(gdb) info threads
Id Target Id Frame
1.1 Thread 1.1 (cortex-m33-arm-cpu cpu [running]) 0x00000000 in ?? ()
* 2.1 Thread 2.2 (cortex-m33-arm-cpu cpu [halted ]) 0x00000000 in ?? ()

You probably also want to set gdb to ``schedule-multiple`` mode,
so that when you tell gdb to ``continue`` it resumes all CPUs,
not just those in the cluster you are currently working on::

(gdb) set schedule-multiple on

Advanced debugging options
==========================

Changing single-stepping behaviour
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The default single stepping behavior is step with the IRQs and timer
service routines off. It is set this way because when gdb executes a
Expand Down Expand Up @@ -88,6 +147,8 @@ three commands you can query and set the single step behavior:
sending: "qemu.sstep=0x5"
received: "OK"

Examining physical memory
^^^^^^^^^^^^^^^^^^^^^^^^^

Another feature that QEMU gdbstub provides is to toggle the memory GDB
works with, by default GDB will show the current process memory respecting
Expand Down
5 changes: 4 additions & 1 deletion tests/docker/Makefile.include
Expand Up @@ -16,7 +16,10 @@ DOCKER_IMAGES := $(sort $(notdir $(basename $(wildcard $(DOCKER_FILES_DIR)/*.doc
DOCKER_TARGETS := $(patsubst %,docker-image-%,$(DOCKER_IMAGES))
# Use a global constant ccache directory to speed up repetitive builds
DOCKER_CCACHE_DIR := $$HOME/.cache/qemu-docker-ccache
DOCKER_REGISTRY := $(if $(REGISTRY),$(REGISTRY),registry.gitlab.com/qemu-project/qemu)
ifeq ($(HOST_ARCH),x86_64)
DOCKER_DEFAULT_REGISTRY := registry.gitlab.com/qemu-project/qemu
endif
DOCKER_REGISTRY := $(if $(REGISTRY),$(REGISTRY),$(DOCKER_DEFAULT_REGISTRY))

DOCKER_TESTS := $(notdir $(shell \
find $(SRC_PATH)/tests/docker/ -name 'test-*' -type f))
Expand Down
1 change: 1 addition & 0 deletions tests/docker/dockerfiles/centos8.docker
Expand Up @@ -29,6 +29,7 @@ ENV PACKAGES \
rdma-core-devel \
spice-glib-devel \
spice-server \
systemtap-sdt-devel \
tar \
zlib-devel

Expand Down
42 changes: 38 additions & 4 deletions tests/tcg/configure.sh
Expand Up @@ -52,7 +52,7 @@ fi
: ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
: ${cross_cc_cflags_hexagon="-mv67 -O2 -static"}
: ${cross_cc_hppa="hppa-linux-gnu-gcc"}
: ${cross_cc_i386="i386-pc-linux-gnu-gcc"}
: ${cross_cc_i386="i686-linux-gnu-gcc"}
: ${cross_cc_cflags_i386="-m32"}
: ${cross_cc_m68k="m68k-linux-gnu-gcc"}
: $(cross_cc_mips64el="mips64el-linux-gnuabi64-gcc")
Expand All @@ -69,7 +69,7 @@ fi
: ${cross_cc_cflags_sparc="-m32 -mv8plus -mcpu=ultrasparc"}
: ${cross_cc_sparc64="sparc64-linux-gnu-gcc"}
: ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
: ${cross_cc_x86_64="x86_64-pc-linux-gnu-gcc"}
: ${cross_cc_x86_64="x86_64-linux-gnu-gcc"}
: ${cross_cc_cflags_x86_64="-m64"}

for target in $target_list; do
Expand Down Expand Up @@ -108,79 +108,103 @@ for target in $target_list; do
case $target in
aarch64-*)
# We don't have any bigendian build tools so we only use this for AArch64
container_hosts="x86_64 aarch64"
container_image=debian-arm64-test-cross
container_cross_cc=aarch64-linux-gnu-gcc-10
;;
alpha-*)
container_hosts=x86_64
container_image=debian-alpha-cross
container_cross_cc=alpha-linux-gnu-gcc
;;
arm-*)
# We don't have any bigendian build tools so we only use this for ARM
container_hosts="x86_64 aarch64"
container_image=debian-armhf-cross
container_cross_cc=arm-linux-gnueabihf-gcc
;;
cris-*)
container_hosts=x86_64
container_image=fedora-cris-cross
container_cross_cc=cris-linux-gnu-gcc
;;
hppa-*)
container_hosts=x86_64
container_image=debian-hppa-cross
container_cross_cc=hppa-linux-gnu-gcc
;;
i386-*)
container_hosts=x86_64
container_image=fedora-i386-cross
container_cross_cc=gcc
;;
m68k-*)
container_hosts=x86_64
container_image=debian-m68k-cross
container_cross_cc=m68k-linux-gnu-gcc
;;
mips64el-*)
container_hosts=x86_64
container_image=debian-mips64el-cross
container_cross_cc=mips64el-linux-gnuabi64-gcc
;;
mips64-*)
container_hosts=x86_64
container_image=debian-mips64-cross
container_cross_cc=mips64-linux-gnuabi64-gcc
;;
mipsel-*)
container_hosts=x86_64
container_image=debian-mipsel-cross
container_cross_cc=mipsel-linux-gnu-gcc
;;
mips-*)
container_hosts=x86_64
container_image=debian-mips-cross
container_cross_cc=mips-linux-gnu-gcc
;;
ppc-*|ppc64abi32-*)
container_hosts=x86_64
container_image=debian-powerpc-cross
container_cross_cc=powerpc-linux-gnu-gcc
;;
ppc64-*)
container_hosts=x86_64
container_image=debian-ppc64-cross
container_cross_cc=powerpc64-linux-gnu-gcc
;;
ppc64le-*)
container_hosts=x86_64
container_image=debian-ppc64el-cross
container_cross_cc=powerpc64le-linux-gnu-gcc
;;
riscv64-*)
container_hosts=x86_64
container_image=debian-riscv64-cross
container_cross_cc=riscv64-linux-gnu-gcc
;;
s390x-*)
container_hosts=x86_64
container_image=debian-s390x-cross
container_cross_cc=s390x-linux-gnu-gcc
;;
sh4-*)
container_hosts=x86_64
container_image=debian-sh4-cross
container_cross_cc=sh4-linux-gnu-gcc
;;
sparc64-*)
container_hosts=x86_64
container_image=debian-sparc64-cross
container_cross_cc=sparc64-linux-gnu-gcc
;;
x86_64-*)
container_hosts="aarch64 ppc64el x86_64"
container_image=debian-amd64-cross
container_cross_cc=x86_64-linux-gnu-gcc
;;
xtensa*-softmmu)
container_hosts=x86_64
container_image=debian-xtensa-cross

# default to the dc232b cpu
Expand Down Expand Up @@ -257,6 +281,12 @@ for target in $target_list; do
echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> $config_target_mak
fi
;;
i386-linux-user)
if do_compiler "$target_compiler" $target_compiler_cflags \
-Werror -fno-pie -o $TMPE $TMPC; then
echo "CROSS_CC_HAS_I386_NOPIE=y" >> $config_target_mak
fi
;;
esac

enabled_cross_compilers="$enabled_cross_compilers $target_compiler"
Expand All @@ -265,7 +295,11 @@ for target in $target_list; do
done

if test $got_cross_cc = no && test "$container" != no && test -n "$container_image"; then
echo "DOCKER_IMAGE=$container_image" >> $config_target_mak
echo "DOCKER_CROSS_CC_GUEST=$container_cross_cc" >> $config_target_mak
for host in $container_hosts; do
if test "$host" = "$ARCH"; then
echo "DOCKER_IMAGE=$container_image" >> $config_target_mak
echo "DOCKER_CROSS_CC_GUEST=$container_cross_cc" >> $config_target_mak
fi
done
fi
done
16 changes: 13 additions & 3 deletions tests/tcg/i386/Makefile.target
Expand Up @@ -27,13 +27,23 @@ run-plugin-test-i386-bmi2-%: QEMU_OPTS += -cpu max
hello-i386: CFLAGS+=-ffreestanding
hello-i386: LDFLAGS+=-nostdlib

#
# test-386 includes a couple of additional objects that need to be linked together
#
# test-386 includes a couple of additional objects that need to be
# linked together, we also need a no-pie capable compiler due to the
# non-pic calls into 16-bit mode
ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_I386_NOPIE),)
test-i386: CFLAGS += -fno-pie

test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S test-i386.h test-i386-shift.h test-i386-muldiv.h
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_CFLAGS) -o $@ \
$(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
else
test-i386:
$(call skip-test, "BUILD of $@", "missing -no-pie compiler support")
run-test-i386:
$(call skip-test, "RUN of test-i386", "not built")
run-plugin-test-i386-with-%:
$(call skip-test, "RUN of test-i386 ($*)", "not built")
endif

ifeq ($(SPEED), slow)

Expand Down
2 changes: 1 addition & 1 deletion tests/tcg/i386/system/kernel.ld
Expand Up @@ -12,7 +12,7 @@ SECTIONS {
}

.data : {
*(.data)
*(.data*)
__load_en = .;
}

Expand Down
5 changes: 4 additions & 1 deletion tests/tcg/multiarch/gdbstub/sha1.py
Expand Up @@ -40,7 +40,10 @@ def run_test():

check_break("SHA1Init")

# check step and inspect values
# Check step and inspect values. We do a double next after the
# breakpoint as depending on the version of gdb we may step the
# preamble and not the first actual line of source.
gdb.execute("next")
gdb.execute("next")
val_ctx = gdb.parse_and_eval("context->state[0]")
exp_ctx = 0x67452301
Expand Down

0 comments on commit d5be106

Please sign in to comment.