From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id TXK2FC2g62n9/zgAWB0awg (envelope-from ) for ; Fri, 24 Apr 2026 12:54:05 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TcSNs9Hj; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 41A371E0BA; Fri, 24 Apr 2026 12:54:05 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 11ABA1E067 for ; Fri, 24 Apr 2026 12:54:04 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 7E5414BB3BBF for ; Fri, 24 Apr 2026 16:54:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E5414BB3BBF Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TcSNs9Hj Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id F3B474BB3BAF for ; Fri, 24 Apr 2026 16:53:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F3B474BB3BAF Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F3B474BB3BAF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777049615; cv=none; b=HvCO/Cye44hm0LwTdnElE+KiKLjYSjzETVrCM1CaJ2FEr02+aEW9gJ/wjAOS+fNcdQKFf8icOMS0ikqEL/SBbM85GXGotg7rr0dOtWnhZqlblBU6DqZCe/2a3gNsJlpqM7zOC8cII+uZOrLxNBGk03HLgrVHNuyOMDcDIzbVuKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777049615; c=relaxed/simple; bh=jQIyG5MmPSeSeTdmyhP8q+stjlmaxTByIK+5fmdJKpA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=eMcbucnMs9+RyljG6o2ihwb+pyTiBy8eYNZpxFjDImrM3Enj0t7ctD3iTxKzqenfROUwWQ3rvZtOMeZRBWeJ7vwXAzdbuSAc78uZ43srChHe0p57MIJ0O5Qx9SAKVyaBgbGLKV0GnClyeprfm2xRCh81O2JNckC1gyFIAcq7DQA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F3B474BB3BAF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777049614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GkiB6ShWIZvL2QuAKdmr9wRLHS3m+LmHrJPGZzfLKuM=; b=TcSNs9HjzVU38/xGqeYOZGv2pd2MWRcMNa5Wc4wgGpopmHNJI/5MWawCBC03zt/FgLwC9x 7cGE5ZJgDMCdqWZjBPpyB0TuzbrMB9iNZQUnVbZ/MfTDyqr+YGk4VZzex1Lf9wfgQPlFsm 7NPG/TEeNds+mjkn0kw4eN6cUlCVoUc= Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-694-y71dZK26MkebnXjKdx3HDQ-1; Fri, 24 Apr 2026 12:53:32 -0400 X-MC-Unique: y71dZK26MkebnXjKdx3HDQ-1 X-Mimecast-MFC-AGG-ID: y71dZK26MkebnXjKdx3HDQ_1777049612 Received: by mail-vk1-f197.google.com with SMTP id 71dfb90a1353d-56fab6d9242so14521151e0c.0 for ; Fri, 24 Apr 2026 09:53:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777049611; x=1777654411; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GkiB6ShWIZvL2QuAKdmr9wRLHS3m+LmHrJPGZzfLKuM=; b=dwaU/wCkOSHPxiLAenKq6ZT7SKWf6Z+qWSrLJtqg30/jRBcAaL9bIgkzovQyOCVs7m J1aqwRb2tJkVCsRsaoMmn6LmM/qHMEpx6ghFLfKITqNQlws57UzgCcHWkv6L9VWPvuT5 0+ycvGNAhW14pIBy/v0DG4VFvx37RYce2boVPQSB4Qz2xVxXKJXGM427MLrokdNa1bp1 kkZXByy4tNU5VFrzi8b33AL4jh0K4KDZ9aTG91y4bUOdjIm56X5JY7uSCtUf/YHvl90v xyJgJoCtesIxSzFpLNouTmYS+3rnNP6x/uGD25VGnAT0L/KJ71Vu6Q4GsH/VkAUIXMOl KqJw== X-Forwarded-Encrypted: i=1; AFNElJ+GHcq15NWfB488wBcKIdF743V+L9D6jaKWrri7BHuU/NKqmSoqJBQkEID3J6hsGqcxcs+upXfOjjeD5w==@sourceware.org X-Gm-Message-State: AOJu0Yz21TROLts/EKJuUB8anSEu92PyoUaNehh9RED84ZPDJ5r/DBTC NG6MAOAH1jTS7zNzAu0hV5lzRVIb6oHJFNfxQzwh59PdtBnxjza2IgvNE2DUCIMhc2fXBp69b4r 0OuDsFZ8X4xknBefta9u1PgK7uwFkw6NDGRz4k27o/Jt+jfnYGi+H8Wh9TelU6edpfVkxMxY= X-Gm-Gg: AeBDievnhrF2TSIPW5yaG/xwS/zW+QGRbxHbLHIZ0mvQmPmF0w3SodaBhcEja0gF4ta yiDU1y/PW6rcuWhlqqv9r5SzZWh4kdiTLVgWnY7LMRkRsfS8xGSPP7Q6AVcyk9tJFAUm+2x6aWs Jex0RSBbmk6ys4KwNKPWDpLE9f9s8wnQM3xLUeZTSeLzSHeKn8RDVDmltWeFtjP05JR5UeqVA7T myFPDk9m3ZIgNZVwqimemzKrfr4wDJZ3/CEFgw564Lm81eCY6/9WITyuhB/EA3Z15wBxg5D5A5v 3M6qjtwGG2vUJjrH8WQgKJZf25ku1/e9L7vckOjDYL7anSdly41hyWs/NtBeNVv5ihVypq2zxST NkKdM3aPy1Gx9l95cx028KkJdIWuzp8I1QQdkSKuRbw== X-Received: by 2002:a05:6122:322b:b0:56b:1eb:d396 with SMTP id 71dfb90a1353d-56fa5add31fmr18970489e0c.14.1777049611227; Fri, 24 Apr 2026 09:53:31 -0700 (PDT) X-Received: by 2002:a05:6122:322b:b0:56b:1eb:d396 with SMTP id 71dfb90a1353d-56fa5add31fmr18970479e0c.14.1777049610716; Fri, 24 Apr 2026 09:53:30 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:993e::75d? ([2804:14d:8084:993e::75d]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-56fa9351ca8sm13370045e0c.18.2026.04.24.09.53.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Apr 2026 09:53:30 -0700 (PDT) Message-ID: <9d5cf7b2-aede-4803-a52e-bf81d97ce1d4@redhat.com> Date: Fri, 24 Apr 2026 13:53:25 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/4] gdb/aarch64: Test record/replay support for CSSC To: Ezra.Sitorus@arm.com, gdb-patches@sourceware.org Cc: luis.machado.foss@gmail.com, thiago.bauermann@linaro.org References: <20260420215232.68675-1-Ezra.Sitorus@arm.com> <20260420215232.68675-3-Ezra.Sitorus@arm.com> From: Guinevere Larsen In-Reply-To: <20260420215232.68675-3-Ezra.Sitorus@arm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: VohYG1RNbrGSoqoK7HibG7dR2uvBVOsLmhrq1O8N37Q_1777049612 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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~public-inbox=simark.ca@sourceware.org On 4/20/26 6:52 PM, Ezra.Sitorus@arm.com wrote: > From: Ezra Sitorus > > This patch checks that the handling of CSSC instructions is correct. > There is no explicit support for handling these instructions which is > why this patch is composed of tests. Hi Ezra! Thank you for working on this The way this paragraph is worded is a bit confusing to me. On a first reading, this sounded to me like there isn't support for CSSC instructions. However, looking at the test this is clearly not the case since the test expects things to pass I suggest rewording the paragraph to something like this:     GDB can handle aarch64's CSSC instructions, but there were no tests ensuring that and ensuring no regressions would creep in. This commit adds some tests for those instructions. > > Regression tested on aarch64-none-linux-gnu on QEMU with CSSC support. > I observe unrelated regressions that appear to be environmental rather > than caused by this patch. I don't really think there's a need to mention regression testing, since this commit is just adding a test, but it doesn't really harm anything either, so it's your choice to add or remove it. On the code changes, I only have the same feedback as I sent on patch 1: the register keyword is deprecated and entirely ignored by clang. Instead of creating variables, you can just use the registers directly in the asm statements and exp file. -- Cheers, Guinevere Larsen It/she > --- > gdb/testsuite/gdb.reverse/aarch64-cssc.c | 113 +++++++++++++++++ > gdb/testsuite/gdb.reverse/aarch64-cssc.exp | 141 +++++++++++++++++++++ > gdb/testsuite/lib/gdb.exp | 52 ++++++++ > 3 files changed, 306 insertions(+) > create mode 100644 gdb/testsuite/gdb.reverse/aarch64-cssc.c > create mode 100644 gdb/testsuite/gdb.reverse/aarch64-cssc.exp > > diff --git a/gdb/testsuite/gdb.reverse/aarch64-cssc.c b/gdb/testsuite/gdb.reverse/aarch64-cssc.c > new file mode 100644 > index 00000000000..d80d202590c > --- /dev/null > +++ b/gdb/testsuite/gdb.reverse/aarch64-cssc.c > @@ -0,0 +1,113 @@ > +/* This test program is part of GDB, the GNU debugger. > + > + Copyright 2024-2026 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 . */ > + > +#include > + > +#define PREPARE_REGS(X, Y, Z) \ > + __asm__ volatile ("mov %0, %1\n" : "=r"(xa): "r"(X):); \ > + __asm__ volatile ("mov %0, %1\n" : "=r"(xb): "r"(Y):); \ > + __asm__ volatile ("mov %0, %1\n" : "=r"(xc): "r"(Z):); \ > + > +int > +main (void) > +{ > + register uint64_t xa asm ("x19"); > + register uint32_t xb asm ("x20"); > + register uint64_t xc asm ("x21"); > + const uint64_t a = 0x0123456789abcdef; > + const uint64_t b = 0xfedbca9876543210; > + const uint64_t c = 0xdeadbeefc001face; > + > + PREPARE_REGS (a, b, c); > + /* Before abs. */ > + __asm__ volatile ("abs %0, %1\n" > + : "+r"(xa) > + : "r"(xb)); > + /* After abs. */ > + > + PREPARE_REGS (a, b, c); > + /* Before cnt. */ > + __asm__ volatile ("cnt %0, %1\n" > + : "+r"(xa) > + : "r"(xb)); > + /* After cnt. */ > + > + PREPARE_REGS (a, b, c); > + /* Before ctz. */ > + __asm__ volatile ("ctz %0, %1\n" > + : "+r"(xa) > + : "r"(xb)); > + /* After ctz. */ > + > + PREPARE_REGS (a, b, c); > + /* Before smax-1. */ > + __asm__ volatile ("smax %0, %1, #10\n" > + : "+r"(xa) > + : "r"(xb)); > + /* After smax-1. */ > + > + PREPARE_REGS (a, b, c); > + /* Before smax-2. */ > + __asm__ volatile ("smax %0, %1, %2\n" > + : "+r"(xa) > + : "r"(xb), "r"(xc)); > + /* After smax-2. */ > + > + PREPARE_REGS (a, b, c); > + /* Before smin-1. */ > + __asm__ volatile ("smin %0, %1, #10\n" > + : "+r"(xa) > + : "r"(xb)); > + /* After smin-1. */ > + > + PREPARE_REGS (a, b, c); > + /* Before smin-2. */ > + __asm__ volatile ("smin %0, %1, %2\n" > + : "+r"(xa) > + : "r"(xb), "r"(xc)); > + /* After smin-2. */ > + > + PREPARE_REGS (a, b, c); > + /* Before umax-1. */ > + __asm__ volatile ("umax %0, %1, #10\n" > + : "+r"(xa) > + : "r"(xb)); > + /* After umax-1. */ > + > + PREPARE_REGS (a, b, c); > + /* Before umax-2. */ > + __asm__ volatile ("umax %0, %1, %2\n" > + : "+r"(xa) > + : "r"(xb), "r"(xc)); > + /* After umax-2. */ > + > + PREPARE_REGS (a, b, c); > + /* Before umin-1. */ > + __asm__ volatile ("umin %0, %1, #10\n" > + : "+r"(xa) > + : "r"(xb)); > + /* After umin-1. */ > + > + PREPARE_REGS (a, b, c); > + /* Before umin-2. */ > + __asm__ volatile ("umin %0, %1, %2\n" > + : "+r"(xa) > + : "r"(xb), "r"(xc)); > + /* After umin-2. */ > + > + return 0; > +} > diff --git a/gdb/testsuite/gdb.reverse/aarch64-cssc.exp b/gdb/testsuite/gdb.reverse/aarch64-cssc.exp > new file mode 100644 > index 00000000000..640ea4ae19f > --- /dev/null > +++ b/gdb/testsuite/gdb.reverse/aarch64-cssc.exp > @@ -0,0 +1,141 @@ > +# Copyright 2024-2026 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 instruction record for AArch64 FEAT_CSSC instructions. > +# Based on gdb.reverse/aarch64-mops.exp > +# > +# The basic flow of the record tests are: > +# 1) Stop before executing the instructions of interest. Record > +# the initial value of the registers that the instruction will > +# change, i.e. the destination register. > +# 2) Execute the instructions. Record the new value of the > +# registers that changed. > +# 3) Reverse the direction of the execution and execute back to > +# just before the instructions of interest. Record the final > +# value of the registers of interest. > +# 4) Check that the initial and new values of the registers are > +# different, i.e. the instruction changed the registers as expected. > +# 5) Check that the initial and final values of the registers are > +# the same, i.e. GDB record restored the registers to their > +# original values. > + > +require allow_aarch64_cssc_tests > +standard_testfile > + > +if { > + [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ > + [list debug additional_flags=-march=armv8-a+cssc]] > +} { > + return -1 > +} > + > +if {![runto_main]} { > + return -1 > +} > + > +gdb_test_no_output "record full" > + > +proc test_single_asm { name } { > + global decimal hex > + > + set before_seq [gdb_get_line_number "Before ${name}"] > + set after_seq [gdb_get_line_number "After ${name}"] > + set regs { x19 x20 x21 } > + > + set insn [lindex [split $name "-"] 0] > + > + gdb_test "break $before_seq" \ > + "Breakpoint $decimal at $hex: file .*/aarch64-cssc.c, line $decimal\\." \ > + "$insn: break before instruction sequence" > + gdb_continue_to_breakpoint "$insn: about to execute instruction sequence" \ > + [multi_line ".*/aarch64-cssc.c:$decimal" \ > + "$decimal\[ \t\]+__asm__ volatile \\(\"${insn} \[^\r\n\]+\""] > + > + # Depending on the compiler, the line number information may put GDB a few > + # instructions before the beginning of the asm statement. > + arrive_at_instruction $insn > + # Add a breakpoint that we're sure is at the prologue instruction. > + gdb_test "break *\$pc" \ > + "Breakpoint $decimal at $hex: file .*/aarch64-cssc.c, line $decimal\\." \ > + "$insn: break at prologue instruction" > + > + # Record the initial register values. > + foreach r $regs { > + set ${r}_initial [capture_command_output "info register $r" ""] > + } > + > + gdb_test "break $after_seq" \ > + "Breakpoint $decimal at $hex: file .*/aarch64-cssc.c, line $decimal\\." \ > + "$insn: break after instruction sequence" > + gdb_continue_to_breakpoint "$insn: executed instruction sequence" \ > + [multi_line ".*/aarch64-cssc.c:$decimal" ".*"] > + > + # Record the new register values. > + foreach r $regs { > + set ${r}_new [capture_command_output "info register $r" ""] > + } > + > + # Execute in reverse to before the instruction sequence. > + gdb_test_no_output "set exec-direction reverse" > + > + gdb_continue_to_breakpoint "reversed execution of instruction sequence" \ > + [multi_line ".*/aarch64-cssc.c:$decimal" \ > + "$decimal\[ \t\]+__asm__ volatile \\(\"${insn} \[^\r\n\]+\""] > + > + # Record the final register values. > + foreach r $regs { > + set ${r}_final [capture_command_output "info register $r" ""] > + } > + > + foreach v { x19 x20 x21 } { > + gdb_assert ![string compare [set ${v}_initial] [set ${v}_final]] \ > + "$insn: check $v initial value versus $v final value" > + } > + > + gdb_assert [string compare [set x19_initial] [set x19_new]] \ > + "$insn: check x19 initial value versus x19 new value" > + > + foreach v { x20 x21 } { > + gdb_assert ![string compare [set ${v}_initial] [set ${v}_new]] \ > + "$insn: check $v initial value versus $v new value" > + } > + > + # Restore forward execution and go to end of recording. > + gdb_test_no_output "set exec-direction forward" > + gdb_test "record goto end" \ > + [multi_line \ > + "Go forward to insn number $decimal" \ > + "#0 main \\(\\) at .*/aarch64-cssc.c:$decimal" \ > + ".*"] > +} > + > +set cases { > + { abs } > + { cnt } > + { ctz } > + { smax-1 } > + { smax-2 } > + { smin-1 } > + { smin-2 } > + { umax-1 } > + { umax-2 } > + { umin-1 } > + { umin-2 } > +} > + > +foreach c $cases { > + lassign $c insn > + test_single_asm $insn > +} > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index c6afc556548..7d400e9028a 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -5350,6 +5350,58 @@ gdb_caching_proc allow_aarch64_lrcpc3_tests {} { > return $allow_lrcpc3_tests > } > > +# Run a test on the target to see if it supports the AArch64 CSSC feature. > +# Return 1 if so, 0 if it does not. Note this causes a restart of GDB. > + > +gdb_caching_proc allow_aarch64_cssc_tests {} { > + global srcdir subdir gdb_prompt inferior_exited_re > + > + set me "allow_aarch64_cssc_tests" > + > + if { ![is_aarch64_target]} { > + return 0 > + } > + > + set compile_flags "{additional_flags=-march=armv8-a+cssc}" > + > + # Compile a test program reading CSSC. > + set src { > + int main() { > + asm volatile ("abs x0, x1"); > + return 0; > + } > + } > + > + if {![gdb_simple_compile $me $src executable $compile_flags]} { > + return 0 > + } > + > + # Compilation succeeded so now run it via gdb. > + clean_restart > + gdb_load $obj > + gdb_run_cmd > + > + gdb_expect { > + -re ".*Illegal instruction.*${gdb_prompt} $" { > + verbose -log "\n$me cssc support not detected" > + set allow_cssc_tests 0 > + } > + -re ".*$inferior_exited_re normally.*${gdb_prompt} $" { > + verbose -log "\n$me: cssc support detected" > + set allow_cssc_tests 1 > + } > + default { > + warning "\n$me: default case taken" > + set allow_cssc_tests 0 > + } > + } > + gdb_exit > + remote_file build delete $obj > + > + verbose "$me: returning $allow_cssc_tests" 2 > + return $allow_cssc_tests > +} > + > # Run a test on the target to see if it supports AArch64 MOPS (Memory > # Operations) extensions. Return 1 if so, 0 if it does not. Note this > # causes a restart of GDB.