]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp
Fix some duplicate test names
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / aarch64-tagged-pointer.exp
1 # Copyright 2017-2020 Free Software Foundation, Inc.
2 #
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.
7 #
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.
12 #
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/>.
15 #
16 # This file is part of the gdb testsuite.
17
18 if {![is_aarch64_target]} {
19 verbose "Skipping ${gdb_test_file_name}."
20 return
21 }
22
23 standard_testfile
24 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
25 return -1
26 }
27
28 if ![runto_main] {
29 untested "could not run to main"
30 return -1
31 }
32
33 gdb_breakpoint [gdb_get_line_number "breakpoint here"]
34 gdb_continue_to_breakpoint "breakpoint here"
35
36 # Test that GDB manages caches correctly for tagged address.
37 # Read from P2,
38 gdb_test "x p2" "$hex:\[\t \]+0x000004d2" "x p2"
39 gdb_test_no_output "set variable i = 5678"
40 # Test that *P2 is updated.
41 gdb_test "x p2" "$hex:\[\t \]+0x0000162e" "x p2, updated"
42
43 # Read from SP1->i,
44 gdb_test "print sp1->i" " = 1234" "print SP1->i"
45 # Write to SP2->i,
46 gdb_test_no_output "set variable sp2->i = 5678"
47 # Test that SP1->i is updated.
48 gdb_test "print sp1->i" " = 5678" "print SP1->i, updated"
49
50 gdb_test "x/d &sp2->i" "$hex:\[\t \]+5678"
51 gdb_test "x/d &sp1->i" "$hex:\[\t \]+5678"
52
53 # Test that the same disassembly is got when disassembling function vs
54 # tagged function pointer.
55 set insn1 ""
56 set insn2 ""
57 set test "disassemble foo,+8"
58 gdb_test_multiple $test $test {
59 -re ":\[\t \]+(\[a-z\]*)\[ \r\n\]+.*:\[\t \]+(\[a-z\]*).*$gdb_prompt $" {
60 set insn1 $expect_out(1,string)
61 set insn2 $expect_out(2,string)
62 pass $test
63 }
64 }
65
66 gdb_test "disassemble func_ptr,+8" \
67 ":\[\t \]+$insn1\[ \r\n\]+.*:\[\t \]+$insn2.*"
68
69 foreach_with_prefix bptype {"hbreak" "break"} {
70
71 # Set a breakpoint on a tagged address, func_ptr,
72 gdb_test "$bptype *func_ptr" \
73 "warning: Breakpoint address adjusted from .*reakpoint $decimal at .*" \
74 "breakpoint at *func_ptr"
75 # Resume the program and expect it hits foo,
76 gdb_test "continue" \
77 "Continuing\\..*Breakpoint \[0-9\]+, foo \\(\\) at .*" \
78 "run until breakpoint set *func_ptr"
79 gdb_test "up" "foo \\(\\).*" "caller is foo"
80 delete_breakpoints
81
82 # Set a breakpoint on normal function, call it through tagged
83 # function pointer.
84 gdb_test "$bptype foo" "reakpoint $decimal at .*" \
85 "hardware breakpoint at foo"
86 gdb_test "continue" \
87 "Continuing\\..*Breakpoint \[0-9\]+, foo \\(\\) at .*" \
88 "run until breakpoint set foo"
89 gdb_test "up" "\\(\*func_ptr\\) \\(\\).*" "caller is *func_ptr"
90 delete_breakpoints
91 }
92
93 gdb_test "down"
94 gdb_test "finish"
95 # Watch on tagged pointer.
96 gdb_test "watch *sp2"
97 gdb_test "continue" \
98 "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \
99 "run until watchpoint on s1"
100 delete_breakpoints
101
102 gdb_test "watch *p2"
103 gdb_test "continue" \
104 "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \
105 "run until watchpoint on i"