1 # Copyright 2022-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 file is part of the gdb testsuite.
18 # Test explicitly unwinding the PC DWARF register on aarch64
20 require is_aarch64_target
24 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
32 proc test_reg_vals {} {
33 gdb_test "p \$pc - &main" "= 8" "p \$pc"
34 gdb_test "p/x \$x30" "= 0x1234" "p \$x30"
37 proc test_unwind_pc { inst } {
38 gdb_test "si" "$inst" "single step"
39 gdb_test "backtrace" \
40 ".*#1.*in main ().*" \
42 gdb_test "up" "in main ().*" "parent frame"
46 # Ready to enter the function
47 gdb_test "si" "bl test_func" "call site"
48 # Step through the 3 instructions in the function to make sure that
49 # we have the same unwind info throughout.
50 with_test_prefix "1st stepi" {
51 test_unwind_pc "mov x0, x30"
53 with_test_prefix "2nd stepi" {
54 test_unwind_pc "mov x30, 0x1234"
56 with_test_prefix "3rd stepi" {
57 test_unwind_pc "ret x0"
59 # Check again after we returned
60 with_test_prefix "final" {
61 # Check that we've stepped out (si prints out the new function name)
62 gdb_test "si" ".*main *().*" "single step out"
63 gdb_test "backtrace" \
64 "#0\[\t \]+main ().*" \