From patchwork Fri May 10 05:24:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 796029 Delivered-To: patch@linaro.org Received: by 2002:a5d:452e:0:b0:34e:ceec:bfcd with SMTP id j14csp668880wra; Thu, 9 May 2024 22:24:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUwiE2iDp77pmN5AX4WK48GxExtmMT0C4H/rtaMeOlFN6Nt5R6S65C1u5/VNg2vAmNYgBQYxMD+kiOVtDlj2rXK X-Google-Smtp-Source: AGHT+IEeA0mXLMnY5SkBlkMt1cCYINDQS2UzyMWSnqF9aZ541z4OjvZ+jxWylxHF3jgjAAZxGc3H X-Received: by 2002:a05:6214:4388:b0:6a0:c8c3:7a53 with SMTP id 6a1803df08f44-6a1681aeba1mr13524206d6.31.1715318695528; Thu, 09 May 2024 22:24:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715318695; cv=pass; d=google.com; s=arc-20160816; b=lpxJlEpvwqf2CskZSHvmZAtgJ+23q0U2LV+ANdxSDvlbGiynyd+ia6z4KFsTWKuuM1 HMJrtCiJltZRCz8l+fo3Opoo1ig7nEMYLmYlvasQJN5euw9A7rUIWPCJL8H+b9yBVsR1 xuN46yGLwhBo5z5jMsZPTK4YGMLPy+PvAz64aVIRf5qCcaM0JeScXdsn1hgIR9oKbbSO 4gNcB9vYPvHB/ZdkXKstFbJoFYOgEKP/zTTxfHmdVXift42KdqN2sB56z6FPUpd91uuw 5piE1G9rXdHS9l8VOohMmmxIPjUkFQf2lPLeLW56LkojzK/XrWilDhDOODJOT5fcp9Tl ek6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:arc-filter:dmarc-filter:delivered-to; bh=E49Ej90wJ8Yzkw832LSO7S+A8H6Ux4NZDCi/ilkGlfk=; fh=fCgs51ICTgFk+vSt57NFPMWoUahXD4XhqjP2ci5WYSU=; b=SdRUFrzUxwK72eWQAe18MsUTou9iVnHzFGeuMNjXVt9k9Y3zPf7ZqS8utYWJsKm/iD l+1/LpS35OZXs/bOX/cIVjU1tiLBXDVCztjckGjWNiiEzmdu0P8f5RmhbsWvj6QjROqe UT6Dsf4nAmN5PkXpeXNLdVESspvm8ue4d2cGmmqOkk2Wq5s1AOQUdvvwxQ4Ggnd3V4r5 QG5xusjjAOFy6SQFcYk/WbfpFy3q34mz1EWa8C5J9Jro97uot2cUAbRf/yzURAm6vNCQ IF08QHG+65nrky+IV5U/5wDpY/GD1I+unMdTPaWuZ3L8r1HFCiIg3os9t4iXRrUSnZyg THpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l+loZ6D3; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f2b6873si28791286d6.333.2024.05.09.22.24.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 22:24:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l+loZ6D3; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 27E3E386F421 for ; Fri, 10 May 2024 05:24:55 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id 39FBE3858431 for ; Fri, 10 May 2024 05:24:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 39FBE3858431 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 39FBE3858431 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715318667; cv=none; b=pvwZBH59qZZYGUxxz3Ri7LitmXPTDZxxk/0zI4EuTWLA1rz4quipIJamGa1jRgJgZVG+LgMTGlnBjrlMItEoq09KBcn/r4sLPG+Na6k3MEfLnYP2bmPXaNyZwc4WD9UmPVAbYA0O/Yr1L2/Ok2f7jlx2zBa88P/OICGTElB4V0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715318667; c=relaxed/simple; bh=UmGOuAkU/WqVOmAeiujEhP7G5+EU6twxIkZiFEOR5NY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=w//sdttFNv+Jm42PyTOaM9/sRT3nNI7ifer+MyTXII6fqoqcN9XQKMv+4qINdKA1SK4r1jeY1J/J8imtZ1p6W9u7HGmTUoFTdUqlJolLTsQJyVltn6g3jm65NC6k0Imgf6LXjTQgutU9UdNxDpus4dt1OrRyNqBjGEjMpTHEauc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-2b27c532e50so1252546a91.2 for ; Thu, 09 May 2024 22:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715318662; x=1715923462; darn=sourceware.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=E49Ej90wJ8Yzkw832LSO7S+A8H6Ux4NZDCi/ilkGlfk=; b=l+loZ6D3wYjn1/rPh+W6MKMeEP36AljPcoVBWfFjWq6znoNtqUp6sU6CUw9qSBtZxl CRf6OKMlLGkuO6TQrrXrDtn0/ekkjd+BLkCtIAgyFvcGd+wUE8TEojrfKqHy85HserL0 KKgxLDxieZGyeosUTkaSLyHQrIO2fPbDxkffgJheK+CbUnSnryw3SjH6pbUYDr2TTLTX iD1VDm7WuSb1EwRXaahlMAL0r38w0rhslmaW+v2OGFmAtRZarNN20FOaqVA5gHJfu5MM vgeolcF1COAV3dP45bWX2uEX21HA9tbFQT/D9ZZaoMEFYiAjFI46bss6uxkZXd/Slkm6 Mxeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715318662; x=1715923462; 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=E49Ej90wJ8Yzkw832LSO7S+A8H6Ux4NZDCi/ilkGlfk=; b=dCcBJX25TZMT9UdYDY70Ux0pyi8lh8z8ZIkZGXrzU9A3cJ+Ccou8XSjfYDehhwOxvy i9aidfBQk6lQpnZZzJRB3w+O4aEjA68OvKCmu7CM2yuTPL/6UG2m/AQXb6GGMP/A0TxL c25UP/K7B5xH/eqHwfvan6YHx8ywXDaWK6b47n+p1AIAib/2ZNvO6gOXBHwcFcGboq0z RtYh7Z37CS/NKSQ1wH66v0PZ91X/DGwtRbc+eaB4cy2HTExH1SAZP1I025QjhhgZ1TII C3y+et9BtE+m2auIKeAtAQsxG2Bh/kR4HJ4Skn4CCXJEgkC5tM1Yls8ucjgGyymjI4IY Lv2g== X-Gm-Message-State: AOJu0Yyw6omYMh8fQFJ3viclryOFdKZbmWUoy/MUkLFb3/dajJBRaJVE I3vUHQz404UJXGS/362ZiD1xCsxwVNxkzgK4+iY1e6jhXe2WwX9z55ho3E/NF0qCgQuVk5fCHgN o X-Received: by 2002:a17:90b:3781:b0:2b5:6d47:9e1c with SMTP id 98e67ed59e1d1-2b6cc144312mr1592501a91.1.1715318662048; Thu, 09 May 2024 22:24:22 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:9d31:c7dc:c8bd:73d9]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2b6288498e2sm4275201a91.13.2024.05.09.22.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 22:24:21 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Christophe Lyon , Luis Machado Subject: [PATCH v3 3/5] gdb/testsuite: Add gdb.arch/aarch64-mops-watchpoint.exp Date: Fri, 10 May 2024 02:24:06 -0300 Message-ID: <20240510052408.2173579-4-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240510052408.2173579-1-thiago.bauermann@linaro.org> References: <20240510052408.2173579-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patch=linaro.org@sourceware.org Test behaviour of watchpoints triggered by MOPS instructions. This test is similar to gdb.base/memops-watchpoint.exp, but specifically for MOPS instructions rather than whatever instructions are used in the libc's implementation of memset/memcpy/memmove. There's a separate watched variable for each set of instructions so that the testcase can test whether GDB correctly identified the watchpoint that triggered in each case. --- .../gdb.arch/aarch64-mops-watchpoint.c | 66 ++++++++++++++++ .../gdb.arch/aarch64-mops-watchpoint.exp | 79 +++++++++++++++++++ gdb/testsuite/lib/gdb.exp | 61 ++++++++++++++ 3 files changed, 206 insertions(+) create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp No change since v1. diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c new file mode 100644 index 000000000000..b981f033d210 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c @@ -0,0 +1,66 @@ +/* This test program is part of GDB, the GNU debugger. + + Copyright 2024 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +int +main (void) +{ + char source[40] __attribute__ ((aligned (8))) + = "This is a relatively long string..."; + char a[40] __attribute__ ((aligned (8))) + = "String to be overwritten with zeroes"; + char b[40] __attribute__ ((aligned (8))) + = "Another string to be memcopied..."; + char c[40] __attribute__ ((aligned (8))) + = "Another string to be memmoved..."; + char *p, *q; + long size, zero; + + /* Break here. */ + p = a; + size = sizeof (a); + zero = 0; + /* memset implemented in MOPS instructions. */ + __asm__ volatile ("setp [%0]!, %1!, %2\n\t" + "setm [%0]!, %1!, %2\n\t" + "sete [%0]!, %1!, %2\n\t" + : "+&r"(p), "+&r"(size) + : "r"(zero) + : "memory"); + + p = b; + q = source; + size = sizeof (b); + /* memmove implemented in MOPS instructions. */ + __asm__ volatile ("cpyp [%0]!, [%1]!, %2!\n\t" + "cpym [%0]!, [%1]!, %2!\n\t" + "cpye [%0]!, [%1]!, %2!\n\t" + : "+&r" (p), "+&r" (q), "+&r" (size) + : + : "memory"); + p = c; + q = source; + size = sizeof (c); + /* memcpy implemented in MOPS instructions. */ + __asm__ volatile ("cpyfp [%0]!, [%1]!, %2!\n\t" + "cpyfm [%0]!, [%1]!, %2!\n\t" + "cpyfe [%0]!, [%1]!, %2!\n\t" + : "+&r" (p), "+&r" (q), "+&r" (size) + : + : "memory"); + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp new file mode 100644 index 000000000000..9e210602d800 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp @@ -0,0 +1,79 @@ +# Copyright 2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test a binary that uses MOPS (Memory Operations) instructions. +# This test is similar to gdb.base/memops-watchpoint.exp, but specifically +# tests MOPS instructions rather than whatever instructions are used in the +# system libc's implementation of memset/memcpy/memmove. + +require allow_hw_watchpoint_tests allow_aarch64_mops_tests + +standard_testfile + +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ + [list debug additional_flags=-march=armv9.3-a]] } { + return -1 +} + +set linespec ${srcfile}:[gdb_get_line_number "Break here"] +if ![runto ${linespec}] { + return -1 +} + +gdb_test "watch -location a\[28\]" \ + "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \ + "set watch on a" +gdb_test "watch -location b\[28\]" \ + "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \ + "set watchpoint on b" +gdb_test "watch -location c\[28\]" \ + "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \ + "set watchpoint on c" + +gdb_test "continue" \ + [multi_line \ + "Continuing\\." \ + "" \ + "Hardware watchpoint ${decimal}: -location a\\\[28\\\]" \ + "" \ + "Old value = 104 'h'" \ + "New value = 0 '\\\\000'" \ + "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \ + "${decimal}\\s+__asm__ volatile \\(\"setp.*\\\\n\\\\t\""] \ + "continue until set watchpoint hits" + +gdb_test "continue" \ + [multi_line \ + "Continuing\\." \ + "" \ + "Hardware watchpoint ${decimal}: -location b\\\[28\\\]" \ + "" \ + "Old value = 101 'e'" \ + "New value = 114 'r'" \ + "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \ + "${decimal}\\s+__asm__ volatile \\(\"cpyp.*\\\\n\\\\t\""] \ + "continue until cpy watchpoint hits" + +gdb_test "continue" \ + [multi_line \ + "Continuing\\." \ + "" \ + "Hardware watchpoint ${decimal}: -location c\\\[28\\\]" \ + "" \ + "Old value = 100 'd'" \ + "New value = 114 'r'" \ + "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \ + "${decimal}\\s+__asm__ volatile \\(\"cpyfp.*\\\\n\\\\t\""] \ + "continue until cpyf watchpoint hits" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 0d78691c381b..25b272fdaabc 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4497,6 +4497,67 @@ proc aarch64_supports_sme_svl { length } { return 1 } +# Run a test on the target to see if it supports Aarch64 MOPS (Memory +# Operations) extensions. Return 0 if so, 1 if it does not. Note this causes +# a restart of GDB. + +gdb_caching_proc allow_aarch64_mops_tests {} { + global srcdir subdir gdb_prompt inferior_exited_re + + set me "allow_aarch64_mops_tests" + + if { ![is_aarch64_target]} { + return 0 + } + + # ARMv9.3-A contains the MOPS extension. The test program doesn't use it, + # but take the opportunity to check whether the toolchain knows about MOPS. + set compile_flags "{additional_flags=-march=armv9.3-a}" + + # Compile a program that tests the MOPS feature. + set src { + #include + #include + + #ifndef HWCAP2_MOPS + #define HWCAP2_MOPS (1UL << 43) + #endif + + int main() { + bool mops_supported = getauxval (AT_HWCAP2) & HWCAP2_MOPS; + + return !mops_supported; + } + } + + if {![gdb_simple_compile $me $src executable $compile_flags]} { + return 0 + } + + # Compilation succeeded so now run it via gdb. + clean_restart $obj + gdb_run_cmd + gdb_expect { + -re ".*$inferior_exited_re with code 01.*${gdb_prompt} $" { + verbose -log "\n$me mops support not detected" + set allow_mops_tests 0 + } + -re ".*$inferior_exited_re normally.*${gdb_prompt} $" { + verbose -log "\n$me: mops support detected" + set allow_mops_tests 1 + } + default { + warning "\n$me: default case taken" + set allow_mops_tests 0 + } + } + gdb_exit + remote_file build delete $obj + + verbose "$me: returning $allow_mops_tests" 2 + return $allow_mops_tests +} + # A helper that compiles a test case to see if __int128 is supported. proc gdb_int128_helper {lang} { return [gdb_can_simple_compile "i128-for-$lang" {