Home | History | Annotate | Line # | Download | only in gdb.arch
powerpc-addpcis.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 
     17  1.1  christos # Test to confirm that gdb is properly single stepping over the
     18  1.1  christos # displaced addpcis instruction.
     19  1.1  christos # The addpcis instruction and its extended mnemonics lnia and subpcis
     20  1.1  christos # apply an immediate shifted value (X || 0x0000) to the current PC/NIA
     21  1.1  christos # value, and store that value into the instructions target register.
     22  1.1  christos # When the instruction is displaced, it needs special handling.
     23  1.1  christos 
     24  1.1  christos # lnia Rx == addpcis Rx,0
     25  1.1  christos # subcis Rx,value == addpcis Rx,-value
     26  1.1  christos 
     27  1.1  christos if { ![istarget powerpc*-*] } {
     28  1.1  christos     verbose "Skipping powerpc addpcis test."
     29  1.1  christos     return
     30  1.1  christos }
     31  1.1  christos 
     32  1.1  christos set retval 0
     33  1.1  christos 
     34  1.1  christos standard_testfile .s
     35  1.1  christos 
     36  1.1  christos if { [prepare_for_testing "failed to prepare" $testfile "$srcfile" \
     37  1.1  christos       {debug quiet}] } {
     38  1.1  christos     return -1
     39  1.1  christos }
     40  1.1  christos 
     41  1.1  christos if {![runto_main]} {
     42  1.1  christos       return
     43  1.1  christos }
     44  1.1  christos 
     45  1.1  christos set check_pc [get_hexadecimal_valueof "\$pc" "default0"]
     46  1.1  christos set bp1 *$check_pc+4
     47  1.1  christos set bp2 *$check_pc+12
     48  1.1  christos set bp3 *$check_pc+16
     49  1.1  christos gdb_breakpoint $bp1
     50  1.1  christos gdb_breakpoint $bp2
     51  1.1  christos gdb_breakpoint $bp3
     52  1.1  christos 
     53  1.1  christos set insn_supported 1
     54  1.1  christos gdb_test_multiple "stepi" "set r3" {
     55  1.1  christos     -re "Program received signal SIGILL, Illegal instruction\\..*" {
     56  1.1  christos 	set insn_supported 0
     57  1.1  christos     }
     58  1.1  christos     -re -wrap "" {
     59  1.1  christos 	pass $gdb_test_name
     60  1.1  christos     }
     61  1.1  christos }
     62  1.1  christos if { ! $insn_supported } {
     63  1.1  christos     unsupported "illegal instruction"
     64  1.1  christos     return
     65  1.1  christos }
     66  1.1  christos set check_r3 [get_hexadecimal_valueof "\$r3" "default0"]
     67  1.1  christos gdb_test "stepi" "" "set r4"
     68  1.1  christos set check_r4 [get_hexadecimal_valueof "\$r4" "default0"]
     69  1.1  christos gdb_test "stepi" "" "set r5"
     70  1.1  christos set check_r5 [get_hexadecimal_valueof "\$r5" "default0"]
     71  1.1  christos gdb_test "stepi" "" "set r6"
     72  1.1  christos set check_r6 [get_hexadecimal_valueof "\$r6" "default0"]
     73  1.1  christos gdb_test "stepi" "" "set r7"
     74  1.1  christos set check_r7 [get_hexadecimal_valueof "\$r7" "default0"]
     75  1.1  christos gdb_test "stepi" "" "set r8"
     76  1.1  christos set check_r8 [get_hexadecimal_valueof "\$r8" "default0"]
     77  1.1  christos gdb_test "stepi" "" "set r9"
     78  1.1  christos set check_r9 [get_hexadecimal_valueof "\$r9" "default0"]
     79  1.1  christos 
     80  1.1  christos # R6 will contain the reference value.  All other
     81  1.1  christos # instructions in this test will be storing values
     82  1.1  christos # relative to what is stored in R6.
     83  1.1  christos 
     84  1.1  christos #	subpcis 3,+0x100 	# /* set r3 */
     85  1.1  christos #	subpcis 4,+0x10		# /* set r4 */
     86  1.1  christos #	subpcis 5,+0x1		# /* set r5 */
     87  1.1  christos #	lnia    6		# /* set r6 */
     88  1.1  christos #	addpcis 7,+0x1		# /* set r7 */
     89  1.1  christos #	addpcis 8,+0x10		# /* set r8 */
     90  1.1  christos #	addpcis 9,+0x100	# /* set r9 */
     91  1.1  christos 
     92  1.1  christos if [expr $check_r3 + 0x1000000   != $check_r6 - 0xc ] {
     93  1.1  christos     fail "unexpected value r3 + 0x1,000,000 != r6 + 0xc ; r3: $check_r3  r6: $check_r6 "
     94  1.1  christos }
     95  1.1  christos if [expr $check_r4 + 0x100000  != $check_r6 - 0x8 ] {
     96  1.1  christos     fail "unexpected value r4 + 0x100,000 != r6 - 0x8 ; r4: $check_r4  r6: $check_r6 "
     97  1.1  christos }
     98  1.1  christos if [expr $check_r5 + 0x10000  != $check_r6 - 0x4 ] {
     99  1.1  christos     fail "unexpected value r5 + 0x10,000 != r6 , r5: $check_r5  r6: $check_r6 "
    100  1.1  christos }
    101  1.1  christos if [expr $check_r6 != $check_r6] {
    102  1.1  christos     fail "unexpected value r6 != r6 , r6: $check_r6  r6: $check_r6 "
    103  1.1  christos }
    104  1.1  christos if [expr $check_r7 - 0x10000  != $check_r6 + 0x4] {
    105  1.1  christos     fail "unexpected value r7 - 0x10,000 != r6 + 0x4 , r7: $check_r7  r7: $check_r6 "
    106  1.1  christos }
    107  1.1  christos if [expr $check_r8 - 0x100000  != $check_r6 + 0x8 ] {
    108  1.1  christos     fail "unexpected value r8 - 0x100,000 != r6 , r8: $check_r8  r8: $check_r6 "
    109  1.1  christos }
    110  1.1  christos if [expr $check_r9 - 0x1000000  != $check_r6 + 0xc ] {
    111  1.1  christos     fail "unexpected value r9 - 0x1,000,000 != r6 + 0xc , r9: $check_r9  r6: $check_r6 "
    112  1.1  christos }
    113  1.1  christos 
    114  1.1  christos gdb_test "info break"
    115  1.1  christos gdb_test "info register r3 r4 r5 r6 r7 r8 r9"
    116  1.1  christos gdb_test "disas main"
    117  1.1  christos 
    118