]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp
gas: ginsn: remove unnecessary buffer allocation and free
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / amd64-pseudo-unwind.exp
CommitLineData
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
23if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
24 verbose "Skipping amd64 pseudo register unwind."
25 return
26}
27
28standard_testfile amd64-pseudo-unwind.c amd64-pseudo-unwind-asm.S
29
30if { [prepare_for_testing "failed to prepare" ${testfile} \
31 "${srcfile} ${srcfile2}" {debug}] } {
32 return -1
33}
34
35clean_restart ${binfile}
36
37if ![runto_main] then {
38 fail "could not run to main"
39}
40
41gdb_breakpoint break_here_asm temporary
42gdb_continue_to_breakpoint "continue to callee"
43
44# Verify the value of rbx/ebx in the inner frame (callee).
45with_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).
52gdb_test_no_output "set \$ebx = 0x34353637"
53
54# Verify the value of rbx/ebx in the inner frame (callee) after the change.
55with_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.
61gdb_test "up"
62
63# Verify the value of rbx/ebx in the outer frame (caller).
64with_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).
71gdb_test_no_output "set \$ebx = 0x44454647"
72
73# Verify the value of rbx/ebx in the outer frame (caller) after the change.
74with_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.
81gdb_test "down"
82with_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.
89gdb_breakpoint break_here_c temporary
90gdb_continue_to_breakpoint "continue to break_here_c"
91gdb_test "p/x value" " = 0x1011121344454647"