1 # Copyright
2018-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 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.
23 if { ![istarget x86_64
-*-* ] ||
![is_lp64_target
] } {
24 verbose
"Skipping amd64 pseudo register unwind."
28 standard_testfile amd64
-pseudo
-unwind.c amd64
-pseudo
-unwind
-asm.S
30 if { [prepare_for_testing
"failed to prepare" ${testfile} \
31 "${srcfile} ${srcfile2}" {debug}] } {
35 clean_restart $
{binfile
}
41 gdb_breakpoint break_here_asm temporary
42 gdb_continue_to_breakpoint
"continue to callee"
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"
50 # Verify that we can change the value of the pseudo register
(ebx
) in the inner
52 gdb_test_no_output
"set \$ebx = 0x34353637"
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"
60 # Go up one frame
, and
do the same.
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"
69 # Verify that we can change the value of the pseudo register
(ebx
) in the outer
71 gdb_test_no_output
"set \$ebx = 0x44454647"
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"
79 # Go
back to frame
0 (callee
), check that the change to the outer frame didn
't
80 # mess up anything there.
82 with_test_prefix "callee, after change in caller" {
83 gdb_test "p/x \$rbx" " = 0x2021222334353637"
84 gdb_test "p/x \$ebx" " = 0x34353637"
87 # Verify that the value of the saved rbx we changed is correctly seen by the
89 gdb_breakpoint break_here_c temporary
90 gdb_continue_to_breakpoint "continue to break_here_c"
91 gdb_test "p/x value" " = 0x1011121344454647"