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