From patchwork Thu May 23 03:51:24 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: 798397 Delivered-To: patch@linaro.org Received: by 2002:a5d:6a47:0:b0:354:fb4b:99cd with SMTP id t7csp29041wrw; Wed, 22 May 2024 20:52:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUMfc+pXo85j7+1Fx5vekuG0ZCsjsq/mYrip4HQ7hyItTBpY8tn1Sc2Ybl2A62/lQgemM+0wvt/jbYArZ9stoxy X-Google-Smtp-Source: AGHT+IHnyZoa0Km1vN8LepZdN5/aFFSqd5py0fGc0hwryP7eCAOc64kyWOfTZ1DqzRRzJSaKaioa X-Received: by 2002:a0d:cb58:0:b0:61b:34b0:ff04 with SMTP id 00721157ae682-627e4846b5dmr36760757b3.32.1716436349396; Wed, 22 May 2024 20:52:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716436349; cv=pass; d=google.com; s=arc-20160816; b=aYHcDmDgiB8xGQQPtY2fG6o+3aArRRp0DFdJbVTuTZ+lDvb3lusld2gyl9snW1bEQq 9GdDfsILny01KfKOvsVjLWlYYvHE5GguTwJCw3EkzyTsPTcpXv8xGoz1upaLot8IyJ6Z DXZRkFFus3nJ9qkgxOuRjgJdoiu5JezdJwU5m4Um88I1Uy2QUWdQ+ud6n+SSbpe8dUwd UbovZ4ufFVD95PDXd42NCAw+mgeI4UwPm1/1v91A3sH3wkqx/eB3SjEvLmQOZSIMUwUh vrh4/jPaZwqjuSMdf5hvkUG3F8sxPtZbvfgxWh290U033V1NzoO4EEO2AvbrSZOqHNCg f78g== 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=+Hlgtl9IW3h71ehJygtrZ7Azc2qhSTdSpst7m2YEwI0=; fh=loWCTN49GeJC1HCrrvtQFeZ0kzyLaMXCA7ZZRe9+Kj4=; b=FdnGGK79ZaeMVjb4UQrcWJU/gC3TpFAfF7Smwn6Bp4REyxTU8TJh0l/Xm8mFLCyeV1 hFguU1WMfIHmeydlUg8/pjV0z75nJxqYcwRgvFcLSLBG+qj3F02Ia/pjaVAPbC+tbsJF xf4y6mfPv4Cnrz8VFUqXxl1pIiIpVMSC9zCwcd1+wYRUUrqpG0DakKkq+f/qpMY3sVlk 80YdFKqZvt0A9lBYDThxTkl3Qsm2GwNfdiF5JxJzBDzMJNZ7bfvLn2qVPKlGzupA3bL9 /piBwmCu/iol5+5HI4WuVHK5YTHex1+SOTO3gH/UDr7zdFOyUtKrl2BDlnPbylNwdwnC /jdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yvDP7i9s; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f2b486fsi316695476d6.313.2024.05.22.20.52.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 20:52:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yvDP7i9s; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 0D16F38654B4 for ; Thu, 23 May 2024 03:52:29 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id CB8BD38654AD for ; Thu, 23 May 2024 03:51:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB8BD38654AD 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 CB8BD38654AD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716436302; cv=none; b=GUdfztsXi23F8J1u5l/kmgrO8YFYaQRjaP862suK8uPHcAJze7xCJK2EG5dVVNYRhNwnb1UPJUPK5DuQ5iy5UCfEJ+NusQmGmpyaKAHlyq5/oNpNNkbB8koKfr9qQt78dz4F2IyilL4QWEJeegmoPa7h0HIYLKFJ00kP4Iu3nWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716436302; c=relaxed/simple; bh=MCukXILfTqNFR9VFFKkVJeeWOlnNv03R4Xipj2Jdu4s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FyZgYwtx9PLnLYtuUn2nsC5h3RTd+D/jOD8i3SJs0BoEXDSPWxNCNlEwrKvAKtBf7uNPvezacsHdwjjZuPGhrQUalsiOb/KXevacXDqFug8yKi2rPGLQRk0/RqT4rr/YfQn6akipTVsd4J0/B4pjhFPcNnrDq5ZCoFmqVkRs82Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6f693fb0ad4so2419689b3a.1 for ; Wed, 22 May 2024 20:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716436299; x=1717041099; 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=+Hlgtl9IW3h71ehJygtrZ7Azc2qhSTdSpst7m2YEwI0=; b=yvDP7i9sw9SeRhq8Eucq8edcFSrLHF1r3VHtay9KWUgQ/+K+bEOO1eq2lSUc3eILuS iK26akmRzwKfRJ7TiLAvZb57FanVymlLBEC9rvNAmEl43BCGXCd5wDhYHK7gT8Mcs+mN Tnv5YnvohvudHi0edX111JAMfGOzUBZOKlQ6LL1b5bSXx7ne7zu6YuY2E8W3fPlK7cLc NA25QvZKu7ordbCUbzJp+pDLcIspGGKsczd4caG4ZxT4nqfVbuGreSZRRR2Xp0hkVngy wVl2RMiwuQj2KysQ9sjCxrxN18M6avm2gljnmOdh9+ZEIS0OIskaeJ0Rb/yrqPN8RI/d Vrsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716436299; x=1717041099; 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=+Hlgtl9IW3h71ehJygtrZ7Azc2qhSTdSpst7m2YEwI0=; b=LDbik+t26KJkB/lCVAdIpwlaZz3IHWGXdZtFDGb9uoI3TYgA0ySuxXnA1LEJ+psKGo 1LM1VvVXTt5mgNyAMXJuSNFCU4LKvaR8gZCOt/VFTG93PN0QSdHqNDi5hzbR9cLmWfVT 1Q8uQprwmkvL12f2G/i2YzYSO3FlNm01J+94YBar3y4UBzSfRTsJaVXrIMva1TpFAset 3F/xM5BrTTqP0+7t4JMzjp0TP/jta71ergQAHkRYad7KwFYDYphdFQLU8w5BinsrvAzR SsE0skszZU7h1rcPF/ScgEWnTAP5staLHNws6zGeShaLms8Ie3Itx7jhKTeK9emRJSEm RmzA== X-Gm-Message-State: AOJu0YxgwxgNyrxvO65LEULDimk0lrrH790q0wKdRfav8aRCSiKidtZ2 NOdNmbPmWoDSo7Xh48qri5i4Qv9SOrtrgDfOOWBQY+nYoB+lchgZMLGXNlitV8Z0TprlYnFksWx I X-Received: by 2002:a05:6a00:3a25:b0:6ed:4f2e:ef22 with SMTP id d2e1a72fcca58-6f6d61e9ffemr4432177b3a.31.1716436298763; Wed, 22 May 2024 20:51:38 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:f149:d562:aa25:4733]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f679902e57sm12778803b3a.110.2024.05.22.20.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 20:51:38 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Christophe Lyon , Luis Machado , Guinevere Larsen , Pedro Alves Subject: [PATCH v4 3/3] gdb/testsuite: Add gdb.arch/aarch64-mops-watchpoint.exp Date: Thu, 23 May 2024 00:51:24 -0300 Message-ID: <20240523035124.2639220-4-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240523035124.2639220-1-thiago.bauermann@linaro.org> References: <20240523035124.2639220-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 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. --- Changes in v4: - Moved procedure allow_aarch64_mops_tests to patch 1. - Fix typo in comment (Spotted by Luis). No change in v1, v2 or v3. .../gdb.arch/aarch64-mops-watchpoint.c | 66 ++++++++++++++++ .../gdb.arch/aarch64-mops-watchpoint.exp | 79 +++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.c create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp 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"