From patchwork Sun Mar 3 19:26:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 777648 Delivered-To: patch@linaro.org Received: by 2002:a5d:4b84:0:b0:33d:f458:43ce with SMTP id b4csp222963wrt; Sun, 3 Mar 2024 11:27:13 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU1WMzZYFGijD58krUm9OLR7FR34wZrQmsDhr8Pk5Dgo4+KyXvPlazBxKiNdOZrdwu5NdFJ055cMhkYkumoh3Iw X-Google-Smtp-Source: AGHT+IGUpcD3QsXgLunjf4XkWDxQ3JZwHjcDi++XNFmJ71nIQKBV328VJEtczTg3zFHVxKJbY2NL X-Received: by 2002:a05:620a:468f:b0:788:15e2:8f13 with SMTP id bq15-20020a05620a468f00b0078815e28f13mr10260265qkb.13.1709494033447; Sun, 03 Mar 2024 11:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709494033; cv=none; d=google.com; s=arc-20160816; b=V9bTqzKhXwWQx1W0HvxrRXvYhZRNmzsZBGgzIL17JV7vEMw9/j8g3T74NjNrbYHD7y 4GBejZ2K5DiQv2oShFtZEK2eAisqPSVt53jgw25CyDnQytzr1sCHGKNT2I8wsIQ3G9OT gLas3n9SffQZoJtEHLhnm9JVFp7Ji/hjyEIRc7FcCjPwGiI3nLxZ62CN5O5u3YB/crD+ 7Y3gmYFHfKiFcOolg1lxDZHcjGF1pk91LRlmXV5DrKt/0OHqYDjlVZu5CnCLXty+wvWW NQJfP+k584UeA1uIWWqRfzpO6ujNW9ii3YbmrIf4OPon1oLLylYb3GB/FHNBvHgOVMV+ 5ZEQ== 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=W9FD8yKg80ZqH9APzxpqcFIl19t8UD0rlYBITybI9/w=; fh=kLvOV699bJQJ1aB4dJ9+Hf3L1BkcJSedSEwod57mP/g=; b=D/Yc4KQ7goQeVott3o2lnrfCtPRRP2ZAPMqbnXfE6u8yPeLBGrSHtmzKJZX9kSd1cD uGt+Yxx+xz7M3NWn7Yy4Gk9GhIgRpA+7PK91yDHBwk4VbtErlh/89LJ83LLQZcG9UrUn 5IGiqUmTP4lmMZrsFx/RhNQiWAFw61/HOe8ROLjBFLv52ph5uVG/h7tPP33SmB7xAZwm l2l3/bq8chQCgn9JXh373B5NnEnZ0g10v4QiCLjspFOqnh2YyhQP+2bivCVWbnreDvpI x9AHtGOrYJHzyhLpaeiRDVC4vUd5FNT7lraIUGbss2gyz2vWRIE7nt90CtN+XuUQa6K0 OPcA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a1RVfc29; 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 l9-20020a05620a28c900b00788275f9a1dsi840988qkp.538.2024.03.03.11.27.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Mar 2024 11:27:13 -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=a1RVfc29; 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 1rgrTv-00048f-Ps; Sun, 03 Mar 2024 14:26:43 -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 1rgrTu-00048A-1E for qemu-devel@nongnu.org; Sun, 03 Mar 2024 14:26:42 -0500 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgrTs-00031W-8f for qemu-devel@nongnu.org; Sun, 03 Mar 2024 14:26:41 -0500 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6e5a232fe80so2171734b3a.0 for ; Sun, 03 Mar 2024 11:26:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709493994; x=1710098794; darn=nongnu.org; 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=W9FD8yKg80ZqH9APzxpqcFIl19t8UD0rlYBITybI9/w=; b=a1RVfc29y8Ki5y9pAr4mRCZl93gSG3d7LIiZM0mQCXX2M4g1yTmu7/LQ98iI3GDo5G QhiPzwqbZZym6Hd2fk/KonV38x2LgPcsOi9xPcgd5CsjShH/vFW+fjZ7bNcp6saIOzej T2OShpp+KdEsYWsf2BFrFMNAPDKsAg2emsKXfeeOYuKN20ijMTZF1mbzt+aS2I/KAp+M RJ0n2ohqa96VNPDZ/UKWB0KiFXKLGf1GfQV9ZqjgUAZslB2p4z3jsYAXsAmB9RjuBdLP XpFHXCv7fn+JBgvIX/Gc45t6kGxgVocvLIg5c0FQph08Oj7b0ArcUDLC1ym7OlzskZBA wLsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709493994; x=1710098794; 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=W9FD8yKg80ZqH9APzxpqcFIl19t8UD0rlYBITybI9/w=; b=uqR1IsiIEt6mYqL600CnnAybQIXAf0ZroPXkm0Rfrby7KaGAMHgqJe322O0bWaZps1 wyZxU9H6ZhenSRkEBof7RVzN0fYQ+sqQSeJRn1rO76MQq7FAktPzw2faT5G/9KLhA3pE rtW/oxwaZgJ9xPPIXcujuPDnfH9jGo8K8QS7fUi8MoSl73tGWtyAzJzdo/TMd2IUpKMk pAz4XmNPLMROc8EmMuqVQ2pdrMuebTxx8qKy443on1EVTJc/5PCw0m91SDYT+dp/t24j oTduLUPyl8jZZyeSxxAnCP/sGykENSs9rRFHZLSDoYIJo/T50THoKozAAeoYnEEnlBqp wAvw== X-Gm-Message-State: AOJu0Yz/5rkmA4dPvPKvXzwRIGahfNThuqNH7j+dEt+MXrCgoIsn9ckG 4IirZ3LGgxfwt6Irb6P7fhJwQsDdPA1Ky7fJZSyk/ku01+EOQ0bkyZ+SIuvFRQegfRTMqfpTnQd 1 X-Received: by 2002:a05:6a20:2451:b0:1a0:eb43:421b with SMTP id t17-20020a056a20245100b001a0eb43421bmr9582679pzc.28.1709493994546; Sun, 03 Mar 2024 11:26:34 -0800 (PST) Received: from amd.. ([2804:7f0:b401:120f:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id du6-20020a056a002b4600b006e5933a0da9sm5941287pfb.165.2024.03.03.11.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 11:26:34 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org Cc: peter.maydell@linaro.org, gustavo.romero@linaro.org Subject: [PATCH 2/2] tests/tcg: Add multiarch test for Xfer:siginfo:read stub Date: Sun, 3 Mar 2024 19:26:10 +0000 Message-Id: <20240303192610.498490-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240303192610.498490-1-gustavo.romero@linaro.org> References: <20240303192610.498490-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=gustavo.romero@linaro.org; helo=mail-pf1-x435.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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 Add multiarch test for testing if Xfer:siginfo:read query is properly handled by gdbstub. Signed-off-by: Gustavo Romero --- tests/tcg/multiarch/Makefile.target | 10 ++++++- .../gdbstub/test-qxfer-siginfo-read.py | 26 +++++++++++++++++++ tests/tcg/multiarch/segfault.c | 14 ++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py create mode 100644 tests/tcg/multiarch/segfault.c diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index e10951a801..61cda9640e 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -80,6 +80,13 @@ run-gdbstub-qxfer-auxv-read: sha1 --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \ basic gdbstub qXfer:auxv:read support) +run-gdbstub-qxfer-siginfo-read: segfault + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin "$< -s" --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-siginfo-read.py, \ + basic gdbstub qXfer:siginfo:read support) + run-gdbstub-proc-mappings: sha1 $(call run-test, $@, $(GDB_SCRIPT) \ --gdb $(GDB) \ @@ -122,7 +129,8 @@ endif EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \ run-gdbstub-registers run-gdbstub-prot-none \ - run-gdbstub-catch-syscalls + run-gdbstub-catch-syscalls \ + run-gdbstub-qxfer-siginfo-read # ARM Compatible Semi Hosting Tests # diff --git a/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py b/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py new file mode 100644 index 0000000000..862596b07a --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/test-qxfer-siginfo-read.py @@ -0,0 +1,26 @@ +from __future__ import print_function +# +# Test gdbstub Xfer:siginfo:read stub. +# +# The test runs a binary that causes a SIGSEGV and then looks for additional +# info about the signal through printing GDB's '$_siginfo' special variable, +# which sends a Xfer:siginfo:read query to the gdbstub. +# +# The binary causes a SIGSEGV at dereferencing a pointer with value 0xdeadbeef, +# so the test looks for and checks if this address is correctly reported by the +# gdbstub. +# +# This is launched via tests/guest-debug/run-test.py +# + +import gdb +from test_gdbstub import main, report + +def run_test(): + "Run through the test" + + gdb.execute("continue", False, True) + resp = gdb.execute("print/x $_siginfo", False, True) + report(resp.find("si_addr = 0xdeadbeef"), "Found fault address.") + +main(run_test) diff --git a/tests/tcg/multiarch/segfault.c b/tests/tcg/multiarch/segfault.c new file mode 100644 index 0000000000..e6c8ff31ca --- /dev/null +++ b/tests/tcg/multiarch/segfault.c @@ -0,0 +1,14 @@ +#include +#include + +/* Cause a segfault for testing purposes. */ + +int main(int argc, char *argv[]) +{ + int *ptr = (void *)0xdeadbeef; + + if (argc == 2 && strcmp(argv[1], "-s") == 0) { + /* Cause segfault. */ + printf("%d\n", *ptr); + } +}