| # Copyright 2021 Free Software Foundation, Inc. |
| |
| # This program is free software; you can redistribute it and/or modify |
| # it under the terms of the GNU General Public License as published by |
| # the Free Software Foundation; either version 3 of the License, or |
| # (at your option) any later version. |
| # |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| # GNU General Public License for more details. |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| |
| # Test to see if gdb is properly single stepping over the |
| # displaced lnia instruction. This test checks that a series |
| # of lnia instructions are loading ascending values as expected. |
| |
| # lnia is an extended mnemonic for the addpcis instruction, which |
| # stores the $NIA plus an immediate value into a register. |
| # |
| # lnia Rx == addpcis Rx,0 == lnia Rx |
| # subcis Rx,value == addpcis Rx,-value |
| |
| if { ![istarget powerpc*-*] } { |
| verbose "Skipping powerpc lnia test." |
| return |
| } |
| |
| set retval 0 |
| |
| standard_testfile .s |
| |
| if { [prepare_for_testing "failed to prepare" $testfile "$srcfile" \ |
| {debug quiet}] } { |
| return -1 |
| } |
| |
| if ![runto_main] then { |
| return |
| } |
| |
| set before_pc 0 |
| set check_pc [get_hexadecimal_valueof "\$pc" "default0"] |
| |
| # set some breakpoints on the instructions below main(). |
| set bp1 *$check_pc+4 |
| set bp2 *$check_pc+12 |
| set bp3 *$check_pc+16 |
| gdb_breakpoint $bp1 |
| gdb_breakpoint $bp2 |
| gdb_breakpoint $bp3 |
| |
| # single-step through the lnia instructions, and retrieve the |
| # register values as we proceed. |
| gdb_test "stepi" "" "set r3" |
| set check_r3 [get_hexadecimal_valueof "\$r3" "default0"] |
| gdb_test "stepi" "" "set r4" |
| set check_r4 [get_hexadecimal_valueof "\$r4" "default0"] |
| gdb_test "stepi" "" "set r5" |
| set check_r5 [get_hexadecimal_valueof "\$r5" "default0"] |
| gdb_test "stepi" "" "set r6" |
| set check_r6 [get_hexadecimal_valueof "\$r6" "default0"] |
| gdb_test "stepi" "" "set r7" |
| set check_r7 [get_hexadecimal_valueof "\$r7" "default0"] |
| gdb_test "stepi" "" "set r8" |
| set check_r8 [get_hexadecimal_valueof "\$r8" "default0"] |
| gdb_test "stepi" "" "set r9" |
| set check_r9 [get_hexadecimal_valueof "\$r9" "default0"] |
| |
| # Ensure that our register values are as expected. |
| # Specifically that the values loaded by the lnia instruction |
| # reflect the value of the PC as if the instruction was |
| # not displaced. |
| if [expr $check_r3 + 4 != $check_r4] { |
| fail "unexpected value r3+4 != r4 , r3: $check_r3 r4: $check_r4 " |
| } |
| if [expr $check_r4 + 4 != $check_r5] { |
| fail "unexpected value r4+4 != r5 , r4: $check_r4 r5: $check_r5 " |
| } |
| if [expr $check_r5 + 4 != $check_r6] { |
| fail "unexpected value r5+4 != r6 , r5: $check_r5 r6: $check_r6 " |
| } |
| if [expr $check_r6 + 4 != $check_r7] { |
| fail "unexpected value r6+4 != r7 , r6: $check_r6 r7: $check_r7 " |
| } |
| if [expr $check_r7 + 4 != $check_r8] { |
| fail "unexpected value r7+4 != r8 , r7: $check_r7 r8: $check_r8 " |
| } |
| if [expr $check_r8 + 4 != $check_r9] { |
| fail "unexpected value r8+4 != r9 , r8: $check_r8 r9: $check_r9 " |
| } |
| |
| gdb_test "info break" |
| gdb_test "info register r3 r4 r5 r6 r7 r8 r9" |
| gdb_test "disas main" |
| |
| # Let the inferior store all vector registers in a buffer, then dump |
| # the buffer and check it. |
| |