| 1 | # Copyright 2005, 2007, 2008, 2009, 2010, 2011 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 | if $tracelevel { |
| 17 | strace $tracelevel |
| 18 | } |
| 19 | |
| 20 | |
| 21 | if ![istarget "alpha*-*-*"] then { |
| 22 | verbose "Skipping alpha step tests." |
| 23 | return |
| 24 | } |
| 25 | |
| 26 | set testfile "alpha-step" |
| 27 | set srcfile ${testfile}.c |
| 28 | set binfile ${objdir}/${subdir}/${testfile} |
| 29 | |
| 30 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] != "" } { |
| 31 | unsupported "Testcase compile failed." |
| 32 | return -1 |
| 33 | } |
| 34 | |
| 35 | gdb_exit |
| 36 | gdb_start |
| 37 | gdb_reinitialize_dir $srcdir/$subdir |
| 38 | gdb_load ${binfile} |
| 39 | |
| 40 | proc test_stepi {function } { |
| 41 | # Restart the program from scratch. If GDB got confused during one |
| 42 | # of the previous tests, this makes sure that it doesn't affect |
| 43 | # this series of tests. |
| 44 | if ![runto_main] then { |
| 45 | fail "Can't run to main" |
| 46 | return 0 |
| 47 | } |
| 48 | |
| 49 | # Insert a breakpoint on the FP branch instruction inside FUNCTION. |
| 50 | # Since the function has been hand written, we know this instruction |
| 51 | # is a "fb$function" located at FUNCTION+4. |
| 52 | gdb_test "break *$function+4" \ |
| 53 | "Breakpoint .* at .*" \ |
| 54 | "breakpoint on fb$function instruction" |
| 55 | |
| 56 | gdb_test "continue" \ |
| 57 | "Breakpoint .*, 0x\[0-9a-fA-F\]+ in $function\(\).*" \ |
| 58 | "continue to fb$function instruction (first call)" |
| 59 | |
| 60 | # Extra check to make sure we stopped on the FP branch instruction. |
| 61 | |
| 62 | gdb_test "x /i \$pc" \ |
| 63 | "0x\[0-9a-fA-F\]+ <.*>:\[ \t\]+fb$function.*" \ |
| 64 | "Check breakpoint on fb$function instruction (first call)" |
| 65 | |
| 66 | # Step test, followed by the check that we landed on the expected |
| 67 | # instruction (the testcase should be written in such a way that |
| 68 | # the branch is taken on the first call to this function. |
| 69 | |
| 70 | gdb_test "stepi" \ |
| 71 | "0x\[0-9a-fA-F\]+.*" \ |
| 72 | "stepi on fb$function (first call)" |
| 73 | |
| 74 | gdb_test "x /i \$pc" \ |
| 75 | "0x\[0-9a-fA-F\]+ <.*>:\[ \t\]+ret.*" \ |
| 76 | "Check stepi over fb$function stopped on ret" |
| 77 | |
| 78 | # Continue again. FUNCTION should be called a second time, this time |
| 79 | # with an argument such that the FP branch will not be taken. |
| 80 | |
| 81 | gdb_test "continue" \ |
| 82 | "Breakpoint .*, 0x\[0-9a-fA-F\]+ in $function\(\).*" \ |
| 83 | "continue to fb$function instruction (second call)" |
| 84 | |
| 85 | # Extra check to make sure we stopped on the FP branch instruction. |
| 86 | |
| 87 | gdb_test "x /i \$pc" \ |
| 88 | "0x\[0-9a-fA-F\]+ <.*>:\[ \t\]+fb$function.*" \ |
| 89 | "Check breakpoint on fb$function instruction (second call)" |
| 90 | |
| 91 | # Step test, branch should not be taken. |
| 92 | |
| 93 | gdb_test "stepi" \ |
| 94 | "0x\[0-9a-fA-F\]+.*" \ |
| 95 | "stepi on fb$function (branch not taken)" |
| 96 | |
| 97 | # Extra check to verify that we landed on the instruction we expected. |
| 98 | |
| 99 | gdb_test "x /i \$pc" \ |
| 100 | "0x\[0-9a-fA-F\]+ <.*>:\[ \t\]+fneg.*" \ |
| 101 | "Check stepi over fb$function stopped on fneg instruction" |
| 102 | |
| 103 | } |
| 104 | |
| 105 | test_stepi "gt" |
| 106 | test_stepi "ge" |
| 107 | test_stepi "lt" |
| 108 | test_stepi "le" |
| 109 | test_stepi "eq" |
| 110 | test_stepi "ne" |
| 111 | |