Home | History | Annotate | Line # | Download | only in gdb.arch
powerpc-lnia.exp revision 1.1.1.1.4.2
      1  1.1.1.1.4.2  perseant # Copyright 2021-2023 Free Software Foundation, Inc.
      2  1.1.1.1.4.2  perseant 
      3  1.1.1.1.4.2  perseant # This program is free software; you can redistribute it and/or modify
      4  1.1.1.1.4.2  perseant # it under the terms of the GNU General Public License as published by
      5  1.1.1.1.4.2  perseant # the Free Software Foundation; either version 3 of the License, or
      6  1.1.1.1.4.2  perseant # (at your option) any later version.
      7  1.1.1.1.4.2  perseant #
      8  1.1.1.1.4.2  perseant # This program is distributed in the hope that it will be useful,
      9  1.1.1.1.4.2  perseant # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  1.1.1.1.4.2  perseant # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  1.1.1.1.4.2  perseant # GNU General Public License for more details.
     12  1.1.1.1.4.2  perseant #
     13  1.1.1.1.4.2  perseant # You should have received a copy of the GNU General Public License
     14  1.1.1.1.4.2  perseant # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  1.1.1.1.4.2  perseant 
     16  1.1.1.1.4.2  perseant # Test to see if gdb is properly single stepping over the
     17  1.1.1.1.4.2  perseant # displaced lnia instruction.  This test checks that a series
     18  1.1.1.1.4.2  perseant # of lnia instructions are loading ascending values as expected.
     19  1.1.1.1.4.2  perseant 
     20  1.1.1.1.4.2  perseant # lnia is an extended mnemonic for the addpcis instruction, which
     21  1.1.1.1.4.2  perseant # stores the $NIA plus an immediate value into a register.
     22  1.1.1.1.4.2  perseant #
     23  1.1.1.1.4.2  perseant #		lnia Rx == addpcis Rx,0 == lnia Rx
     24  1.1.1.1.4.2  perseant #		subcis Rx,value == addpcis Rx,-value
     25  1.1.1.1.4.2  perseant 
     26  1.1.1.1.4.2  perseant if { ![istarget powerpc*-*] } {
     27  1.1.1.1.4.2  perseant     verbose "Skipping powerpc lnia test."
     28  1.1.1.1.4.2  perseant     return
     29  1.1.1.1.4.2  perseant }
     30  1.1.1.1.4.2  perseant 
     31  1.1.1.1.4.2  perseant set retval 0
     32  1.1.1.1.4.2  perseant 
     33  1.1.1.1.4.2  perseant standard_testfile .s
     34  1.1.1.1.4.2  perseant 
     35  1.1.1.1.4.2  perseant if { [prepare_for_testing "failed to prepare" $testfile "$srcfile" \
     36  1.1.1.1.4.2  perseant       {debug quiet}] } {
     37  1.1.1.1.4.2  perseant     return -1
     38  1.1.1.1.4.2  perseant }
     39  1.1.1.1.4.2  perseant 
     40  1.1.1.1.4.2  perseant if {![runto_main]} {
     41  1.1.1.1.4.2  perseant       return
     42  1.1.1.1.4.2  perseant }
     43  1.1.1.1.4.2  perseant 
     44  1.1.1.1.4.2  perseant set before_pc 0
     45  1.1.1.1.4.2  perseant set check_pc [get_hexadecimal_valueof "\$pc" "default0"]
     46  1.1.1.1.4.2  perseant 
     47  1.1.1.1.4.2  perseant # set some breakpoints on the instructions below main().
     48  1.1.1.1.4.2  perseant set bp1 *$check_pc+4
     49  1.1.1.1.4.2  perseant set bp2 *$check_pc+12
     50  1.1.1.1.4.2  perseant set bp3 *$check_pc+16
     51  1.1.1.1.4.2  perseant gdb_breakpoint $bp1
     52  1.1.1.1.4.2  perseant gdb_breakpoint $bp2
     53  1.1.1.1.4.2  perseant gdb_breakpoint $bp3
     54  1.1.1.1.4.2  perseant 
     55  1.1.1.1.4.2  perseant # single-step through the lnia instructions, and retrieve the
     56  1.1.1.1.4.2  perseant # register values as we proceed.
     57  1.1.1.1.4.2  perseant set insn_supported 1
     58  1.1.1.1.4.2  perseant gdb_test_multiple "stepi" "set r3" {
     59  1.1.1.1.4.2  perseant     -re "Program received signal SIGILL, Illegal instruction\\..*" {
     60  1.1.1.1.4.2  perseant 	set insn_supported 0
     61  1.1.1.1.4.2  perseant     }
     62  1.1.1.1.4.2  perseant     -re -wrap "" {
     63  1.1.1.1.4.2  perseant 	pass $gdb_test_name
     64  1.1.1.1.4.2  perseant     }
     65  1.1.1.1.4.2  perseant }
     66  1.1.1.1.4.2  perseant if { ! $insn_supported } {
     67  1.1.1.1.4.2  perseant     unsupported "illegal instruction"
     68  1.1.1.1.4.2  perseant     return
     69  1.1.1.1.4.2  perseant }
     70  1.1.1.1.4.2  perseant set check_r3 [get_hexadecimal_valueof "\$r3" "default0"]
     71  1.1.1.1.4.2  perseant gdb_test "stepi" "" "set r4"
     72  1.1.1.1.4.2  perseant set check_r4 [get_hexadecimal_valueof "\$r4" "default0"]
     73  1.1.1.1.4.2  perseant gdb_test "stepi" "" "set r5"
     74  1.1.1.1.4.2  perseant set check_r5 [get_hexadecimal_valueof "\$r5" "default0"]
     75  1.1.1.1.4.2  perseant gdb_test "stepi" "" "set r6"
     76  1.1.1.1.4.2  perseant set check_r6 [get_hexadecimal_valueof "\$r6" "default0"]
     77  1.1.1.1.4.2  perseant gdb_test "stepi" "" "set r7"
     78  1.1.1.1.4.2  perseant set check_r7 [get_hexadecimal_valueof "\$r7" "default0"]
     79  1.1.1.1.4.2  perseant gdb_test "stepi" "" "set r8"
     80  1.1.1.1.4.2  perseant set check_r8 [get_hexadecimal_valueof "\$r8" "default0"]
     81  1.1.1.1.4.2  perseant gdb_test "stepi" "" "set r9"
     82  1.1.1.1.4.2  perseant set check_r9 [get_hexadecimal_valueof "\$r9" "default0"]
     83  1.1.1.1.4.2  perseant 
     84  1.1.1.1.4.2  perseant # Ensure that our register values are as expected.
     85  1.1.1.1.4.2  perseant # Specifically that the values loaded by the lnia instruction
     86  1.1.1.1.4.2  perseant # reflect the value of the PC as if the instruction was
     87  1.1.1.1.4.2  perseant # not displaced.
     88  1.1.1.1.4.2  perseant if [expr $check_r3 + 4 != $check_r4] {
     89  1.1.1.1.4.2  perseant     fail "unexpected value r3+4 != r4 , r3: $check_r3  r4: $check_r4 "
     90  1.1.1.1.4.2  perseant }
     91  1.1.1.1.4.2  perseant if [expr $check_r4 + 4 != $check_r5] {
     92  1.1.1.1.4.2  perseant     fail "unexpected value r4+4 != r5 , r4: $check_r4  r5: $check_r5 "
     93  1.1.1.1.4.2  perseant }
     94  1.1.1.1.4.2  perseant if [expr $check_r5 + 4 != $check_r6] {
     95  1.1.1.1.4.2  perseant     fail "unexpected value r5+4 != r6 , r5: $check_r5  r6: $check_r6 "
     96  1.1.1.1.4.2  perseant }
     97  1.1.1.1.4.2  perseant if [expr $check_r6 + 4 != $check_r7] {
     98  1.1.1.1.4.2  perseant     fail "unexpected value r6+4 != r7 , r6: $check_r6  r7: $check_r7 "
     99  1.1.1.1.4.2  perseant }
    100  1.1.1.1.4.2  perseant if [expr $check_r7 + 4 != $check_r8] {
    101  1.1.1.1.4.2  perseant     fail "unexpected value r7+4 != r8 , r7: $check_r7  r8: $check_r8 "
    102  1.1.1.1.4.2  perseant }
    103  1.1.1.1.4.2  perseant if [expr $check_r8 + 4 != $check_r9] {
    104  1.1.1.1.4.2  perseant     fail "unexpected value r8+4 != r9 , r8: $check_r8  r9: $check_r9 "
    105  1.1.1.1.4.2  perseant }
    106  1.1.1.1.4.2  perseant 
    107  1.1.1.1.4.2  perseant gdb_test "info break"
    108  1.1.1.1.4.2  perseant gdb_test "info register r3 r4 r5 r6 r7 r8 r9"
    109  1.1.1.1.4.2  perseant gdb_test "disas main"
    110  1.1.1.1.4.2  perseant 
    111  1.1.1.1.4.2  perseant # Let the inferior store all vector registers in a buffer, then dump
    112  1.1.1.1.4.2  perseant # the buffer and check it.
    113  1.1.1.1.4.2  perseant 
    114