]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/consecutive.exp
2001-07-25 Michael Snyder <msnyder@redhat.com>
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / consecutive.exp
CommitLineData
c2b8fa57
MS
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
23if $tracelevel then {
24 strace $tracelevel
25}
26
27#
28# Test breakpoints at consecutive instruction addresses.
29#
30
31set prms_id 0
32set bug_id 0
33
34set testfile "consecutive"
35set srcfile ${testfile}.c
36set binfile ${objdir}/${subdir}/${testfile}
37
38if { [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
42if [get_compiler_info ${binfile}] {
43 return -1
44}
45
46gdb_exit
47gdb_start
48gdb_reinitialize_dir $srcdir/$subdir
49gdb_load ${binfile}
50
51if [target_info exists gdb_stub] {
52 gdb_step_for_stub;
53}
54
55if ![runto_main] then {
56 perror "couldn't run to breakpoint"
57 continue
58}
59
60set nl "\[\r\n\]+"
61
62gdb_breakpoint foo
63gdb_test "continue" "Breakpoint $decimal, foo .*" \
64 "continue to breakpoint in foo"
65
66set bp_addr 0
67set stop_addr 0
68
69send_gdb "x /2i \$pc\n"
70gdb_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
90gdb_test "break \*$bp_addr" "Breakpoint $decimal at $bp_addr: file .*" \
91 "set bp, 2nd instr"
92
93send_gdb "step\n"
94gdb_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