Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2017-2022 Free Software Foundation, Inc. |
a738ea1d YQ |
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, | |
c2b75043 | 38 | gdb_test "x p2" "$hex:\[\t \]+0x000004d2" "x p2" |
a738ea1d YQ |
39 | gdb_test_no_output "set variable i = 5678" |
40 | # Test that *P2 is updated. | |
c2b75043 | 41 | gdb_test "x p2" "$hex:\[\t \]+0x0000162e" "x p2, updated" |
a738ea1d YQ |
42 | |
43 | # Read from SP1->i, | |
c2b75043 | 44 | gdb_test "print sp1->i" " = 1234" "print SP1->i" |
a738ea1d YQ |
45 | # Write to SP2->i, |
46 | gdb_test_no_output "set variable sp2->i = 5678" | |
47 | # Test that SP1->i is updated. | |
c2b75043 | 48 | gdb_test "print sp1->i" " = 5678" "print SP1->i, updated" |
a738ea1d YQ |
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.*" | |
a0de8c21 YQ |
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 | } | |
f17d9474 YQ |
92 | |
93 | gdb_test "down" | |
94 | gdb_test "finish" | |
f17d9474 | 95 | |
19007d95 LM |
96 | # sp1 and p1 are untagged pointers, but sp2 and p2 are tagged pointers. |
97 | # Cycle through all of them to make sure the following combinations work: | |
98 | # | |
99 | # hw watch on untagged address, hit on untagged address. | |
100 | # hw watch on tagged address, hit on untagged address. | |
101 | # hw watch on untagged address, hit on tagged address. | |
102 | # hw watch on tagged address, hit on tagged address. | |
103 | foreach symbol {"sp1" "sp2" "p1" "p2"} { | |
104 | gdb_test "watch *${symbol}" | |
105 | gdb_test "continue" \ | |
106 | "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \ | |
107 | "run until watchpoint on ${symbol}" | |
108 | gdb_test "continue" \ | |
109 | "Continuing\\..*Hardware watchpoint \[0-9\]+.*" \ | |
110 | "run until watchpoint on ${symbol}, 2nd hit" | |
111 | delete_breakpoints | |
112 | } |