1 # Copyright 2017-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This file is part of the gdb testsuite.
18 require is_aarch64_target
21 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
29 gdb_breakpoint [gdb_get_line_number "breakpoint here"]
30 gdb_continue_to_breakpoint "breakpoint here"
32 # Test that GDB manages caches correctly for tagged address.
34 gdb_test "x p2" "$hex:\[\t \]+0x000004d2" "x p2"
35 gdb_test_no_output "set variable i = 5678"
36 # Test that *P2 is updated.
37 gdb_test "x p2" "$hex:\[\t \]+0x0000162e" "x p2, updated"
40 gdb_test "print sp1->i" " = 1234" "print SP1->i"
42 gdb_test_no_output "set variable sp2->i = 5678"
43 # Test that SP1->i is updated.
44 gdb_test "print sp1->i" " = 5678" "print SP1->i, updated"
46 gdb_test "x/d &sp2->i" "$hex:\[\t \]+5678"
47 gdb_test "x/d &sp1->i" "$hex:\[\t \]+5678"
49 # Test that the same disassembly is got when disassembling function vs
50 # tagged function pointer.
53 set test "disassemble foo,+8"
54 gdb_test_multiple $test $test {
55 -re ":\[\t \]+(\[a-z\]*)\[ \r\n\]+.*:\[\t \]+(\[a-z\]*).*$gdb_prompt $" {
56 set insn1 $expect_out(1,string)
57 set insn2 $expect_out(2,string)
62 gdb_test "disassemble func_ptr,+8" \
63 ":\[\t \]+$insn1\[ \r\n\]+.*:\[\t \]+$insn2.*"
65 foreach_with_prefix bptype {"hbreak" "break"} {
67 # Set a breakpoint on a tagged address, func_ptr,
68 gdb_test "$bptype *func_ptr" \
69 "warning: Breakpoint address adjusted from .*reakpoint $decimal at .*" \
70 "breakpoint at *func_ptr"
71 # Resume the program and expect it hits foo,
73 "Continuing\\..*Breakpoint \[0-9\]+, foo \\(\\) at .*" \
74 "run until breakpoint set *func_ptr"
75 gdb_test "up" "foo \\(\\).*" "caller is foo"
78 # Set a breakpoint on normal function, call it through tagged
80 gdb_test "$bptype foo" "reakpoint $decimal at .*" \
81 "hardware breakpoint at foo"
83 "Continuing\\..*Breakpoint \[0-9\]+, foo \\(\\) at .*" \
84 "run until breakpoint set foo"
85 gdb_test "up" "\\(\*func_ptr\\) \\(\\).*" "caller is *func_ptr"
92 # sp1 and p1 are untagged pointers, but sp2 and p2 are tagged pointers.
93 # Cycle through all of them to make sure the following combinations work:
95 # hw watch on untagged address, hit on untagged address.
96 # hw watch on tagged address, hit on untagged address.
97 # hw watch on untagged address, hit on tagged address.
98 # hw watch on tagged address, hit on tagged address.
99 foreach symbol {"sp1" "sp2" "p1" "p2"} {
100 gdb_test "watch *${symbol}"
101 gdb_test "continue" \
102 "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \
103 "run until watchpoint on ${symbol}"
104 gdb_test "continue" \
105 "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \
106 "run until watchpoint on ${symbol}, 2nd hit"