gdb/doc/
[external/binutils.git] / gdb / testsuite / gdb.base / consecutive.exp
1 #   Copyright 2001, 2007, 2008, 2009, 2010, 2011
2 #   Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # This file was written by Michael Snyder. (msnyder@redhat.com)
18
19 if $tracelevel then {
20     strace $tracelevel
21 }
22
23 #
24 # Test breakpoints at consecutive instruction addresses.
25 #
26
27
28 set testfile "consecutive"
29 set srcfile ${testfile}.c
30 set binfile ${objdir}/${subdir}/${testfile}
31
32 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
33     untested consecutive.exp
34     return -1
35 }
36
37 if [get_compiler_info ${binfile}] {
38     return -1
39 }
40
41 gdb_exit
42 gdb_start
43 gdb_reinitialize_dir $srcdir/$subdir
44 gdb_load ${binfile}
45
46 if ![runto_main] then {
47     perror "couldn't run to breakpoint"
48     continue
49 }
50
51 set nl "\[\r\n\]+"
52
53 gdb_breakpoint foo
54 gdb_test "continue" "Breakpoint $decimal, foo .*" \
55         "continue to breakpoint in foo"
56
57 set bp_addr 0
58 set stop_addr 0
59
60 gdb_test_multiple "x /2i \$pc" "get breakpoint address for foo" {
61     -re "=> $hex.*${nl}   ($hex).*$gdb_prompt $" {
62         set bp_addr $expect_out(1,string)
63         pass "get breakpoint address for foo"
64     }
65 }
66
67 gdb_test "break \*$bp_addr" "Breakpoint $decimal at $bp_addr: file .*" \
68         "set bp, 2nd instr"
69
70 gdb_test_multiple "step" "stopped at bp, 2nd instr" {
71     -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
72         set stop_addr $expect_out(1,string)
73         if [eval expr "$bp_addr == $stop_addr"] then {
74             pass "stopped at bp, 2nd instr"
75         } else {
76             fail "stopped at bp, 2nd instr (wrong address)"
77         }
78     }
79 }
80