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