1 # Copyright (C) 2008-2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # This file is part of the gdb testsuite.
23 # Test stepping over permanent breakpoints on i386.
25 if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] } then {
26 verbose "Skipping skip over permanent breakpoint on i386 tests."
30 set testfile "i386-bp_permanent"
31 set srcfile i386-prologue.c
32 set binfile ${objdir}/${subdir}/${testfile}
34 # some targets have leading underscores on assembly symbols.
35 set additional_flags [gdb_target_symbol_prefix_flags]
37 # Don't use "debug", so that we don't have line information for the assembly
39 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list $additional_flags]] != "" } {
40 untested ${testfile}.exp
47 gdb_reinitialize_dir $srcdir/$subdir
51 # Run to `main' where we begin our tests.
54 if ![runto_main] then {
60 set retcode [gdb_test_multiple "disassemble $function" "Disassemble function '$function'" {
61 -re ".*($hex) <\\+0>.*($hex) <\\+4>.*($hex) <\\+5>.*($hex) <\\+6>.*$gdb_prompt $" {
62 set function_start $expect_out(1,string);
63 set address $expect_out(2,string);
64 set address1 $expect_out(3,string);
65 set address2 $expect_out(4,string);
70 fail "Disassemble failed, skipping entire test."
74 gdb_breakpoint "*$function_start"
76 gdb_breakpoint "*$address"
78 gdb_test "continue" "Breakpoint .*, $function_start in $function.*" \
79 "Stop at the '$function' start breakpoint (fetching esp)."
81 # We want to fetch esp at the start of '$function' function to make sure
82 # skip_permanent_breakpoint implementation really skips only the perm.
83 # breakpoint. If, for whatever reason, 'leave' instruction doesn't get
84 # executed, esp will not have this value.
86 gdb_test_multiple "print \$esp" "Fetch esp value." {
87 -re "\\\$1.*($hex).*$gdb_prompt $" {
88 set start_esp $expect_out(1,string);
92 gdb_test "continue" "Breakpoint .*, $address in $function.*" \
93 "Stop at permanent breakpoint."
95 gdb_test "stepi" "$address1|$address2 in $function.*" \
96 "Single stepping past permanent breakpoint."
98 gdb_test "print \$esp" ".*$start_esp.*" \
99 "ESP value does not match - step_permanent_breakpoint wrong."