i386-bp_permanent.exp revision 1.1
1# Copyright (C) 2008-2014 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# This file is part of the gdb testsuite.
18
19# Test stepping over permanent breakpoints on i386.
20
21if { ![is_x86_like_target] } then {
22    verbose "Skipping skip over permanent breakpoint on i386 tests."
23    return
24}
25
26set testfile "i386-bp_permanent"
27set srcfile i386-prologue.c
28set binfile ${objdir}/${subdir}/${testfile}
29
30# some targets have leading underscores on assembly symbols.
31set additional_flags [gdb_target_symbol_prefix_flags]
32
33# Don't use "debug", so that we don't have line information for the assembly
34# fragments.
35if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list $additional_flags]] != "" } {
36    untested ${testfile}.exp
37    return -1
38}
39
40
41gdb_exit
42gdb_start
43gdb_reinitialize_dir $srcdir/$subdir
44gdb_load ${binfile}
45
46#
47# Run to `main' where we begin our tests.
48#
49
50if ![runto_main] then {
51  return -1
52}
53
54set function standard
55
56set retcode [gdb_test_multiple "disassemble $function" "Disassemble function '$function'" {
57    -re ".*($hex) <\\+0>.*($hex) <\\+4>.*($hex) <\\+5>.*($hex) <\\+6>.*$gdb_prompt $" {
58      set function_start $expect_out(1,string)
59      set address $expect_out(2,string)
60      set address1 $expect_out(3,string)
61      set address2 $expect_out(4,string)
62    }
63}]
64
65if {$retcode != 0} {
66  fail "Disassemble failed, skipping entire test."
67  return -1
68}
69
70gdb_breakpoint "*$function_start"
71
72gdb_breakpoint "*$address"
73
74gdb_test "continue" "Breakpoint .*, $function_start in $function.*" \
75	 "Stop at the '$function' start breakpoint (fetching esp)."
76
77# We want to fetch esp at the start of '$function' function to make sure
78# skip_permanent_breakpoint implementation really skips only the perm.
79# breakpoint. If, for whatever reason, 'leave' instruction doesn't get
80# executed, esp will not have this value.
81set start_esp 0
82gdb_test_multiple "print \$esp" "Fetch esp value." {
83    -re "\\\$1.*($hex).*$gdb_prompt $" {
84      set start_esp $expect_out(1,string)
85    }
86}
87
88gdb_test "continue" "Breakpoint .*, $address in $function.*" \
89	 "Stop at permanent breakpoint."
90
91gdb_test "stepi" "$address1|$address2 in $function.*" \
92	 "Single stepping past permanent breakpoint."
93
94gdb_test "print \$esp" ".*$start_esp.*" \
95	 "ESP value does not match - step_permanent_breakpoint wrong."
96
97