Home | History | Annotate | Line # | Download | only in gdb.arch
      1  1.1  christos # Copyright 2018-2024 Free Software Foundation, Inc.
      2  1.1  christos 
      3  1.1  christos # This program is free software; you can redistribute it and/or modify
      4  1.1  christos # it under the terms of the GNU General Public License as published by
      5  1.1  christos # the Free Software Foundation; either version 3 of the License, or
      6  1.1  christos # (at your option) any later version.
      7  1.1  christos #
      8  1.1  christos # This program is distributed in the hope that it will be useful,
      9  1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  1.1  christos # GNU General Public License for more details.
     12  1.1  christos #
     13  1.1  christos # You should have received a copy of the GNU General Public License
     14  1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  1.1  christos 
     16  1.1  christos # This test is in the same vein as amd64-pseudo-unwind, making sure we can
     17  1.1  christos # read write pseudo registers in outer frames.  However, it tests a special
     18  1.1  christos # case where the debug info includes unwind information for a pseudo register
     19  1.1  christos # but not the underlying raw register.  This can happen for the pseudo register
     20  1.1  christos # s16, which is the bottom half of the raw register d8.
     21  1.1  christos #
     22  1.1  christos # See "DWARF for the ARM architecture":
     23  1.1  christos #   https://github.com/ARM-software/abi-aa/releases/download/2023Q3/aadwarf32.pdf
     24  1.1  christos 
     25  1.1  christos if { ![istarget arm*-*-* ] } {
     26  1.1  christos     verbose "Skipping arm pseudo register unwind."
     27  1.1  christos     return
     28  1.1  christos }
     29  1.1  christos 
     30  1.1  christos standard_testfile arm-pseudo-unwind-legacy.c arm-pseudo-unwind-legacy-asm.S
     31  1.1  christos 
     32  1.1  christos if { [prepare_for_testing "failed to prepare" ${testfile} \
     33  1.1  christos 	"${srcfile} ${srcfile2}" {debug additional_flags=-marm}] } {
     34  1.1  christos     return -1
     35  1.1  christos }
     36  1.1  christos 
     37  1.1  christos clean_restart ${binfile}
     38  1.1  christos 
     39  1.1  christos if ![runto_main] then {
     40  1.1  christos     fail "could not run to main"
     41  1.1  christos }
     42  1.1  christos 
     43  1.1  christos gdb_breakpoint break_here_asm temporary
     44  1.1  christos gdb_continue_to_breakpoint "continue to callee"
     45  1.1  christos 
     46  1.1  christos # Verify the value of s16 in the inner frame (callee).
     47  1.1  christos with_test_prefix "callee, before change" {
     48  1.1  christos     gdb_test "p/x \$s16" " = 0x20212223"
     49  1.1  christos }
     50  1.1  christos 
     51  1.1  christos # Verify that we can change the value of s16 in the inner frame (callee).
     52  1.1  christos gdb_test_no_output "set \$s16 = 1.0"
     53  1.1  christos 
     54  1.1  christos # Verify the value of s16 in the inner frame (callee) after the change.
     55  1.1  christos with_test_prefix "callee, after change" {
     56  1.1  christos     gdb_test "p/x \$s16" " = 0x3f800000"
     57  1.1  christos }
     58  1.1  christos 
     59  1.1  christos # Go up one frame, and do the same.
     60  1.1  christos gdb_test "up"
     61  1.1  christos 
     62  1.1  christos # Verify the value of s16 in the outer frame (caller).
     63  1.1  christos with_test_prefix "caller, before change" {
     64  1.1  christos     gdb_test "p/x \$s16" " = 0x10111213"
     65  1.1  christos }
     66  1.1  christos 
     67  1.1  christos # Verify that we can change the value of s16 in the outer frame (caller).
     68  1.1  christos gdb_test_no_output "set \$s16 = 2.0"
     69  1.1  christos 
     70  1.1  christos # Verify the value of s16 in the outer frame (caller) after the change.
     71  1.1  christos with_test_prefix "caller, after change" {
     72  1.1  christos     gdb_test "p/x \$s16" " = 0x40000000"
     73  1.1  christos }
     74  1.1  christos 
     75  1.1  christos # Go back to frame 0 (callee), check that the change to the outer frame didn't
     76  1.1  christos # mess up anything there.
     77  1.1  christos gdb_test "down"
     78  1.1  christos with_test_prefix "callee, after change in caller" {
     79  1.1  christos     gdb_test "p/x \$s16" " = 0x3f800000"
     80  1.1  christos }
     81  1.1  christos 
     82  1.1  christos # Verify that the value of the saved s16 we changed is correctly seen by the
     83  1.1  christos # inferior.
     84  1.1  christos gdb_breakpoint break_here_c temporary
     85  1.1  christos gdb_continue_to_breakpoint "continue to break_here_c"
     86  1.1  christos gdb_test "p/x value" " = 0x40000000"
     87