From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id XW3zG5Nr7GngJzoAWB0awg (envelope-from ) for ; Sat, 25 Apr 2026 03:21:55 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=M5Mj1A+3; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5519E1E0BA; Sat, 25 Apr 2026 03:21:55 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, 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 356F31E067 for ; Sat, 25 Apr 2026 03:21:54 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id D1A084BB3BFA for ; Sat, 25 Apr 2026 07:21:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1A084BB3BFA Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=M5Mj1A+3 Received: from mail-dl1-x1229.google.com (mail-dl1-x1229.google.com [IPv6:2607:f8b0:4864:20::1229]) by sourceware.org (Postfix) with ESMTPS id CB2A84BAE7CA for ; Sat, 25 Apr 2026 07:21:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB2A84BAE7CA 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 CB2A84BAE7CA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1229 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777101687; cv=none; b=fcTh9TZ7erEgf737DXXm4h2Qz7LnHdt0b4TB7Ww0ZeNjHWTbWUhJtJcxlXEi3qNYDoiK9gxzxNnBnTs8txtY+GAnFqzkA7zb8Y27K7Wxv2Km5jdnleNZHIRnKmSfvM4LOtUsTOxkLezHPzGfYu3Gt0t1SU4WHgUj60SmMkBmQ+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777101687; c=relaxed/simple; bh=dJBJku+jUHWx2MVZjTzCZCj0yUOlDbiDdoiZ+UTqopo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uUQ9juL8UsijEzYVwKTbMLfbFCNTgUJ+9S/aijVG3wwY5DX5W5qDvxyaatNUSGOm4JE6MOCH/s9wWgkZL5scUxcSBGRKKk/pbkBpdFJiI6C2AhfyrczqZ9TAOGKOHFODnU0cqzgUVck8Rs95F0fGQLHWE70tpceH5eD6Jeb0y6A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB2A84BAE7CA Received: by mail-dl1-x1229.google.com with SMTP id a92af1059eb24-12c8ccc7755so8484583c88.0 for ; Sat, 25 Apr 2026 00:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1777101684; x=1777706484; darn=sourceware.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=TT7bLogtOrQfgEGYUXGSE1b9r1igiNo24biVisWc4KY=; b=M5Mj1A+31ZrSTOUewg0y647COPzD3VLeCrZaohn24P4I9eE/rF4S6FtzAAgC24NFVk MMxj1THEjEXqsU7ht5qQMxV4z03pxmuBDS1ZjZrlkkkYDQMlQs4eYml3HAs6kICeSJ7J dyosWhxH1dSHtETgt0w5aw+rzaYI32THfRRJdtA/y7NLYy8cBnpqx8+qOk+EmvpolXwH WccyziEcE8THrbXuLTrvQseQo8oBhpyIuBdzmEnOPhw+gIweq7/6QYR4iHGoK1PM4qKk WS/xHaVZZjgphfKXcdEh64+q1ri45fsLwkVY/bTE9hYEDdbu5xkcog6gYQM+hmjMzW9p UNZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777101684; x=1777706484; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=TT7bLogtOrQfgEGYUXGSE1b9r1igiNo24biVisWc4KY=; b=i3gCjgkbfeQVpLn6KeBGNJHmxROahe3vBnUuRo7INf6cBqcdmnImT+fgOL8B2i2jGn sw6l2BjDPrrIJHE0QzTQQsDS6dY6CKKVeAgWGiiN2SKQ8oHn+quUy5aJVnFJZwWAB9D2 Aaag1pYrDZcXgRKzBaO1F93PTrJT7N0hyUBxu2ggoVxxZOAnLwijRBBEAx744Fm77ekN CcamlQKwZgptoI3EAIgJZpJXGFIC9sNg3q8BF4ATYurELaw/WPQegJ6x5YUoWj5CH6hd SLHd5JRLr5+uvxHY4UyOvT/KFBiSoKYNlSirBQ5FQy+vJbOfq5fyKzaTtOvFDRSq1sS8 gVSA== X-Gm-Message-State: AOJu0YzZ/zWF1hX3A1+bMOc3kIdwvI9CeslqWJENZEZ2JdKQqZkZ4xae tGEwyNO+YPSnkMzw8c1nyOafyk2A2okBGjr1rfLsYPYxwQYWMqtFdJOxFI6gVJ3TEVo= X-Gm-Gg: AeBDiet7TLMopWBZDqvdQj3qE/JDQD5U6vWC4jk0Fsx4FgOlnlZf9oS1Rg3J1Aauknw P5A91fZ1SCEiCaxUq+UcwHaq7zrGi1A8eX6TMCTYNtnNqlX32UocFvp5jUHktq6ha4Oe/ZSEZZN lqRFQT5R1QJL6OFK9O34y1K5o1vsz5IdFMRqoNdT49HAL9QALa8MEvRvWQnNcxY4cdpdbN7y5On XBprYJGV2xIJ5/9z6weNZbx5OzeU/5gjoE8xFHl5tK8d6DsBGKvHNEMRLjMiCVaoJroVHCe1A3t j0h8t/ppasTcg/T16XfMwmy/14WjA44FGgXI6tzh6YPe206n/mG2WlcZbs+FYazenBqn8W0Mcn+ 4i4W+O2j8WHa1C9AxBqlQ4hD6nXCxxMzBIGPqBWznbgthU/LUVzus6Trem+hUyZbYk6JClxd/VN GYdBevJGh4zXOMhPdB/jMHfY8WnyTC9eOFoi72XyKz0iTR X-Received: by 2002:a05:7022:11c:b0:128:d3de:c9e4 with SMTP id a92af1059eb24-12c73f9da5amr18177937c88.30.1777101684191; Sat, 25 Apr 2026 00:21:24 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12dca2c1c16sm4244835c88.5.2026.04.25.00.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Apr 2026 00:21:23 -0700 (PDT) From: Thiago Jung Bauermann To: Cc: , Subject: Re: [PATCH 1/4] gdb/aarch64: record/replay support for LRCPC3 In-Reply-To: <20260420215232.68675-2-Ezra.Sitorus@arm.com> (Ezra Sitorus's message of "Mon, 20 Apr 2026 22:52:29 +0100") References: <20260420215232.68675-1-Ezra.Sitorus@arm.com> <20260420215232.68675-2-Ezra.Sitorus@arm.com> User-Agent: mu4e 1.14.0; emacs 30.2 Date: Sat, 25 Apr 2026 04:21:21 -0300 Message-ID: <874ikzbj4e.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain 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 Hello again, It turns out I do have a couple more comments on this. writes: > +proc test_single_asm {name diff_reg diff_var diff_mem same_reg same_var same_mem} { > + global decimal hex > + > + set before_seq [gdb_get_line_number "Before ${name}"] > + set after_seq [gdb_get_line_number "After ${name}"] > + > + set insn [lindex [split $name "-"] 0] > + > + gdb_test "break $before_seq" \ > + "Breakpoint $decimal at $hex: file .*/aarch64-lrcpc3.c, line $decimal\\." \ > + "$name: break before instruction sequence" > + gdb_continue_to_breakpoint "$name: about to execute instruction sequence" \ > + [multi_line ".*/aarch64-lrcpc3.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-lrcpc3.c, line $decimal\\." \ > + "$name: break at prologue instruction" > + > + # Record the initial memory and register values. > + set regs [concat $diff_reg $same_reg] > + set vars [concat $diff_var $same_var] > + set mem [concat $diff_mem $same_mem] > + foreach r $regs { > + set ${r}_initial [capture_command_output "info register $r" ""] > + } > + foreach v $vars { > + set ${v}_initial [get_valueof "/x" "$v" "unable to read $v" \ > + "$name: get $v initial value"] > + } > + foreach m $mem { > + set ${m}_initial [capture_command_output "x/x $m" ""] > + } > + > + gdb_test "break $after_seq" \ > + "Breakpoint $decimal at $hex: file .*/aarch64-lrcpc3.c, line $decimal\\." \ > + "$name: break after instruction sequence" > + gdb_continue_to_breakpoint "$name: executed instruction sequence" \ > + [multi_line ".*/aarch64-lrcpc3.c:$decimal" ".*"] > + > + # Record the new memory and register values. > + foreach r $regs { > + set ${r}_new [capture_command_output "info register $r" ""] > + } > + foreach v $vars { > + set ${v}_new [get_valueof "/x" "$v" "unable to read $v" \ > + "$name: get $v new value"] > + } > + foreach m $mem { > + set ${m}_new [capture_command_output "x/x $m" ""] > + } > + > + # Execute in reverse to before the instruction sequence. > + gdb_test_no_output "set exec-direction reverse" This message will be the same for all calls of test_single_arm, causing DUPLICATE errors. > + gdb_continue_to_breakpoint "reversed execution of instruction sequence" \ > + [multi_line ".*/aarch64-lrcpc3.c:$decimal" \ > + "$decimal\[ \t\]+__asm__ volatile \\(\"${insn} \[^\r\n\]+\""] Same here. > + # Record the final memory and register values. > + foreach r $regs { > + set ${r}_final [capture_command_output "info register $r" ""] > + } > + foreach v $vars { > + set ${v}_final [get_valueof "/x" "$v" "unable to read $v" \ > + "$name: get $v final value"] > + } > + foreach m $mem { > + set ${m}_final [capture_command_output "x/x $m" ""] > + } > + > + foreach v [concat $same_reg $same_var $same_mem] { > + gdb_assert ![string compare [set ${v}_initial] [set ${v}_new]] \ > + "$name: check $v initial value versus $v new value" > + gdb_assert ![string compare [set ${v}_initial] [set ${v}_final]] \ > + "$name: check $v initial value versus $v final value" > + } > + > + foreach v [concat $diff_reg $diff_var $diff_mem] { > + gdb_assert [string compare [set ${v}_initial] [set ${v}_new]] \ > + "$name: check $v initial value versus $v new value" > + gdb_assert ![string compare [set ${v}_initial] [set ${v}_final]] \ > + "$name: check $v initial value versus $v final 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-lrcpc3.c:$decimal" \ > + ".*"] The two tests above will also cause DUPLICATE errors. Instead of manually adding $name to test names to differentiate between calls of test_single_asm, I suggest wrapping the whole body of this function in with_test_prefix $name { ... }. This will make sure all of them are covered. > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 28709004570..c6afc556548 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -5287,6 +5287,69 @@ gdb_caching_proc allow_aarch64_fpmr_tests {} { > return $allow_fpmr_tests > } > > +# Run a test on the target to see if it supports AArch64 LRCPC3 (Load-Acquire > +# RCpc instructions) extensions. Return 1 if so, 0 if it does not. Note this > +# causes a restart of GDB. > + > +gdb_caching_proc allow_aarch64_lrcpc3_tests {} { > + global srcdir subdir gdb_prompt inferior_exited_re > + > + set me "allow_aarch64_lrcpc3_tests" > + > + if { ![is_aarch64_target] } { > + return 0 > + } > + > + # Take the opportunity to check whether the toolchain knows about LRCPC3. > + set compile_flags "{additional_flags=-march=armv8-a+rcpc3}" > + > + # Compile a program that tests the LRCPC3 feature. > + set src { > + #include > + > + int main() { > + uint64_t a, b = 0; > + uint64_t *ptr; > + *ptr = 0xdeadbeef; I don't understand what the line above is intended to do. It just crashes the test program and causes the gdb_expect below to take the default case, before the ldiapp instruction has a chance to be executed: (gdb) run Starting program: /home/bauermann/.cache/builds/gdb-native/gdb/testsuite/temp/1360/allow_aarch64_lrcpc3_tests.x [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/aarch64-linux-gnu/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0x0000aaaaaaaa077c in main () at /home/bauermann/.cache/builds/gdb-native/gdb/testsuite/temp/1360/allow_aarch64_lrcpc3_tests.c:7 warning: 7 /home/bauermann/.cache/builds/gdb-native/gdb/testsuite/temp/1360/allow_aarch64_lrcpc3_tests.c: No such file or directory (gdb) WARNING: allow_aarch64_lrcpc3_tests: default case taken gdb_caching_proc allow_aarch64_lrcpc3_tests caused gdb_exit to be called gdb_caching_proc allow_aarch64_lrcpc3_tests marked as called gdb_caching_proc get_compiler_info_1 marked as called gdb_caching_proc is_aarch32_target marked as called gdb_caching_proc universal_compile_options_c marked as called UNSUPPORTED: gdb.reverse/aarch64-lrcpc3.exp: require failed: allow_aarch64_lrcpc3_tests If I make ptr point to a new variable c, then I get the expected SIGILL when running in a machine which doesn't support LRCPC3. > + __asm__ volatile ("ldiapp %0, %1, [%2]\n" > + : "=r"(a), "=r"(b) > + : "r"(ptr) > + : "memory"); > + > + 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 lrcpc3 support not detected" > + set allow_lrcpc3_tests 0 > + } > + -re ".*$inferior_exited_re normally.*${gdb_prompt} $" { > + verbose -log "\n$me: lrcpc3 support detected" > + set allow_lrcpc3_tests 1 > + } > + default { > + warning "\n$me: default case taken" > + set allow_lrcpc3_tests 0 > + } > + } > + gdb_exit > + remote_file build delete $obj > + > + verbose "$me: returning $allow_lrcpc3_tests" 2 > + return $allow_lrcpc3_tests > +} -- Thiago