From patchwork Sat May 4 00:05:20 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: 794557 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp986004wrr; Fri, 3 May 2024 17:06:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXcfr9XT8SLIBevKE+kUm4utxUyv3mGFn61g06fMOLt0bwMBN63UL72c0l83c5KoZQL91GuvdwNoDUwAQrdPb5H X-Google-Smtp-Source: AGHT+IFpnRyhkUb4p9QmwzsCQqtg72rvyW5QstY+rB8XFdodTqVPfLO/ksWVC6+7gkjBq2ZbebPh X-Received: by 2002:a25:ec0b:0:b0:de5:5706:b959 with SMTP id j11-20020a25ec0b000000b00de55706b959mr4496429ybh.1.1714781213700; Fri, 03 May 2024 17:06:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714781213; cv=pass; d=google.com; s=arc-20160816; b=ty2BdvCFnqEC2UXYBsxII3H7wLUcQwRY2VZPnXO6q3gKxz05EVYmD6G70s6qdf3lnx vMMr/UD3Vfy6lk2FELOntwolqUX1EkG9xlEKCbxxEhg5w9veA2AM3u+yC0y4uU/cPDfd lDaubcZb+LKe94SJSRa5lCncKxT1Yy6tK5bYiUywQJ4We1tGk4GMyyZieQnWS9tc958Q 7GoPYpyHS11tMjlDGGASfQJ2ujj1rXo3q+hDhBqV8780jZ526J6JNkU8CZubW+ZDpElT f6QgsqR9W0iTM3TtspvExrItn3g1tErbohPX1OyHrFmpESBtudkg6969rib3UPUl3DLv HwXw== 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:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=1MduVO//xrZXadrlceS6ikuP3WfARpTg2oYwtmYhAJc=; fh=72kqq0iQhigvR9Vv/oqX5ebs3Yyyw7XhzWxOOEPdupI=; b=U0hkHHxdsqTGkBe6YZpEZHJakgt5evXZ1+h1554ZxG3iltXt4f6KwC5vUXw5PBGbgJ /fNvQKSyLonLTySr8v/z5DrT/QJtwckCrHMd2m9ntPx28JsG/R9jhttTmVeQIfUiauct QDgIxWSMkozXZ812cmDgQvqLcr2Ujxp82DACMa+xeEEryNXM1EJ3yUzK1VDfaSYS5vCs bfDaZoxpOZlyUzjVXO5VIkXTO1f4Hcl2SXYeVFiq/H1+O2nWUsrWIn3vOBZxON82oAQv +ybN6UnBVtRuqkAT/A9lpRUWIl3Dphxi+2h8jLksWntzlwFF0BRiu5mlcBbZquC1O93G lxaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CbANOAT9; 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 ay32-20020a05622a22a000b00439df8fa2a2si4485915qtb.652.2024.05.03.17.06.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 17:06:53 -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=CbANOAT9; 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 4F8DC3844073 for ; Sat, 4 May 2024 00:06:53 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id D1B5E3844054 for ; Sat, 4 May 2024 00:05:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D1B5E3844054 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 D1B5E3844054 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714781143; cv=none; b=Oi9g187Y3kJ3ZMMLK+HCyIFCjdC51YA5GOVnGjeku6cFLC+x9iYEaPwExUn1D+JVlQf4CVNqJR+yxXOW0WfYRdZ7AsQjZZj73+uInIZ1f/0bcSRCnTgUT9j7bMY9NZ5XlqfPLoQfDErj5XrgRcf/MgQOw0DbwdcTG+B4Ko6DU8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714781143; c=relaxed/simple; bh=0OXPeMid0ijWsdWT0emEUPY1SOoIVDRrdmKLRpD1xoI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qYwhVf0blPw9hJ6+bxEjYzPxrj12UePby0HDuNW0IhibBwt2qG9yjwdoDPxW1FmNEBIhYhsHiAWII2k9nR1d+kuumrb+hDbLgElC4kav/DL7bJjIsMaPl5NR/6C+ajeb/b5KWxo7nugMxkGZwzRVLUXj1wMRIJJULqCWmCwoflA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1e86d56b3bcso2052255ad.1 for ; Fri, 03 May 2024 17:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714781140; x=1715385940; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1MduVO//xrZXadrlceS6ikuP3WfARpTg2oYwtmYhAJc=; b=CbANOAT9T1ZDi/wENYBsXszDjbi6iWLR3uVtkMqu7UfaTH+V5zj54ePWmrJZ1KY2g7 OWTkDfdGjFDxBsWagqE17gdopBNNC6RZEK6uvDVgn/mDn2eMEf/rr2ZIUCAXfBso2d3f QgpqBVBAwQH9/Yo/o7QdoKEMT+rXgZqlKUgi5MYam51XPSuJcHx+jTVbqkDYMr/vA+Ka K/C9ThpteTpoXG86cK8la5GiAMACfoWHu6QtKJpYu2ZScknH8Q7pzkWxOjXOcArx1r+8 568wBI+GqoHwITzQvUje6WcczIkQgQIPqI80LUS/1BWxKG+saVW/8dlEDc6acOi7kfr1 osDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714781140; x=1715385940; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1MduVO//xrZXadrlceS6ikuP3WfARpTg2oYwtmYhAJc=; b=s0CHv1BrWXcIHnx4rHjp3Ctw9CLRWpKRQ+5uMGs7so4UBdANmyQJkVJJL0eizOJNCT dFRVDt36d+XyMIMTRLr1FIuH8aRMG0OKaI7y3yQnobbVrbv9GjEuRJslsgWrwhhA28k1 YTubAHY2cu/2GG0PTfWo1bNxIi+wsbqUsiexkRYelJdEKcYj90eHX32qmz77cfM4ARtm C5gymR+GWC7ExNA4rys49P1a9u8hhyc5SX47AEDqdgBMeCN+Zcz9p+869qMv9at9G4qo opM1zy5ygN541zSuulGpLYDOVvESyjkMG6p8aDX4sL+RUqyB8gQJGeGj8vzLhFjRI37A Ithg== X-Gm-Message-State: AOJu0YxYT7Db/nPcwMNzulRhiNdy/8HWGzyVjkmmq6mMk5VvnovqxgL8 cywfQXLmcM25osUTCLPdH97HV4OIMG8+fnRz7WvbTx81lOnUSs7Gg0R/odrnUoooYsT5MkpkeOM 1 X-Received: by 2002:a17:902:9f98:b0:1eb:6468:7fc3 with SMTP id g24-20020a1709029f9800b001eb64687fc3mr3782548plq.62.1714781139800; Fri, 03 May 2024 17:05:39 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:50e3:94e0:79b0:c9f9]) by smtp.gmail.com with ESMTPSA id x13-20020a170902ec8d00b001ecf6d3edb5sm3848163plg.241.2024.05.03.17.05.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 17:05:39 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Subject: [PATCH 4/5] gdb/testsuite: Add gdb.arch/aarch64-mops-atomic-inst.exp Date: Fri, 3 May 2024 21:05:20 -0300 Message-ID: <20240504000521.314531-5-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240504000521.314531-1-thiago.bauermann@linaro.org> References: <20240504000521.314531-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 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 The testcase verifies that MOPS sequences are stepped over when stepping the inferior instruction by instruction. --- .../gdb.arch/aarch64-mops-atomic-inst.c | 62 ++++++++++++ .../gdb.arch/aarch64-mops-atomic-inst.exp | 97 +++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-atomic-inst.c create mode 100644 gdb/testsuite/gdb.arch/aarch64-mops-atomic-inst.exp diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-atomic-inst.c b/gdb/testsuite/gdb.arch/aarch64-mops-atomic-inst.c new file mode 100644 index 000000000000..211cfb21c37c --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-mops-atomic-inst.c @@ -0,0 +1,62 @@ +/* This file 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 . */ + +#define TEST_STRING "Just a test string." +#define BUF_SIZE sizeof(TEST_STRING) + +int main(void) +{ + const char source[BUF_SIZE] = TEST_STRING; + char dest[BUF_SIZE]; + char *p = dest; + const char *q; + const long zero = 0; + long size = BUF_SIZE; + + /* Break memset. */ + /* 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 = dest; + q = source; + /* Break memcpy. */ + /* 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"); + + p = dest; + q = source; + /* Break memmove. */ + /* 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"); + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-atomic-inst.exp b/gdb/testsuite/gdb.arch/aarch64-mops-atomic-inst.exp new file mode 100644 index 000000000000..ad74795d5cfd --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-mops-atomic-inst.exp @@ -0,0 +1,97 @@ +# 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 . +# +# This file is part of the GDB testsuite. + +# Test single stepping through MOPS (memory operations) atomic sequences. + +require 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 +} + +proc is_at_instruction { instruction } { + global gdb_prompt hex + + set test "pc points to $instruction" + gdb_test_multiple {x/i $pc} $test { + -re -wrap "=> $hex \[^\r\n\]+:\t$instruction\t\[^\r\n\]+" { + return 1 + } + -re "\r\n$gdb_prompt $" { + return 0 + } + } + + return 0 +} + +proc arrive_at_instruction { instruction } { + set count 0 + + while { [is_at_instruction $instruction] != 1 } { + gdb_test -nopass "nexti" ".*__asm__ volatile.*" \ + "nexti #$count to reach $instruction" + incr count + + if { $count > 50 } { + fail "didn't reach $instruction" + return 0 + } + } + + return 1 +} + +if ![runto_main] { + return -1 +} + +gdb_breakpoint ${srcfile}:[gdb_get_line_number "Break memset"] +gdb_breakpoint ${srcfile}:[gdb_get_line_number "Break memcpy"] +gdb_breakpoint ${srcfile}:[gdb_get_line_number "Break memmove"] + +gdb_continue_to_breakpoint "memset breakpoint" + +if { [arrive_at_instruction setp] } { + # The nexti output isn't useful to detect whether we skipped the sequence. + gdb_test "nexti" "\[^\r\n\]+" "step through the memset sequence" + gdb_assert { [is_at_instruction setm] == 0 \ + && [is_at_instruction sete] == 0 } \ + "stepped through the memset sequence" +} + +gdb_continue_to_breakpoint "memcpy breakpoint" + +if { [arrive_at_instruction cpyfp] } { + # The nexti output isn't useful to detect whether we skipped the sequence. + gdb_test "nexti" "\[^\r\n\]+" "step through the memcpy sequence" + gdb_assert { [is_at_instruction cpyfm] == 0 \ + && [is_at_instruction cpyfe] == 0 } \ + "stepped through the memcpy sequence" +} + +gdb_continue_to_breakpoint "memmove breakpoint" + +if { [arrive_at_instruction cpyp] } { + # The nexti output isn't useful to detect whether we skipped the sequence. + gdb_test "nexti" "\[^\r\n\]+" "step through the memmove sequence" + gdb_assert { [is_at_instruction cpym] == 0 \ + && [is_at_instruction cpye] == 0 } \ + "stepped through the memmove sequence" +}