Home | History | Annotate | Line # | Download | only in gdb.arch
      1 # Copyright 2021-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 # Test to see if gdb is properly single stepping over the
     17 # displaced lnia instruction.  This test checks that a series
     18 # of lnia instructions are loading ascending values as expected.
     19 
     20 # lnia is an extended mnemonic for the addpcis instruction, which
     21 # stores the $NIA plus an immediate value into a register.
     22 #
     23 #		lnia Rx == addpcis Rx,0 == lnia Rx
     24 #		subcis Rx,value == addpcis Rx,-value
     25 
     26 require {istarget powerpc*-*}
     27 
     28 set retval 0
     29 
     30 standard_testfile .s
     31 
     32 if { [prepare_for_testing "failed to prepare" $testfile "$srcfile" \
     33       {debug quiet}] } {
     34     return -1
     35 }
     36 
     37 if {![runto_main]} {
     38       return
     39 }
     40 
     41 set before_pc 0
     42 set check_pc [get_hexadecimal_valueof "\$pc" "default0"]
     43 
     44 # set some breakpoints on the instructions below main().
     45 set bp1 *$check_pc+4
     46 set bp2 *$check_pc+12
     47 set bp3 *$check_pc+16
     48 gdb_breakpoint $bp1
     49 gdb_breakpoint $bp2
     50 gdb_breakpoint $bp3
     51 
     52 # single-step through the lnia instructions, and retrieve the
     53 # register values as we proceed.
     54 set insn_supported 1
     55 gdb_test_multiple "stepi" "set r3" {
     56     -re "Program received signal SIGILL, Illegal instruction\\..*" {
     57 	set insn_supported 0
     58     }
     59     -re -wrap "" {
     60 	pass $gdb_test_name
     61     }
     62 }
     63 if { ! $insn_supported } {
     64     unsupported "illegal instruction"
     65     return
     66 }
     67 set check_r3 [get_hexadecimal_valueof "\$r3" "default0"]
     68 gdb_test "stepi" "" "set r4"
     69 set check_r4 [get_hexadecimal_valueof "\$r4" "default0"]
     70 gdb_test "stepi" "" "set r5"
     71 set check_r5 [get_hexadecimal_valueof "\$r5" "default0"]
     72 gdb_test "stepi" "" "set r6"
     73 set check_r6 [get_hexadecimal_valueof "\$r6" "default0"]
     74 gdb_test "stepi" "" "set r7"
     75 set check_r7 [get_hexadecimal_valueof "\$r7" "default0"]
     76 gdb_test "stepi" "" "set r8"
     77 set check_r8 [get_hexadecimal_valueof "\$r8" "default0"]
     78 gdb_test "stepi" "" "set r9"
     79 set check_r9 [get_hexadecimal_valueof "\$r9" "default0"]
     80 
     81 # Ensure that our register values are as expected.
     82 # Specifically that the values loaded by the lnia instruction
     83 # reflect the value of the PC as if the instruction was
     84 # not displaced.
     85 if [expr $check_r3 + 4 != $check_r4] {
     86     fail "unexpected value r3+4 != r4 , r3: $check_r3  r4: $check_r4 "
     87 }
     88 if [expr $check_r4 + 4 != $check_r5] {
     89     fail "unexpected value r4+4 != r5 , r4: $check_r4  r5: $check_r5 "
     90 }
     91 if [expr $check_r5 + 4 != $check_r6] {
     92     fail "unexpected value r5+4 != r6 , r5: $check_r5  r6: $check_r6 "
     93 }
     94 if [expr $check_r6 + 4 != $check_r7] {
     95     fail "unexpected value r6+4 != r7 , r6: $check_r6  r7: $check_r7 "
     96 }
     97 if [expr $check_r7 + 4 != $check_r8] {
     98     fail "unexpected value r7+4 != r8 , r7: $check_r7  r8: $check_r8 "
     99 }
    100 if [expr $check_r8 + 4 != $check_r9] {
    101     fail "unexpected value r8+4 != r9 , r8: $check_r8  r9: $check_r9 "
    102 }
    103 
    104 gdb_test "info break"
    105 gdb_test "info register r3 r4 r5 r6 r7 r8 r9"
    106 gdb_test "disas main"
    107 
    108 # Let the inferior store all vector registers in a buffer, then dump
    109 # the buffer and check it.
    110 
    111