]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2018-2024 Free Software Foundation, Inc. |
f5d420bb SM |
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 test verifies that we can read and write the value of a pseudo register | |
17 | # in unwound frames. For the test, we choose one raw register, rbx, and one | |
18 | # pseudo register that is backed by rbx, ebx. We have two frames (the inner one, | |
19 | # #0 and the outer one, #1) that each set a value for rbx. We verify that we | |
20 | # can read both rbx and ebx correctly for each frame, and that when we write to | |
21 | # ebx, rbx for that frame is correctly updated. | |
22 | ||
23 | if { ![istarget x86_64-*-* ] || ![is_lp64_target] } { | |
24 | verbose "Skipping amd64 pseudo register unwind." | |
25 | return | |
26 | } | |
27 | ||
28 | standard_testfile amd64-pseudo-unwind.c amd64-pseudo-unwind-asm.S | |
29 | ||
30 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
31 | "${srcfile} ${srcfile2}" {debug}] } { | |
32 | return -1 | |
33 | } | |
34 | ||
35 | clean_restart ${binfile} | |
36 | ||
37 | if ![runto_main] then { | |
38 | fail "could not run to main" | |
39 | } | |
40 | ||
41 | gdb_breakpoint break_here_asm temporary | |
42 | gdb_continue_to_breakpoint "continue to callee" | |
43 | ||
44 | # Verify the value of rbx/ebx in the inner frame (callee). | |
45 | with_test_prefix "callee, before change" { | |
46 | gdb_test "p/x \$rbx" " = 0x2021222324252627" | |
47 | gdb_test "p/x \$ebx" " = 0x24252627" | |
48 | } | |
49 | ||
50 | # Verify that we can change the value of the pseudo register (ebx) in the inner | |
51 | # frame (callee). | |
52 | gdb_test_no_output "set \$ebx = 0x34353637" | |
53 | ||
54 | # Verify the value of rbx/ebx in the inner frame (callee) after the change. | |
55 | with_test_prefix "callee, after change" { | |
56 | gdb_test "p/x \$rbx" " = 0x2021222334353637" | |
57 | gdb_test "p/x \$ebx" " = 0x34353637" | |
58 | } | |
59 | ||
60 | # Go up one frame, and do the same. | |
61 | gdb_test "up" | |
62 | ||
63 | # Verify the value of rbx/ebx in the outer frame (caller). | |
64 | with_test_prefix "caller, before change" { | |
65 | gdb_test "p/x \$rbx" " = 0x1011121314151617" | |
66 | gdb_test "p/x \$ebx" " = 0x14151617" | |
67 | } | |
68 | ||
69 | # Verify that we can change the value of the pseudo register (ebx) in the outer | |
70 | # frame (caller). | |
71 | gdb_test_no_output "set \$ebx = 0x44454647" | |
72 | ||
73 | # Verify the value of rbx/ebx in the outer frame (caller) after the change. | |
74 | with_test_prefix "caller, after change" { | |
75 | gdb_test "p/x \$rbx" " = 0x1011121344454647" | |
76 | gdb_test "p/x \$ebx" " = 0x44454647" | |
77 | } | |
78 | ||
79 | # Go back to frame 0 (callee), check that the change to the outer frame didn't | |
80 | # mess up anything there. | |
81 | gdb_test "down" | |
82 | with_test_prefix "callee, after change in caller" { | |
83 | gdb_test "p/x \$rbx" " = 0x2021222334353637" | |
84 | gdb_test "p/x \$ebx" " = 0x34353637" | |
85 | } | |
86 | ||
87 | # Verify that the value of the saved rbx we changed is correctly seen by the | |
88 | # inferior. | |
89 | gdb_breakpoint break_here_c temporary | |
90 | gdb_continue_to_breakpoint "continue to break_here_c" | |
91 | gdb_test "p/x value" " = 0x1011121344454647" |