From patchwork Tue Jun 27 16:09:43 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: 696895 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3868911wrm; Tue, 27 Jun 2023 09:18:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73A2E3f/+YC/bZ0MHlGwZLlS8zzYOL/1zJtuSqao5XHjQhwjbOWJSnCyddHncuI7W9Qvm7 X-Received: by 2002:ac8:5795:0:b0:401:e023:5e9f with SMTP id v21-20020ac85795000000b00401e0235e9fmr4413696qta.68.1687882734392; Tue, 27 Jun 2023 09:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687882734; cv=none; d=google.com; s=arc-20160816; b=k7qTQUwDBB1W+6uLWRcgxybiPo+dIGCSdOLBKDpDYpT4c/K/fEJYQ0nV1f+Ih299mW pnldIt1JOUpW90C7Z3BTg9rPYIqpNjlRRZaWXQffSpD3D/ZnoAUB8o8Zqe17HnTEs1qg rUAzblWGQbyO0Vw4zyRru72z1lQpqx+fXyGO7laiH6zK912kER0bk+bhqEFTuoaIFKH1 DSj4TDIsLYF/YXkc5cwXhuUxbPwSZ0aB9YBHTl47FLF62QXXZ7akf0PoBgnNdPRAUsNy gR/f3auwWkDUPUEDpC89Y/Egji4yG44/MznrwH55Zwh7EhR1uJIaLJh5KkjtTNED8wF1 JXhg== 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=YSkcoehiqyKjiOIAuNJ9AUja3GDxG2+fTHEXVRu0R8c=; fh=B6/adVaiTRj/g/M/QPigvyXZO+x+u/FNsaNX2Qo1+tw=; b=SYPXX6qv2Px07bfeQ5DnPnHj3dryiJTnVN7rCR2v1YfCx8fZR2qr0qaToUPiKRf6K+ 1k3J0yhoE93lMnHx6yvhgofor/M3D7wvWaB60/re8CD2Ra9LjWRHpYkWVd26HQYLQRhY g22Yyg0TaEV0Ts9ohycnJw5/eoqdC+P5WHVo+WkOsQ+O+Xi/8v6+o7OtuNlr9Q/zVPmt bEZOtl1KETyyPe/oBAwjAK20b8bcX6VRWnd7gaMy+fC/lXEAKAgBXplbffipJ3dG7nfX m90d5kMNLaEaW9HRbJNyNpD6Zoqt2tCUh8tE2+5TNS5+jqihw2ezRkGlq/iw7YRFfo8U WZjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l04FELmG; 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 t21-20020a05622a149500b004007a693058si3293901qtx.662.2023.06.27.09.18.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Jun 2023 09:18:54 -0700 (PDT) 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=l04FELmG; 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 1qEBMI-00012l-HS; Tue, 27 Jun 2023 12:16:02 -0400 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 1qEBMF-0000zX-QY for qemu-devel@nongnu.org; Tue, 27 Jun 2023 12:15:59 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEBMA-00087o-Gd for qemu-devel@nongnu.org; Tue, 27 Jun 2023 12:15:59 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-312824aa384so4221212f8f.1 for ; Tue, 27 Jun 2023 09:15:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687882550; x=1690474550; 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=YSkcoehiqyKjiOIAuNJ9AUja3GDxG2+fTHEXVRu0R8c=; b=l04FELmGhRVd9r5eJ9OS1CF/Sz4hNNsVM36lsWwEstCQKdKbWLYyPtGOdDS9CUJrtW gCY4zfxV+bvK0i54jcHrYqr/B6jOxcCPLXREbWcf3H7oy5R1q8Bhl5zoTgHTeQR/r2Jr ZhvEVxnpI297rzCfsW0ZpJs0Ko1oTeE526SXChfgoCZmyHA4fwFVoUvutFWGEC9+dJc5 UJZU9FT1m92pbDNuVMi8olDo9/DMuMo9kja4qpBV5pUGhOxGLwE1r+ISu/GsdWehSoKQ P7oVfLqzqbRHpodVCyFXG3S+cgsMlAZTDU0+S9ydDL+dsQhbtCMQYNuti6kof+JBU9Wz MxlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687882550; x=1690474550; 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=YSkcoehiqyKjiOIAuNJ9AUja3GDxG2+fTHEXVRu0R8c=; b=aF+eeM8pR0HDTSN9EpZdQJ5C0md65ZhHRr7Rg9KKQEzrQiw/anWF1vdG1tTmrt35H6 d/V5ZfnDVtZLKFOcUR7xtdjnYzGIISvIas4TBf3x2jamNSD/mZzVnx00B4JMa+qsjzQ6 6d+g3Wsf6Pk8EclgdlbXAg1LRsa/QX17XC/t5Vzohf2VB3naWJq+X1ZOYDomRU1SQwUr li98R0IQxz+k0tvA+7NtzTWreCh7ei2Ljur69Qje9lR7HpIVbvbgpZj4yNWyGz3mnwoi u82VVq1FYsDM8O638JmUpDlGBbN1rJaewdd7wdZ9BlyAScEyNcO+LPpsZ/Ozt01ZSiYP hPEw== X-Gm-Message-State: AC+VfDxH/Rrefez7RXfKwNSB1xTOipLrk3nIjv8Ss9wAHA88IE3z+AwP u29uMiCn+6Fw6u2QLvlJI/qZEQ== X-Received: by 2002:adf:e8c1:0:b0:30f:bcf3:9a30 with SMTP id k1-20020adfe8c1000000b0030fbcf39a30mr12190379wrn.17.1687882550523; Tue, 27 Jun 2023 09:15:50 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id z2-20020a5d6542000000b00313eee8c080sm7285706wrv.98.2023.06.27.09.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 09:15:49 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3968E1FFBC; Tue, 27 Jun 2023 17:09:48 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Juan Quintela , Thomas Huth , Cleber Rosa , Leonardo Bras , Beraldo Leal , Peter Maydell , Bin Meng , Yanan Wang , Darren Kenny , Alexander Bulekov , Marcel Apfelbaum , Peter Xu , Radoslaw Biernacki , Laurent Vivier , Paolo Bonzini , Eduardo Habkost , qemu-arm@nongnu.org, Stefan Hajnoczi , Richard Henderson , Bandan Das , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Dani?= =?utf-8?q?el_P=2E_Berrang=C3=A9?= , Alexandre Iooss , Marcin Juszkiewicz , Leif Lindholm , Laurent Vivier , Qiuhao Li , Mahmoud Mandour , Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Ilya Leoshkevich Subject: [PATCH v3 36/36] tests/tcg: Add a test for info proc mappings Date: Tue, 27 Jun 2023 17:09:43 +0100 Message-Id: <20230627160943.2956928-37-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230627160943.2956928-1-alex.bennee@linaro.org> References: <20230627160943.2956928-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.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 From: Ilya Leoshkevich Add a small test to prevent regressions. Signed-off-by: Ilya Leoshkevich Message-Id: <20230621203627.1808446-9-iii@linux.ibm.com> Signed-off-by: Alex Bennée --- tests/tcg/multiarch/Makefile.target | 9 ++- .../multiarch/gdbstub/test-proc-mappings.py | 65 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/multiarch/gdbstub/test-proc-mappings.py diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index 373db69648..43bddeaf21 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -81,6 +81,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-proc-mappings: sha1 + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-proc-mappings.py, \ + proc mappings support) + run-gdbstub-thread-breakpoint: testthread $(call run-test, $@, $(GDB_SCRIPT) \ --gdb $(HAVE_GDB_BIN) \ @@ -97,7 +104,7 @@ run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb") endif EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ - run-gdbstub-thread-breakpoint + run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint # ARM Compatible Semi Hosting Tests # diff --git a/tests/tcg/multiarch/gdbstub/test-proc-mappings.py b/tests/tcg/multiarch/gdbstub/test-proc-mappings.py new file mode 100644 index 0000000000..7b596ac21b --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/test-proc-mappings.py @@ -0,0 +1,65 @@ +"""Test that gdbstub has access to proc mappings. + +This runs as a sourced script (via -x, via run-test.py).""" +from __future__ import print_function +import gdb +import sys + + +n_failures = 0 + + +def report(cond, msg): + """Report success/fail of a test""" + if cond: + print("PASS: {}".format(msg)) + else: + print("FAIL: {}".format(msg)) + global n_failures + n_failures += 1 + + +def run_test(): + """Run through the tests one by one""" + try: + mappings = gdb.execute("info proc mappings", False, True) + except gdb.error as exc: + exc_str = str(exc) + if "Not supported on this target." in exc_str: + # Detect failures due to an outstanding issue with how GDB handles + # the x86_64 QEMU's target.xml, which does not contain the + # definition of orig_rax. Skip the test in this case. + print("SKIP: {}".format(exc_str)) + return + raise + report(isinstance(mappings, str), "Fetched the mappings from the inferior") + report("/sha1" in mappings, "Found the test binary name in the mappings") + + +def main(): + """Prepare the environment and run through the tests""" + try: + inferior = gdb.selected_inferior() + print("ATTACHED: {}".format(inferior.architecture().name())) + except (gdb.error, AttributeError): + print("SKIPPING (not connected)") + exit(0) + + if gdb.parse_and_eval('$pc') == 0: + print("SKIP: PC not set") + 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: + report(False, "GDB Exception: {}".format(sys.exc_info()[0])) + print("All tests complete: %d failures" % n_failures) + exit(n_failures) + + +main()