Home | History | Annotate | Line # | Download | only in gdb.arch
      1 # Copyright 2018-2024 Free Software Foundation, Inc.
      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 is equivalent to amd64-pseudo-unwind, but specific to ARM.  We
     17 # use the raw register d8 which is 64 bits long.  We use pseudo register s16,
     18 # which is the low 32 bits of d8.
     19 
     20 if { ![istarget arm*-*-* ] } {
     21     verbose "Skipping arm pseudo register unwind."
     22     return
     23 }
     24 
     25 standard_testfile arm-pseudo-unwind.c arm-pseudo-unwind-asm.S
     26 
     27 if { [prepare_for_testing "failed to prepare" ${testfile} \
     28 	"${srcfile} ${srcfile2}" {debug additional_flags=-marm}] } {
     29     return -1
     30 }
     31 
     32 clean_restart ${binfile}
     33 
     34 if ![runto_main] then {
     35     fail "could not run to main"
     36 }
     37 
     38 gdb_breakpoint break_here_asm temporary
     39 gdb_continue_to_breakpoint "continue to callee"
     40 
     41 # Verify the value of d8/s16 in the inner frame (callee).
     42 with_test_prefix "callee, before change" {
     43     gdb_test "p/x \$d8" " = 0x2021222324252627"
     44     gdb_test "p/x \$s16" " = 0x24252627"
     45 }
     46 
     47 # Verify that we can change the value of the pseudo register (s16) in the inner
     48 # frame (callee).
     49 gdb_test_no_output "set \$s16 = 1.0"
     50 
     51 # Verify the value of d8/s16 in the inner frame (callee) after the change.
     52 with_test_prefix "callee, after change" {
     53     gdb_test "p/x \$d8" " = 0x202122233f800000"
     54     gdb_test "p/x \$s16" " = 0x3f800000"
     55 }
     56 
     57 # Go up one frame (to caller), and do the same.
     58 gdb_test "up"
     59 
     60 # Verify the value of d8/s16 in the outer frame (caller).
     61 with_test_prefix "caller, before change" {
     62     gdb_test "p/x \$d8" " = 0x1011121314151617"
     63     gdb_test "p/x \$s16" " = 0x14151617"
     64 }
     65 
     66 # Verify that we can change the value of the pseudo register (s16) in the outer
     67 # frame (caller).
     68 gdb_test_no_output "set \$s16 = 2.0"
     69 
     70 # Verify the value of d8/s16 in the outer frame (caller) after the change.
     71 with_test_prefix "caller, after change" {
     72     gdb_test "p/x \$d8" " = 0x1011121340000000"
     73     gdb_test "p/x \$s16" " = 0x40000000"
     74 }
     75 
     76 # Go back to frame 0 (callee), check that the change to the outer frame didn't
     77 # mess up anything there.
     78 gdb_test "down"
     79 with_test_prefix "callee, after change in caller" {
     80     gdb_test "p/x \$d8" " = 0x202122233f800000"
     81     gdb_test "p/x \$s16" " = 0x3f800000"
     82 }
     83 
     84 # Verify that the value of the saved d8 we changed is correctly seen by the
     85 # inferior.
     86 gdb_breakpoint break_here_c temporary
     87 gdb_continue_to_breakpoint "continue to break_here_c"
     88 gdb_test "p/x value" " = 0x1011121340000000"
     89