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