1# Copyright 2009-2017 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# This file is part of the gdb testsuite. 17 18# Test i386 displaced stepping. 19 20 21if { ![is_x86_like_target] } then { 22 verbose "Skipping x86 displaced stepping tests." 23 return 24} 25 26standard_testfile .S 27 28set additional_flags "-Wa,-g" 29 30if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } { 31 untested "failed to compile" 32 return -1 33} 34 35# Get things started. 36 37gdb_exit 38gdb_start 39gdb_reinitialize_dir $srcdir/$subdir 40gdb_load ${binfile} 41 42gdb_test "set displaced-stepping on" "" 43gdb_test "show displaced-stepping" ".* displaced stepping .* is on.*" 44 45if ![runto_main] then { 46 fail "can't run to main" 47 return 0 48} 49 50########################################## 51 52# Test call/ret. 53 54gdb_test "break test_call" \ 55 "Breakpoint.*at.* file .*$srcfile, line.*" \ 56 "break test_call" 57gdb_test "break test_call_end" \ 58 "Breakpoint.*at.* file .*$srcfile, line.*" \ 59 "break test_call_end" 60 61gdb_test "break test_ret" \ 62 "Breakpoint.*at.* file .*$srcfile, line.*" \ 63 "break test_ret" 64gdb_test "break test_ret_end" \ 65 "Breakpoint.*at.* file .*$srcfile, line.*" \ 66 "break test_ret_end" 67 68gdb_test "continue" \ 69 "Continuing.*Breakpoint.*, test_call ().*" \ 70 "continue to test_call" 71gdb_test "continue" \ 72 "Continuing.*Breakpoint.*, test_call_end ().*" \ 73 "continue to test_call_end" 74 75gdb_test "continue" \ 76 "Continuing.*Breakpoint.*, test_ret ().*" \ 77 "continue to test_ret" 78gdb_test "continue" \ 79 "Continuing.*Breakpoint.*, test_ret_end ().*" \ 80 "continue to test_ret_end" 81 82########################################## 83 84# Absolute jump with leading prefixes. 85# These don't occur in normal code, but gdb should still DTRT. 86 87gdb_test "break test_prefixed_abs_jump" \ 88 "Breakpoint.*at.* file .*$srcfile, line.*" \ 89 "break test_prefixed_abs_jump" 90gdb_test "break test_prefixed_abs_jump_end" \ 91 "Breakpoint.*at.* file .*$srcfile, line.*" \ 92 "break test_prefixed_abs_jump_end" 93 94gdb_test "continue" \ 95 "Continuing.*Breakpoint.*, test_prefixed_abs_jump ().*" \ 96 "continue to test_prefixed_abs_jump" 97gdb_test "continue" \ 98 "Continuing.*Breakpoint.*, test_prefixed_abs_jump_end ().*" \ 99 "continue to test_prefixed_abs_jump_end" 100 101########################################## 102 103# Test syscall. 104 105gdb_test "break test_syscall" \ 106 "Breakpoint.*at.* file .*$srcfile, line.*" \ 107 "break test_syscall" 108gdb_test "break test_syscall_end" \ 109 "Breakpoint.*at.* file .*$srcfile, line.*" \ 110 "break test_syscall_end" 111 112gdb_test "continue" \ 113 "Continuing.*Breakpoint.*, test_syscall ().*" \ 114 "continue to test_syscall" 115gdb_test "continue" \ 116 "Continuing.*Breakpoint.*, test_syscall_end ().*" \ 117 "continue to test_syscall_end" 118 119########################################## 120 121# Test prefixed syscall. 122# These don't occur in normal code, but gdb should still DTRT. 123 124gdb_test "break test_prefixed_syscall" \ 125 "Breakpoint.*at.* file .*$srcfile, line.*" \ 126 "break test_prefixed_syscall" 127gdb_test "break test_prefixed_syscall_end" \ 128 "Breakpoint.*at.* file .*$srcfile, line.*" \ 129 "break test_prefixed_syscall_end" 130 131gdb_test "continue" \ 132 "Continuing.*Breakpoint.*, test_prefixed_syscall ().*" \ 133 "continue to test_prefixed_syscall" 134gdb_test "continue" \ 135 "Continuing.*Breakpoint.*, test_prefixed_syscall_end ().*" \ 136 "continue to test_prefixed_syscall_end" 137 138########################################## 139 140# int3 (with prefixes) 141# These don't occur in normal code, but gdb should still DTRT. 142 143gdb_test "break test_int3" \ 144 "Breakpoint.*at.* file .*$srcfile, line.*" \ 145 "break test_int3" 146gdb_test "break test_int3_end" \ 147 "Breakpoint.*at.* file .*$srcfile, line.*" \ 148 "break test_int3_end" 149 150gdb_test "continue" \ 151 "Continuing.*Breakpoint.*, test_int3 ().*" \ 152 "continue to test_int3" 153 154gdb_test "continue" \ 155 "Continuing.*Breakpoint.*, test_int3_end ().*" \ 156 "continue to test_int3_end" 157 158########################################## 159 160# Done, run program to exit. 161 162gdb_continue_to_end "i386-disp-step" 163