]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2017-2024 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 | ||
d9050fb8 | 18 | require is_aarch64_target |
a738ea1d YQ |
19 | |
20 | standard_testfile | |
21 | if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { | |
22 | return -1 | |
23 | } | |
24 | ||
25 | if ![runto_main] { | |
a738ea1d YQ |
26 | return -1 |
27 | } | |
28 | ||
29 | gdb_breakpoint [gdb_get_line_number "breakpoint here"] | |
30 | gdb_continue_to_breakpoint "breakpoint here" | |
31 | ||
32 | # Test that GDB manages caches correctly for tagged address. | |
33 | # Read from P2, | |
c2b75043 | 34 | gdb_test "x p2" "$hex:\[\t \]+0x000004d2" "x p2" |
a738ea1d YQ |
35 | gdb_test_no_output "set variable i = 5678" |
36 | # Test that *P2 is updated. | |
c2b75043 | 37 | gdb_test "x p2" "$hex:\[\t \]+0x0000162e" "x p2, updated" |
a738ea1d YQ |
38 | |
39 | # Read from SP1->i, | |
c2b75043 | 40 | gdb_test "print sp1->i" " = 1234" "print SP1->i" |
a738ea1d YQ |
41 | # Write to SP2->i, |
42 | gdb_test_no_output "set variable sp2->i = 5678" | |
43 | # Test that SP1->i is updated. | |
c2b75043 | 44 | gdb_test "print sp1->i" " = 5678" "print SP1->i, updated" |
a738ea1d YQ |
45 | |
46 | gdb_test "x/d &sp2->i" "$hex:\[\t \]+5678" | |
47 | gdb_test "x/d &sp1->i" "$hex:\[\t \]+5678" | |
48 | ||
49 | # Test that the same disassembly is got when disassembling function vs | |
50 | # tagged function pointer. | |
51 | set insn1 "" | |
52 | set insn2 "" | |
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) | |
58 | pass $test | |
59 | } | |
60 | } | |
61 | ||
62 | gdb_test "disassemble func_ptr,+8" \ | |
63 | ":\[\t \]+$insn1\[ \r\n\]+.*:\[\t \]+$insn2.*" | |
a0de8c21 YQ |
64 | |
65 | foreach_with_prefix bptype {"hbreak" "break"} { | |
66 | ||
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, | |
72 | gdb_test "continue" \ | |
73 | "Continuing\\..*Breakpoint \[0-9\]+, foo \\(\\) at .*" \ | |
74 | "run until breakpoint set *func_ptr" | |
75 | gdb_test "up" "foo \\(\\).*" "caller is foo" | |
76 | delete_breakpoints | |
77 | ||
78 | # Set a breakpoint on normal function, call it through tagged | |
79 | # function pointer. | |
80 | gdb_test "$bptype foo" "reakpoint $decimal at .*" \ | |
81 | "hardware breakpoint at foo" | |
82 | gdb_test "continue" \ | |
83 | "Continuing\\..*Breakpoint \[0-9\]+, foo \\(\\) at .*" \ | |
84 | "run until breakpoint set foo" | |
85 | gdb_test "up" "\\(\*func_ptr\\) \\(\\).*" "caller is *func_ptr" | |
86 | delete_breakpoints | |
87 | } | |
f17d9474 YQ |
88 | |
89 | gdb_test "down" | |
90 | gdb_test "finish" | |
f17d9474 | 91 | |
19007d95 LM |
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: | |
94 | # | |
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" | |
107 | delete_breakpoints | |
108 | } |