From patchwork Tue Feb 21 22:52:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 655398 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp374822wrb; Tue, 21 Feb 2023 15:04:33 -0800 (PST) X-Google-Smtp-Source: AK7set+mQQF2ZaxNdeS3hzzaaoNqaeSLjtyRpsA/IsFmf46o14p5NNXbiTD0lxl5IktVhez2VXjw X-Received: by 2002:ac8:5c86:0:b0:3b8:6763:c25f with SMTP id r6-20020ac85c86000000b003b86763c25fmr25534618qta.13.1677020673141; Tue, 21 Feb 2023 15:04:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677020673; cv=none; d=google.com; s=arc-20160816; b=b7UWkL4anPYQaD77DqhaELCR2+nfLknrIEm8Q4zh/HX9LT0cFPjUxgrnPITtdElxNP ie7Q9iQRVFJuHJ8pG1dCwPM7H/LdRciXW/pMlkf8BGDCNZ2FuShgyMNqi5EXvyxNSHiu VjhuqVuacq/keU9s3IVAIMdPkg7AQgA2JvGkAtB2xk5VN4hJlVWLzHgVAJNZz0WUMw0X SBkWQAvK/QD7FCKl2qhkgHF6KjcILo8LZjWcj2UMrvDdJWSRjBgcZ1GOVLF0kiBQPlPC igYj98fXyhVHUbdSbORcbiyz50XX3moysyUgbiDAmPdM8tI/tJ6ekxkrK1Nqa8tPPRNN j+rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/FUKHXeuCXtBvDsk59GkfkYB8FHTK4Rxul90aEXOMFE=; b=psIJj2Yyak5+pIz3+OMvA0ksh5PWtatkiqoIpE+kMMr2u55SKqj/bb7BlQvPH0JTAQ uWM0atm30y7WbKlaD/wOEterLTHnAjvgXTiGaXHmqeEF7EOKfDq+1jFWJIJKM20/a/rD kaMVNfNXEeJmQ/6rDLdX32+ApJfWGXq157GCEnQl0nQypNngAz9dMQkHDuvYYVJdC/4p dIdkRzK82YaT1GZlD+dLMSkoYTOK8cqTPntnYepGq7ZKmZyFc5trqqzK8AjZIvcBi2zI UDbwJ0EnbCM/lerfz7LuSQ3Bho/GMJgnC3wM4g2X6apgu4FOkEVJ0Dcf0ZWh9BwdrLPB VC3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c5mY9RWt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f13-20020ac859cd000000b003b83c0ba5cfsi12698812qtf.543.2023.02.21.15.04.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Feb 2023 15:04:33 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c5mY9RWt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUbeT-0006dD-VR; Tue, 21 Feb 2023 18:02:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUbeB-0006OH-5u for qemu-devel@nongnu.org; Tue, 21 Feb 2023 18:02:10 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUbe3-0006D6-6o for qemu-devel@nongnu.org; Tue, 21 Feb 2023 18:02:05 -0500 Received: by mail-wm1-x331.google.com with SMTP id m14-20020a7bce0e000000b003e00c739ce4so4075906wmc.5 for ; Tue, 21 Feb 2023 15:01:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/FUKHXeuCXtBvDsk59GkfkYB8FHTK4Rxul90aEXOMFE=; b=c5mY9RWteBVGgF/LR9Bx0irYGWPV65PUX0nkgGhfFkQB9KiueE1F0g4qtky7Ohh9Ix M9fDd6r0jZzS5IWTGTEOlgKhh4br8KPjnhWvHg2DhF7j7N1vgtAMJS3Mm1VQZxsgfdZp /TiMSe0f9VAaM+zr2QfL292UZsJRiWcA9zkAjPfzGHyz/Zttn+JQ6SvLqDtrlRGgCcRe pudI9j4gup9eLFvspGX5tBOrli09aILLhM1GK2zgnmQv0tlhFtS+BkmrDGQp4flikrLF g9z3XFwNRfY04vCWPFSJI6Uvpn8Eek3SkV1MzMk9kwoIVIVv44gk9PT0aDn5Sq7dVKMB bOow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/FUKHXeuCXtBvDsk59GkfkYB8FHTK4Rxul90aEXOMFE=; b=phzjxk6zYRoD/J/BCcTUT4fQZrieQ9gH23x9MADbP4CTLQ3h9bso+uY4oB5OH4Z5qc NlmbRZbnKdj1yBBWXC5G07/QOEcuMzU4czUxlSHiZ2C/uYvrt/c30ZfpPZa02wF62+gd gjLBrArVAZW8+vHNmZTefkEpHHqT63/PfjpC9hiFjItR0vmOB5wLwpuUnh1zFaoHAz5u H4kXxe2kbNsABcHtmzBwxQnyEl3a9oLIC2vvOhWEYeW4YYXg5vxM7hKu6i6LUzuuwEIj 6HNujhfT0Ck4hftxxzT7pCObAQiBxnzSnbjjcVlPbtLNBqvooMuGX8jn9RN6Ixe/9lHk Ptig== X-Gm-Message-State: AO0yUKUogYK9HI2Q5Hz8MzcR5p+Ep8SWSOPpezJwEBDkvkF6hcUj6302 H2zXkp8BTkE65g9lAlTr3y4gYQ== X-Received: by 2002:a05:600c:995:b0:3d6:ecc4:6279 with SMTP id w21-20020a05600c099500b003d6ecc46279mr4259460wmp.27.1677020516890; Tue, 21 Feb 2023 15:01:56 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r26-20020a05600c2f1a00b003db0bb81b6asm5207691wmn.1.2023.02.21.15.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 15:01:56 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1E90E1FFCF; Tue, 21 Feb 2023 22:52:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Yoshinori Sato , nicolas.eder@lauterbach.com, Stafford Horne , Daniel Henrique Barboza , Mahmoud Mandour , Taylor Simpson , mads@ynddal.dk, Marek Vasut , Artyom Tarasenko , Alistair Francis , qemu-ppc@nongnu.org, Yanan Wang , Sunil Muthuswamy , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eduardo Habkost , Bin Meng , Bastian Koppelmann , Palmer Dabbelt , Marcel Apfelbaum , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Rolnik , Aleksandar Rikalo , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Xiaojuan Yang , Richard Henderson , Peter Maydell , Alexandre Iooss , Chris Wulff , Jiaxun Yang , David Gibson , "Edgar E. Iglesias" , Greg Kurz , David Hildenbrand , Song Gao , Ilya Leoshkevich , Max Filippov , Mark Cave-Ayland Subject: [PATCH v3 22/24] testing: probe gdb for supported architectures ahead of time Date: Tue, 21 Feb 2023 22:52:25 +0000 Message-Id: <20230221225227.3735319-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221225227.3735319-1-alex.bennee@linaro.org> References: <20230221225227.3735319-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Currently when we encounter a gdb that is old or not built with multiarch in mind we fail rather messily. Try and improve the situation by probing ahead of time and setting HOST_GDB_SUPPORTS_ARCH=y in the relevant tcg configs. We can then skip and give a more meaningful message if we don't run the test. [AJB: we still miss some arches, for example gdb uses s390 which fails when we look for s390x. Not sure what the best way to deal with that is? Maybe define a gdb_arch as we probe each target?] Signed-off-by: Alex Bennée Cc: Richard Henderson Cc: Paolo Bonzini --- configure | 8 +++++ scripts/probe-gdb-support.sh | 36 +++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 2 +- tests/tcg/multiarch/Makefile.target | 5 +++ .../multiarch/system/Makefile.softmmu-target | 6 +++- tests/tcg/s390x/Makefile.target | 2 +- 6 files changed, 56 insertions(+), 3 deletions(-) create mode 100755 scripts/probe-gdb-support.sh diff --git a/configure b/configure index cf6db3d551..366a1d8dd2 100755 --- a/configure +++ b/configure @@ -226,6 +226,7 @@ stack_protector="" safe_stack="" use_containers="yes" gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") +gdb_arches="" if test -e "$source_path/.git" then @@ -2344,6 +2345,7 @@ if test -n "$gdb_bin"; then gdb_version=$($gdb_bin --version | head -n 1) if version_ge ${gdb_version##* } 9.1; then echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak + gdb_arches=$("$source_path/scripts/probe-gdb-support.sh" $gdb_bin) else gdb_bin="" fi @@ -2467,6 +2469,12 @@ for target in $target_list; do write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak" echo "BUILD_STATIC=$build_static" >> "$config_target_mak" echo "QEMU=$PWD/$qemu" >> "$config_target_mak" + + # will GDB work with these binaries? + if test "${gdb_arches#*$arch}" != "$gdb_arches"; then + echo "HOST_GDB_SUPPORTS_ARCH=y" >> "$config_target_mak" + fi + echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs tcg_tests_targets="$tcg_tests_targets $target" fi diff --git a/scripts/probe-gdb-support.sh b/scripts/probe-gdb-support.sh new file mode 100755 index 0000000000..2b09a00a5b --- /dev/null +++ b/scripts/probe-gdb-support.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +# Probe gdb for supported architectures. +# +# This is required to support testing of the gdbstub as its hard to +# handle errors gracefully during the test. Instead this script when +# passed a GDB binary will probe its architecture support and return a +# string of supported arches, stripped of guff. +# +# Copyright 2023 Linaro Ltd +# +# Author: Alex Bennée +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +if test -z "$1"; then + echo "Usage: $0 /path/to/gdb" + exit 1 +fi + +# Start gdb with a set-architecture and capture the set of valid +# options. + +valid_args=$($1 -ex "set architecture" -ex "quit" 2>&1 >/dev/null) + +# Strip off the preamble +raw_arches=$(echo "${valid_args}" | sed "s/.*Valid arguments are \(.*\)/\1/") + +# Split into lines, strip everything after :foo and return final +# "clean" list of supported arches. +final_arches=$(echo "${raw_arches}" | tr ', ' '\n' | sed "s/:.*//" | sort | uniq) + +echo "$final_arches" diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index db122ab4ff..9e91a20b0d 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -81,7 +81,7 @@ sha512-vector: sha512.c TESTS += sha512-vector -ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py run-gdbstub-sysregs: sysregs diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index ae8b3d7268..373db69648 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -64,6 +64,7 @@ run-test-mmap-%: test-mmap $(call run-test, test-mmap-$*, $(QEMU) -p $* $<, $< ($* byte pages)) ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py run-gdbstub-sha1: sha1 @@ -87,6 +88,10 @@ run-gdbstub-thread-breakpoint: testthread --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-thread-breakpoint.py, \ hitting a breakpoint on non-main thread) +else +run-gdbstub-%: + $(call skip-test, "gdbstub test $*", "no guest arch support") +endif else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb") diff --git a/tests/tcg/multiarch/system/Makefile.softmmu-target b/tests/tcg/multiarch/system/Makefile.softmmu-target index 368b64d531..5f432c95f3 100644 --- a/tests/tcg/multiarch/system/Makefile.softmmu-target +++ b/tests/tcg/multiarch/system/Makefile.softmmu-target @@ -15,6 +15,7 @@ MULTIARCH_TEST_SRCS=$(wildcard $(MULTIARCH_SYSTEM_SRC)/*.c) MULTIARCH_TESTS = $(patsubst $(MULTIARCH_SYSTEM_SRC)/%.c, %, $(MULTIARCH_TEST_SRCS)) ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py run-gdbstub-memory: memory @@ -26,7 +27,10 @@ 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) - +else +run-gdbstub-%: + $(call skip-test, "gdbstub test $*", "no guest arch support") +endif else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb") diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target index 72ad309b27..b7f576f983 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -51,7 +51,7 @@ $(Z15_TESTS): CFLAGS+=-march=z15 -O2 TESTS+=$(Z15_TESTS) endif -ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py run-gdbstub-signals-s390x: signals-s390x