* gdb.base/completion.exp: Recognize the more detailed error
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / condbreak.exp
CommitLineData
7dbd117d 1# Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
c906108c
SS
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 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This test was written by Rich Title.
21# Purpose is to test conditional breakpoints.
22# Modeled after "break.exp".
23
c906108c
SS
24if $tracelevel then {
25 strace $tracelevel
26 }
27
28global usestubs
29
30#
31# test running programs
32#
33set prms_id 0
34set bug_id 0
35
c2c6d25f 36set testfile "break"
c906108c
SS
37set srcfile ${testfile}.c
38set binfile ${objdir}/${subdir}/${testfile}
39
40if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
41 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
42}
43
085dd6e6
JM
44if [get_compiler_info ${binfile}] {
45 return -1;
46}
47
c906108c
SS
48gdb_exit
49gdb_start
50gdb_reinitialize_dir $srcdir/$subdir
51gdb_load ${binfile}
52
53
54if [target_info exists gdb_stub] {
55 gdb_step_for_stub;
56}
57
58#
59# test break at function
60#
61gdb_test "break main" \
62 "Breakpoint.*at.* file .*$srcfile, line.*" \
63 "breakpoint function"
64
65#
66# test conditional break at function
67#
68gdb_test "break marker1 if 1==1" \
7dbd117d 69 "Breakpoint.*at.* file .*$srcfile, line.*"
c906108c 70
7dbd117d 71gdb_test "delete 2" ""
c906108c
SS
72
73#
74# test conditional break at line number
75#
085dd6e6 76gdb_test "break 79 if 1==1" \
7dbd117d 77 "Breakpoint.*at.* file .*$srcfile, line 79\\."
c906108c 78
7dbd117d 79gdb_test "delete 3" ""
c906108c
SS
80
81#
82# test conditional break at function
83#
84gdb_test "break marker1 if (1==1)" \
7dbd117d 85 "Breakpoint.*at.* file .*$srcfile, line.*"
c906108c
SS
86
87#
88# test conditional break at line number
89#
085dd6e6 90gdb_test "break 79 if (1==1)" \
7dbd117d 91 "Breakpoint.*at.* file .*$srcfile, line 79\\."
c906108c
SS
92
93gdb_test "break marker2 if (a==43)" \
7dbd117d 94 "Breakpoint.*at.* file .*$srcfile, line.*"
c906108c
SS
95
96#
97# check to see what breakpoints are set
98#
99
085dd6e6
JM
100if {$hp_aCC_compiler} {
101 set marker1_proto "\\(void\\)"
102 set marker2_proto "\\(int\\)"
103} else {
104 set marker1_proto ""
105 set marker2_proto ""
106}
107
108set main_line 75
c906108c
SS
109gdb_test "info break" \
110 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
111\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
085dd6e6 112\[0-9\]+\[\t \]+breakpoint keep y.* in marker1$marker1_proto at .*$srcfile:4\[38\].*
c906108c 113\[\t \]+stop only if 1 == 1.*
085dd6e6 114\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:79.*
c906108c 115\[\t \]+stop only if 1 == 1.*
085dd6e6 116\[0-9\]+\[\t \]+breakpoint keep y.* in marker2$marker2_proto at .*$srcfile:4\[49\].*
c906108c
SS
117\[\t \]+stop only if a == 43.*" \
118 "breakpoint info"
119
120
121#
7a292a7a 122# run until the breakpoint at main is hit.
c906108c 123#
7a292a7a
SS
124
125
cce74817 126rerun_to_main
c906108c
SS
127
128#
129# run until the breakpoint at a line number
130#
085dd6e6 131gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:79.*79\[\t \]+printf.*factorial.*" \
c906108c
SS
132 "run until breakpoint set at a line number"
133
134#
135# run until the breakpoint at marker1
136#
11cf8741
JM
137# If the inferior stops at the first instruction of a source line, GDB
138# won't print the actual PC value; the source line is enough to
139# exactly specify the PC. But if the inferior is instead stopped in
140# the midst of a source line, GDB will include the PC in the
141# breakpoint hit message. This way, GDB always provides the exact
142# stop location, but avoids clutter when possible.
143#
144# Suppose you have a function written completely on one source line, like:
145# int foo (int x) { return 0; }
146# Setting a breakpoint at `foo' actually places the breakpoint after
147# foo's prologue.
148#
149# GCC's STABS writer always emits a line entry attributing the
150# prologue instructions to the line containing the function's open
151# brace, even if the first user instruction is also on that line.
152# This means that, in the case of a one-line function, you will get
153# two line entries in the debug info for the same line: one at the
154# function's entry point, and another at the first user instruction.
155# GDB preserves these duplicated line entries, and prefers the later
156# one; thus, when the program stops after the prologue, at the first
157# user instruction, GDB's search finds the second line entry, decides
158# that the PC is indeed at the beginning of a source line, and doesn't
159# print an address in the breakpoint hit message.
160#
161# GCC's Dwarf2 writer, on the other hand, squeezes out duplicate line
162# entries, so GDB considers the source line to begin at the start of
163# the function's prologue. Thus, if the program stops at the
164# breakpoint, GDB will decide that the PC is not at the beginning of a
165# source line, and will print an address.
166#
167# I think the Dwarf2 writer's behavior is arguably correct, but not
168# helpful. If the user sets a breakpoint at that source line, they
169# want that breakpoint to fall after the prologue. Identifying the
170# prologue's code with the opening brace is nice, but it shouldn't
171# take precedence over real code.
172#
173# Until the Dwarf2 writer gets fixed, I'm going to XFAIL its behavior.
174send_gdb "continue\n"
175gdb_expect {
c2d11a7d 176 -re "Continuing\\..*Breakpoint \[0-9\]+, marker1 \\(\\) at .*$srcfile:4\[38\].*4\[38\]\[\t \]+.*$gdb_prompt $" {
11cf8741
JM
177 pass "run until breakpoint at marker1"
178 }
c2d11a7d 179 -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker1 \\(\\) at .*$srcfile:4\[38\].*4\[38\]\[\t \]+.*$gdb_prompt $" {
11cf8741
JM
180 xfail "run until breakpoint at marker1"
181 }
182 -re "$gdb_prompt $" {
183 fail "run until breakpoint at marker1"
184 }
185 timeout {
186 fail "(timeout) run until breakpoint at marker1"
187 }
188}
c906108c 189
c906108c 190# run until the breakpoint at marker2
dfcd3bfb 191# Same issues here as above.
a0b3c4fd 192setup_xfail hppa2.0w-*-* 11512CLLbs
dfcd3bfb
JM
193send_gdb "continue\n"
194gdb_expect {
195 -re "Continuing\\..*Breakpoint \[0-9\]+, marker2 \\(a=43\\) at .*$srcfile:4\[49\].*4\[49\]\[\t \]+.*" {
196 pass "run until breakpoint at marker2"
197 }
198 -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker2 \\(a=43\\) at .*$srcfile:4\[49\].*4\[49\]\[\t \]+.*" {
199 xfail "run until breakpoint at marker2"
200 }
201 -re "$gdb_prompt $" {
202 fail "run until breakpoint at marker2"
203 }
204 timeout {
205 fail "(timeout) run until breakpoint at marker2"
206 }
207}
This page took 0.266069 seconds and 4 git commands to generate.