1 |
1181 |
sfurman |
# Copyright 1997, 1998, 1999, 2000, 2001 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 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 |
|
|
|
24 |
|
|
if $tracelevel then {
|
25 |
|
|
strace $tracelevel
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
global usestubs
|
29 |
|
|
|
30 |
|
|
#
|
31 |
|
|
# test running programs
|
32 |
|
|
#
|
33 |
|
|
set prms_id 0
|
34 |
|
|
set bug_id 0
|
35 |
|
|
|
36 |
|
|
set testfile "break"
|
37 |
|
|
set srcfile ${testfile}.c
|
38 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
39 |
|
|
|
40 |
|
|
if { [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 |
|
|
|
44 |
|
|
if [get_compiler_info ${binfile}] {
|
45 |
|
|
return -1;
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
gdb_exit
|
49 |
|
|
gdb_start
|
50 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
51 |
|
|
gdb_load ${binfile}
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
if [target_info exists gdb_stub] {
|
55 |
|
|
gdb_step_for_stub;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
#
|
59 |
|
|
# test break at function
|
60 |
|
|
#
|
61 |
|
|
gdb_test "break main" \
|
62 |
|
|
"Breakpoint.*at.* file .*$srcfile, line.*" \
|
63 |
|
|
"breakpoint function"
|
64 |
|
|
|
65 |
|
|
#
|
66 |
|
|
# test conditional break at function
|
67 |
|
|
#
|
68 |
|
|
gdb_test "break marker1 if 1==1" \
|
69 |
|
|
"Breakpoint.*at.* file .*$srcfile, line.*"
|
70 |
|
|
|
71 |
|
|
gdb_test "delete 2" ""
|
72 |
|
|
|
73 |
|
|
#
|
74 |
|
|
# test conditional break at line number
|
75 |
|
|
#
|
76 |
|
|
gdb_test "break 79 if 1==1" \
|
77 |
|
|
"Breakpoint.*at.* file .*$srcfile, line 79\\."
|
78 |
|
|
|
79 |
|
|
gdb_test "delete 3" ""
|
80 |
|
|
|
81 |
|
|
#
|
82 |
|
|
# test conditional break at function
|
83 |
|
|
#
|
84 |
|
|
gdb_test "break marker1 if (1==1)" \
|
85 |
|
|
"Breakpoint.*at.* file .*$srcfile, line.*"
|
86 |
|
|
|
87 |
|
|
#
|
88 |
|
|
# test conditional break at line number
|
89 |
|
|
#
|
90 |
|
|
gdb_test "break 79 if (1==1)" \
|
91 |
|
|
"Breakpoint.*at.* file .*$srcfile, line 79\\."
|
92 |
|
|
|
93 |
|
|
gdb_test "break marker2 if (a==43)" \
|
94 |
|
|
"Breakpoint.*at.* file .*$srcfile, line.*"
|
95 |
|
|
|
96 |
|
|
#
|
97 |
|
|
# check to see what breakpoints are set
|
98 |
|
|
#
|
99 |
|
|
|
100 |
|
|
if {$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 |
|
|
|
108 |
|
|
set main_line 75
|
109 |
|
|
gdb_test "info break" \
|
110 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
111 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
|
112 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.* in marker1$marker1_proto at .*$srcfile:4\[38\].*
|
113 |
|
|
\[\t \]+stop only if 1 == 1.*
|
114 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:79.*
|
115 |
|
|
\[\t \]+stop only if 1 == 1.*
|
116 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.* in marker2$marker2_proto at .*$srcfile:4\[49\].*
|
117 |
|
|
\[\t \]+stop only if a == 43.*" \
|
118 |
|
|
"breakpoint info"
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
#
|
122 |
|
|
# run until the breakpoint at main is hit.
|
123 |
|
|
#
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
rerun_to_main
|
127 |
|
|
|
128 |
|
|
#
|
129 |
|
|
# run until the breakpoint at a line number
|
130 |
|
|
#
|
131 |
|
|
gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:79.*79\[\t \]+printf.*factorial.*" \
|
132 |
|
|
"run until breakpoint set at a line number"
|
133 |
|
|
|
134 |
|
|
#
|
135 |
|
|
# run until the breakpoint at marker1
|
136 |
|
|
#
|
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.
|
174 |
|
|
send_gdb "continue\n"
|
175 |
|
|
gdb_expect {
|
176 |
|
|
-re "Continuing\\..*Breakpoint \[0-9\]+, marker1 \\(\\) at .*$srcfile:4\[38\].*4\[38\]\[\t \]+.*$gdb_prompt $" {
|
177 |
|
|
pass "run until breakpoint at marker1"
|
178 |
|
|
}
|
179 |
|
|
-re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker1 \\(\\) at .*$srcfile:4\[38\].*4\[38\]\[\t \]+.*$gdb_prompt $" {
|
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 |
|
|
}
|
189 |
|
|
|
190 |
|
|
# run until the breakpoint at marker2
|
191 |
|
|
# Same issues here as above.
|
192 |
|
|
setup_xfail hppa2.0w-*-* 11512CLLbs
|
193 |
|
|
send_gdb "continue\n"
|
194 |
|
|
gdb_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 |
|
|
}
|