This commit was generated by cvs2svn to track changes on a CVS vendor
[external/binutils.git] / gdb / testsuite / gdb.base / consecutive.exp
1 #   Copyright 2001
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 2 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, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
20
21 # This file was written by Michael Snyder. (msnyder@redhat.com)
22
23 if $tracelevel then {
24     strace $tracelevel
25 }
26
27 #
28 # Test breakpoints at consecutive instruction addresses.
29 #
30
31 set prms_id 0
32 set bug_id 0
33
34 set testfile "consecutive"
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
37
38 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
39     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
40 }
41
42 if [get_compiler_info ${binfile}] {
43     return -1
44 }
45
46 gdb_exit
47 gdb_start
48 gdb_reinitialize_dir $srcdir/$subdir
49 gdb_load ${binfile}
50
51 if [target_info exists gdb_stub] {
52     gdb_step_for_stub;
53 }
54
55 if ![runto_main] then {
56     perror "couldn't run to breakpoint"
57     continue
58 }
59
60 set nl "\[\r\n\]+"
61
62 gdb_breakpoint foo
63 gdb_test "continue" "Breakpoint $decimal, foo .*" \
64         "continue to breakpoint in foo"
65
66 set bp_addr 0
67 set stop_addr 0
68
69 send_gdb "x /2i \$pc\n"
70 gdb_expect {
71     global hex
72     global nl
73     global bp_addr
74     global gdb_prompt
75
76     -re "$hex.*${nl}($hex).*$gdb_prompt $" {
77         set bp_addr $expect_out(1,string)
78         pass "get breakpoint address for foo"
79     }
80     -re ".*$gdb_prompt $" {
81         fail "get breakpoint address for foo"
82         return 0;
83     }
84     timeout {
85         fail "get breakpoint address for foo (timeout)"
86         return 0;
87     }
88 }
89
90 gdb_test "break \*$bp_addr" "Breakpoint $decimal at $bp_addr: file .*" \
91         "set bp, 2nd instr"
92
93 send_gdb "step\n"
94 gdb_expect {
95     -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
96         set stop_addr $expect_out(1,string)
97         if [eval expr "$bp_addr == $stop_addr"] then {
98             pass "stopped at bp, 2nd instr"
99         } else {
100             fail "stopped at bp, 2nd instr (wrong address)"
101         }
102     }
103     -re ".*$gdb_prompt $" {
104         fail "stopped at bp, 2nd instr"
105     }
106     timeout {
107         fail "stopped at bp, 2nd instr (timeout)"
108
109     }
110 }
111