aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch
diff options
context:
space:
mode:
authorLuis Machado <luis.machado@arm.com>2022-09-15 15:57:01 +0100
committerLuis Machado <luis.machado@arm.com>2022-10-03 14:15:25 +0100
commite63ae49b6a87b779714c1dc922479a76882af977 (patch)
tree277a4f3a11d57617d7020e5c0b5e96b18aab08ac /gdb/testsuite/gdb.arch
parent1ba3a3222039eb2576d29c9fd3af444f59fa51d2 (diff)
downloadfsf-binutils-gdb-e63ae49b6a87b779714c1dc922479a76882af977.zip
fsf-binutils-gdb-e63ae49b6a87b779714c1dc922479a76882af977.tar.gz
fsf-binutils-gdb-e63ae49b6a87b779714c1dc922479a76882af977.tar.bz2
[AArch64] Handle W registers as pseudo-registers instead of aliases of X registers
The aarch64 port handles W registers as aliases of X registers. This is incorrect because X registers are 64-bit and W registers are 32-bit. This patch teaches GDB how to handle W registers as pseudo-registers of 32-bit, the bottom half of the X registers. Testcase included.
Diffstat (limited to 'gdb/testsuite/gdb.arch')
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-w-registers.c22
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-w-registers.exp100
2 files changed, 122 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.arch/aarch64-w-registers.c b/gdb/testsuite/gdb.arch/aarch64-w-registers.c
new file mode 100644
index 0000000..7d12a20
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-w-registers.c
@@ -0,0 +1,22 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2022 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 <http://www.gnu.org/licenses/>. */
+
+int
+main ()
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-w-registers.exp b/gdb/testsuite/gdb.arch/aarch64-w-registers.exp
new file mode 100644
index 0000000..72711fe
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-w-registers.exp
@@ -0,0 +1,100 @@
+# Copyright (C) 2022 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 <http://www.gnu.org/licenses/>.
+
+# Check if the W registers have the expected size and if setting/fetching
+# values from W registers works correctly for both big and little endian.
+
+if {![is_aarch64_target]} {
+ verbose "Skipping ${gdb_test_file_name}."
+ return
+}
+
+standard_testfile
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile {nodebug}]} {
+ return -1
+}
+
+if ![runto_main] {
+ untested "could not run to main"
+ return -1
+}
+
+array set w_values {
+ 0 0x0
+ 1 0x10
+ 2 0x2010
+ 3 0x302010
+ 4 0x40302010
+ 5 0x40302010
+ 6 0x40302010
+ 7 0x40302010
+ 8 0x40302010
+}
+
+array set x_values {
+ 0 0x0
+ 1 0x10
+ 2 0x2010
+ 3 0x302010
+ 4 0x40302010
+ 5 0x5040302010
+ 6 0x605040302010
+ 7 0x70605040302010
+ 8 0x8070605040302010
+}
+
+# Exercise various things for register w<rn>
+
+proc test_register { rn } {
+ gdb_test "ptype \$w${rn}" "type = uint32_t"
+ gdb_test "p sizeof(\$w${rn})" " = 4"
+
+ # Set all bits of x<rn>
+ gdb_test_no_output "set \$x${rn}=0xffffffffffffffff" \
+ "set all bits of x${rn}"
+
+ # Test setting/fetching values
+ for {set i 0} {$i < 9} {incr i} {
+ global w_values
+ global x_values
+
+ with_test_prefix "set w${rn} to $x_values($i)" {
+ # Set value of W and see the effects on W and X.
+ gdb_test_no_output "set \$w${rn}=$x_values($i)"
+ gdb_test "p/x \$w${rn}" "= $w_values($i)"
+ gdb_test "p/x \$x${rn}" "= $w_values($i)"
+ }
+
+ with_test_prefix "set x${rn} to $x_values($i)" {
+ # Set value of X and see the effects on W and X.
+ gdb_test_no_output "set \$x${rn}=$x_values($i)"
+ gdb_test "p/x \$w${rn}" "= $w_values($i)"
+ gdb_test "p/x \$x${rn}" "= $x_values($i)"
+
+ # Set all bits of x<rn>
+ gdb_test_no_output "set \$x${rn}=0xffffffffffffffff" \
+ "set all bits of x${rn}"
+ }
+ }
+}
+
+# Run tests
+foreach_with_prefix endian {"little" "big"} {
+ gdb_test "set endian ${endian}" "The target is set to ${endian} endian\."
+
+ for {set i 0} {$i < 31} {incr i} {
+ test_register $i
+ }
+}