]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/annota1.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / annota1.exp
CommitLineData
1d506c26 1# Copyright 1999-2024 Free Software Foundation, Inc.
a4cb37cb
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
a4cb37cb 6# (at your option) any later version.
e22f8b7c 7#
a4cb37cb
SS
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.
e22f8b7c 12#
a4cb37cb 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
a4cb37cb 15
a4cb37cb
SS
16# This file was written by Elena Zannoni (ezannoni@cygnus.com)
17
a4cb37cb 18
300b6685
PA
19# This testcase cannot use runto_main because of the different prompt
20# we get when using annotation level 2.
fc33412a 21#
ec1300f6 22require target_can_use_run_cmd
fc33412a 23
9c97429f 24set breakpoints_invalid "\r\n\032\032breakpoints-invalid\r\n"
fc33412a 25
a4cb37cb
SS
26#
27# test running programs
28#
a4cb37cb 29
a64d2530 30standard_testfile .c
a4cb37cb 31
fc91c6c2 32if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
84c93cd5 33 untested "failed to compile"
b60f0898 34 return -1
a4cb37cb
SS
35}
36
37
a64d2530 38clean_restart ${binfile}
a4cb37cb 39
a4cb37cb
SS
40# The commands we test here produce many lines of output; disable "press
41# <return> to continue" prompts.
6acb16a2 42gdb_test_no_output "set height 0"
a4cb37cb
SS
43
44#
495346f6 45# break in main
a4cb37cb 46#
2c8910ba
TS
47
48set main_line [gdb_get_line_number "break main"]
49
495346f6 50gdb_test "break ${srcfile}:${main_line}" \
2c8910ba 51 "Breakpoint.*at.* file .*$srcfile, line $main_line\\." \
a4cb37cb
SS
52 "breakpoint main"
53
54
55#
56# NOTE: this prompt is OK only when the annotation level is > 1
57# NOTE: When this prompt is in use the gdb_test procedure cannot be used because
58# it assumes that the last char after the gdb_prompt is a white space. This is not
59# true with this annotated prompt. So we must use send_gdb and gdb_expect.
60#
61
62set old_gdb_prompt $gdb_prompt
63set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n"
64
d99968dc
EZ
65#
66# Escape all the characters in the path that need it. For instance
67# the directory name could contain '+'.
68#
69set escapedsrcfile [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
a4cb37cb
SS
70
71
72#
73# set the annotation level to 2
74#
75# of course, this will test:
76# annotate-pre-prompt
77# annotate-prompt
78# annotate-post-prompt (in the next block)
79#
80send_gdb "set annotate 2\n"
81gdb_expect {
82 -re "set annotate 2\r\n$gdb_prompt$" { pass "annotation set at level 2" }
83 -re ".*$gdb_prompt$" { fail "annotation set at level 2" }
84 timeout { fail "annotation set at level 2 (timeout)" }
85 }
86
87
88#
89# info break will test:
90# annotate-breakpoints-headers
91# annotate-field
92# annotate-breakpoints-table
93# annotate-record
94# annotate-breakpoints-table-end
95#
6acb16a2
MS
96gdb_test_multiple "info break" "breakpoint info" {
97 -re "\r\n\032\032post-prompt\r\n\r\n\032\032breakpoints-headers\r\n\r\n\032\032field 0\r\nNum \r\n\032\032field 1\r\nType \r\n\032\032field 2\r\nDisp \r\n\032\032field 3\r\nEnb \r\n\032\032field 4\r\nAddress +\r\n\032\032field 5\r\nWhat\r\n\r\n\032\032breakpoints-table\r\n\r\n\032\032record\r\n\r\n\032\032field 0\r\n1 \r\n\032\032field 1\r\nbreakpoint \r\n\032\032field 2\r\nkeep \r\n\032\032field 3\r\ny \r\n\032\032field 4\r\n$hex +\r\n\032\032field 5\r\nin main at ${escapedsrcfile}:$main_line\r\n\r\n\032\032breakpoints-table-end\r\n$gdb_prompt$" {
3d63690a 98 pass $gdb_test_name
6acb16a2
MS
99 }
100 -re "\r\n\032\032post-prompt\r\n\r\n\032\032breakpoints-headers\r\n\r\n\032\032field 0\r\nNum \r\n\032\032field 1\r\nType \r\n\032\032field 2\r\nDisp \r\n\032\032field 3\r\nEnb \r\n\032\032field 4\r\nAddress +\r\n\032\032field 5\r\nWhat\r\n\r\n\032\032breakpoints-table\r\n\r\n\032\032record\r\n\r\n\032\032field 0\r\n1 \r\n\032\032field 1\r\nbreakpoint \r\n\032\032field 2\r\nkeep \r\n\032\032field 3\r\ny \r\n\032\032field 4\r\n$hex +\r\n\032\032field 5\r\nin main at .*${srcfile}:$main_line\r\n\r\n\032\032breakpoints-table-end\r\n$gdb_prompt$" {
e1692475 101 setup_xfail "*-*-*" 8375
3d63690a 102 fail $gdb_test_name
6acb16a2 103 }
a4cb37cb
SS
104}
105
106
107#
108# run to a break point will test:
109# annotate-frames-invalid
110# annotate-breakpoints-invalid (a.k.a. breakpoints-changed)
111# annotate-starting
112# annotate-breakpoint
113# annotate-frame-begin
114# annotate-frame-function-name
115# annotate-frame-args
116# annotate-frame-source-begin
117# annotate-frame-source-file
118# annotate-frame-source-file-end
119# annotate-frame-source-line
120# annotate-frame-source-end
121# annotate-source
122# annotate-frame-end
123# annotate-stopped
124#
392a587b 125#exp_internal 1
8c008720 126set binexp [string_to_regexp $binfile]
c9923e71 127
cf4505a7 128set warning_slow_re \
359efc2d 129 "warning: File transfers from remote targets can be slow\[^\r\n\]+\r\n"
cf4505a7
TV
130set warning_gdb_index_re \
131 [multi_line \
132 "warning: Skipping \[^\r\n\]+ .gdb_index section in \[^\r\n\]+" \
133 "Do \"set use-deprecated-index-sections on\" before the file is read" \
359efc2d 134 "to use the section anyway\\.\r\n"]
cf4505a7 135set reading_re \
359efc2d 136 "Reading \[^\r\n\]+\r\n"
c0ae8ccd
TV
137set libthread_db_re \
138 [multi_line \
139 "\\\[Thread debugging using libthread_db enabled\\\]" \
359efc2d 140 "Using host libthread_db library \[^\r\n\]+\r\n"]
cf4505a7 141
359efc2d 142set optional_re \
cf4505a7 143 [list \
359efc2d
TV
144 "\(" \
145 "\($reading_re)" \
146 "|" \
147 "\($warning_slow_re\)" \
148 "|" \
149 "\($libthread_db_re\)" \
150 "|" \
cf4505a7 151 "\(\r\n$warning_gdb_index_re\)?" \
359efc2d
TV
152 "\)*"]
153set optional_re [join $optional_re ""]
154
155set run_re \
156 [list \
157 "\r\n\032\032post-prompt\r\n" \
158 "Starting program: $binexp \r\n" \
159 $optional_re \
04f4c17c
TV
160 "\(\r\n\032\032breakpoints-invalid\r\n\)?" \
161 $optional_re \
359efc2d
TV
162 "\r\n\032\032starting\r\n" \
163 $optional_re \
164 "\r\n\032\032frames-invalid\r\n" \
165 $optional_re \
166 "\r\n\032\032breakpoints-invalid\r\n" \
167 $optional_re \
168 "\r\n\032\032breakpoint 1\r\n" \
169 "\r\n" \
170 "Breakpoint 1, " \
171 "\r\n\032\032frame-begin 0 $hex\r\n" \
172 "\r\n\032\032frame-function-name\r\n" \
173 "main" \
174 "\r\n\032\032frame-args\r\n" \
175 " \\(\\)" \
176 "\r\n\032\032frame-source-begin\r\n" \
177 " at " \
178 "\r\n\032\032frame-source-file\r\n" \
179 ".*annota1.c" \
180 "\r\n\032\032frame-source-file-end\r\n" \
181 ":" \
182 "\r\n\032\032frame-source-line\r\n" \
183 "$main_line" \
184 "\r\n\032\032frame-source-end\r\n" \
185 "\r\n" \
186 "\r\n\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n" \
187 "\r\n\032\032frame-end\r\n" \
188 "\r\n\032\032stopped\r\n"]
cf4505a7
TV
189
190set run_re [join $run_re ""]
c9923e71
PA
191
192gdb_test_multiple "run" "run until main breakpoint" {
cf4505a7 193 -re $run_re.*$gdb_prompt$ {
3d63690a 194 pass $gdb_test_name
7346e70f 195 }
6acb16a2 196}
392a587b
JM
197#exp_internal 0
198#exit 0
a4cb37cb
SS
199
200#
201# Let's do a next, to get to a point where the array is initialized
202# We don't care about the annotated output for this operation, it is the same as
203# the one produced by run above
204#
6acb16a2
MS
205gdb_test_multiple "next" "go after array init line" {
206 -re "source .*annota1.c.*$gdb_prompt$" {
3d63690a 207 pass $gdb_test_name
6acb16a2 208 }
a4cb37cb
SS
209}
210
211
212#
213# printing the array will test:
214# annotate-value-history-begin
215# annotate-value-history-value
216# annotate-array-section-begin
217# annotate-elt
218# FIXME: annotate-elt-rep and annotate-elt-rep-end not tested
219# annotate-array-section-end
220# annotate-value-history-end
221# FIXME: annotate-value-begin and annotate-value-end not tested (the gdb output
222# command would cause them to be used)
223#
6acb16a2
MS
224gdb_test_multiple "print my_array" "print array" {
225 -re "\r\n\032\032post-prompt\r\n\r\n\032\032value-history-begin 1 -\r\n.*= \r\n\032\032value-history-value\r\n.\r\n\032\032array-section-begin 0 -\r\n1\r\n\032\032elt\r\n, 2\r\n\032\032elt\r\n, 3\r\n\032\032elt\r\n\r\n\032\032array-section-end\r\n.\r\n\r\n\032\032value-history-end\r\n$gdb_prompt$" {
3d63690a 226 pass $gdb_test_name
6acb16a2 227 }
a4cb37cb
SS
228}
229
230
231#
232# this should generate an error message, so to test:
233# annotate-error-begin
234# FIXME: annotate-error not tested
235#
236
237#exp_internal 1
6acb16a2
MS
238gdb_test_multiple "print non_existent_value" "print non_existent_value" {
239 -re "\r\n\032\032post-prompt\r\n\r\n\032\032error-begin\r\nNo symbol \"non_existent_value\" in current context.\r\n\r\n\032\032error\r\n$gdb_prompt$" {
3d63690a 240 pass $gdb_test_name
6acb16a2 241 }
a4cb37cb
SS
242}
243
244
245#
246# break at signal handler. So that, once we are in the sig handler, if we do a bt
247# we can test annotate-signal-handler-caller
248#
6acb16a2 249gdb_test_multiple "break handle_USR1" "break handle_USR1" {
9c97429f 250 -re "\r\n\032\032post-prompt\r\nBreakpoint.*at $hex: file.*$srcfile, line.*\r\n\032\032breakpoints-invalid\r\n.*$gdb_prompt$" {
3d63690a 251 pass $gdb_test_name
6acb16a2 252 }
a4cb37cb
SS
253}
254
255#
256# break at printf. When we are stopped at printf, we can test
257#
6acb16a2 258gdb_test_multiple "break printf" "break printf" {
9c97429f 259 -re "\r\n\032\032post-prompt\r\nBreakpoint.*at $hex.*\032\032breakpoints-invalid\r\n.*$gdb_prompt$" {
3d63690a 260 pass $gdb_test_name
6acb16a2
MS
261 }
262 -re "\r\n\032\032post-prompt\r\nwarning: Breakpoint address adjusted from $hex to $hex.\r\n\r\n\032\032breakpoints-invalid\r\nBreakpoint.*at $hex.*$gdb_prompt$" {
3d63690a 263 pass $gdb_test_name
6acb16a2 264 }
a4cb37cb
SS
265}
266
267#
268# get to printf
269#
6ad82919 270set pat_begin "\r\n\032\032post-prompt\r\nContinuing.\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\n${breakpoints_invalid}\r\n\032\032frames-invalid\r\n"
2fa63963 271set pat_adjust "warning: Breakpoint 3 address previously adjusted from $hex to $hex.\r\n"
e8f97270 272set pat_end "\r\n\032\032breakpoint 3\r\n\r\nBreakpoint 3, \r\n\032\032frame-begin 0 $hex\r\n\r\n(\032\032frame-address\r\n$hex\r\n\032\032frame-address-end\r\n in \r\n)*.*\032\032frame-function-name\r\n.*printf(@.*)?\r\n\032\032frame-args\r\n.*\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$"
8c8f4ebe 273
2fa63963
DJ
274gdb_test_multiple "continue" "continue to printf" {
275 -re "${pat_begin}($pat_adjust)?$pat_end" {
3d63690a 276 pass $gdb_test_name
2fa63963 277 }
3d63690a 278 -re ".*$gdb_prompt$" { fail $gdb_test_name }
a4cb37cb
SS
279}
280
281#
282# test:
283# annotate-frame-where
284# annotate-frame-address
285# annotate-frame-address-end
286#
2bcfdb75
TV
287set pat_begin \
288 [list \
289 "\r\n\032\032post-prompt\r\n" \
290 "\r\n\032\032frame-begin 0 $hex\r\n" \
291 ".0 \r\n" \
292 "(" \
293 "\032\032frame-address\r\n" \
294 "${hex}( \\\[PAC\\\])?" \
295 "\r\n\032\032frame-address-end\r\n" \
296 " in \r\n" \
297 ")*" \
298 "\032\032frame-function-name\r\n" \
299 ".*printf(@.*)?" \
300 "\r\n\032\032frame-args\r\n" \
301 " \\(.*frame-end\r\n" \
302 "\r\n\032\032frame-begin 1 $hex\r\n" \
303 ".1 " \
304 "\r\n\032\032frame-address\r\n" \
305 "${hex}( \\\[PAC\\\])?" \
306 "\r\n\032\032frame-address-end\r\n" \
307 " in " \
308 "\r\n\032\032frame-function-name\r\n" \
309 "main" \
310 "\r\n\032\032frame-args\r\n" \
311 " \\(\\)" \
312 "\r\n\032\032frame-source-begin\r\n" \
313 " at " \
314 "\r\n\032\032frame-source-file\r\n"]
315
316set pat_begin [join $pat_begin ""]
317
318set pat_end \
319 [list \
320 "\r\n\032\032frame-source-file-end\r\n" \
321 ":" \
322 "\r\n\032\032frame-source-line\r\n" \
323 ".*" \
324 "\r\n\032\032frame-source-end\r\n\r\n" \
325 "\r\n\032\032frame-end\r\n" \
326 "(" \
327 "\r\n\032\032frame-begin .*\r\n" \
328 "\r\n\032\032frame-end\r\n" \
329 ")*" \
330 "$gdb_prompt$"]
6acb16a2 331
2bcfdb75 332set pat_end [join $pat_end ""]
6acb16a2
MS
333
334gdb_test_multiple "backtrace" "backtrace from shlibrary" {
335 -re "$pat_begin$escapedsrcfile$pat_end" {
3d63690a 336 pass $gdb_test_name
6acb16a2
MS
337 }
338 -re "$pat_begin.*$srcfile$pat_end" {
e1692475 339 setup_xfail "*-*-*" 8375
3d63690a 340 fail $gdb_test_name
6acb16a2 341 }
a4cb37cb
SS
342}
343
344
345#
346# test printing a frame with some arguments:
347# annotate-arg-begin
348# annotate-arg-name-end
349# annotate-arg-value
350# annotate-arg-end
351#
a4cb37cb 352
ab618a02
MC
353if [target_info exists gdb,nosignals] {
354 unsupported "send SIGUSR1"
355 unsupported "backtrace @ signal handler"
356} else {
6acb16a2 357 gdb_test_multiple "signal SIGUSR1" "send SIGUSR1" {
7c13f4e8 358 -re "\r\n\032\032post-prompt\r\nContinuing with signal SIGUSR1.\r\n\r\n\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)+\r\n\r\n\032\032breakpoint 2\r\n\r\nBreakpoint 2, \r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nhandle_USR1\r\n\032\032frame-args\r\n \\(\r\n\032\032arg-begin\r\nsig\r\n\032\032arg-name-end\r\n=\r\n\032\032arg-value -\r\n$decimal\r\n\032\032arg-end\r\n\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n${escapedsrcfile}\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n.*\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source.*annota1.c:.*:.*:beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" {
3d63690a 359 pass $gdb_test_name
6acb16a2 360 }
7c13f4e8 361 -re "\r\n\032\032post-prompt\r\nContinuing with signal SIGUSR1.\r\n\r\n\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)+\r\n\r\n\032\032breakpoint 2\r\n\r\nBreakpoint 2, \r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nhandle_USR1\r\n\032\032frame-args\r\n \\(\r\n\032\032arg-begin\r\nsig\r\n\032\032arg-name-end\r\n=\r\n\032\032arg-value -\r\n$decimal\r\n\032\032arg-end\r\n\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n.*${srcfile}\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n.*\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source.*annota1.c:.*:.*:beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" {
e1692475 362 setup_xfail "*-*-*" 8375
3d63690a 363 fail $gdb_test_name
6acb16a2 364 }
ab618a02 365 }
a4cb37cb 366
ab618a02
MC
367 #
368 # test:
369 # annotate-signal-handler-caller
370 #
6acb16a2 371 gdb_test_multiple "backtrace" "backtrace @ signal handler" {
ab618a02 372 -re "frame-begin 0 $hex\r\n#0.*frame-end.*frame-begin 1 $hex\r\n#1.*(\032\032signal-handler-caller\r\n.signal handler called.\r\n\r\n)+\032\032frame-end\r\n\r\n\032\032frame-begin 2 $hex\r\n#2.*(frame-begin 3 $hex\r\n#3.*)*frame-end.*$gdb_prompt$" {
3d63690a 373 pass $gdb_test_name
ab618a02 374 }
0a791409 375 }
a4cb37cb
SS
376}
377
378#
379# delete all the breakpoints
380#
6acb16a2 381gdb_test_multiple "delete 1" "delete bp 1" {
9c97429f 382 -re "\r\n\032\032post-prompt\r\n${breakpoints_invalid}$gdb_prompt$" {
3d63690a 383 pass $gdb_test_name
6acb16a2 384 }
a4cb37cb
SS
385}
386
6acb16a2 387gdb_test_multiple "delete 2" "delete bp 2" {
9c97429f 388 -re "\r\n\032\032post-prompt\r\n${breakpoints_invalid}$gdb_prompt$" {
3d63690a 389 pass $gdb_test_name
6acb16a2 390 }
a4cb37cb
SS
391}
392
6acb16a2 393gdb_test_multiple "delete 3" "delete bp 3" {
9c97429f 394 -re "\r\n\032\032post-prompt\r\n${breakpoints_invalid}$gdb_prompt$" {
3d63690a 395 pass $gdb_test_name
6acb16a2 396 }
a4cb37cb
SS
397}
398
399#
495346f6 400# break in main, after value is initialized. This is in preparation
a4cb37cb
SS
401# to test the annotate output for the display command.
402#
3d63690a 403gdb_test_multiple "break ${srcfile}:${main_line}" "break in main" {
9c97429f 404 -re "post-prompt.*Breakpoint 4 at $hex: file ${escapedsrcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" {
3d63690a 405 pass $gdb_test_name
6acb16a2 406 }
9c97429f 407 -re "post-prompt.*Breakpoint 4 at $hex: file .*${srcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" {
e1692475 408 setup_xfail "*-*-*" 8375
3d63690a 409 fail $gdb_test_name
6acb16a2 410 }
a4cb37cb
SS
411}
412
413#
414# display the value; test:
415# annotate-display-begin
416# annotate-display-number-end
417# annotate-display-format
418# annotate-display-expression
419# annotate-display-expression-end
420# annotate-display-end
421# FIXME: annotate-display-value not tested
422#
6acb16a2
MS
423gdb_test_multiple "display value" "set up display" {
424 -re "post-prompt\r\n\r\n\032\032display-begin\r\n1\r\n\032\032display-number-end\r\n: \r\n\032\032display-format\r\n\r\n\032\032display-expression\r\nvalue\r\n\032\032display-expression-end\r\n = \r\n\032\032display-expression\r\n7\r\n\r\n\032\032display-end\r\n$gdb_prompt$" {
425 pass "set up display"
426 }
a4cb37cb
SS
427}
428
c715d073
PA
429# Get the core into the output directory.
430if {![is_remote host]} {
431 gdb_test -prompt "$gdb_prompt$" \
432 "set cwd [file dirname $binfile]" "" \
433 "set inferior cwd to test directory"
434}
a4cb37cb
SS
435
436# should ask query. Test annotate-query.
437# we don't care about anything else here, only the query.
438
439send_gdb "run\n"
440gdb_expect {
441 -re "pre-query.*already.*\\(y or n\\).*query\r\n" {
442 send_gdb "y\n"
443 gdb_expect {
444 -re ".*post-query.*$gdb_prompt$" \
445 { pass "re-run" }
446 -re ".*$gdb_prompt$" { fail "re-run" }
447 timeout { fail "re-run (timeout)" }
448 }
449 }
450 -re ".*$gdb_prompt$" { fail "re-run" }
451 timeout { fail "re-run (timeout)" }
452}
453
5c44784c
JM
454#
455# Test that breakpoints-invalid is issued once and only once for
456# breakpoint ignore count changes, after annotation stopped.
457#
2c8910ba
TS
458
459set value_inc_line [gdb_get_line_number "increment value"]
460
461gdb_test_multiple "break $value_inc_line" "break at value++" {
462 -re "Breakpoint 5 at $hex: file .*$srcfile, line $value_inc_line.*$gdb_prompt$" {
463 pass "break at value++"
5c44784c 464 }
5c44784c
JM
465}
466
6acb16a2 467gdb_test_multiple "ignore 5 4" "ignore 5 4" {
5c44784c
JM
468 -re "Will ignore next 4 crossings of breakpoint 5.*$gdb_prompt$" {
469 pass "ignore 5 4"
470 }
5c44784c
JM
471}
472
6acb16a2 473gdb_test_multiple "continue" "annotate ignore count change" {
187d10dd
PA
474 -re ".*breakpoints-invalid.*breakpoints-invalid.*$gdb_prompt$" {
475 fail "annotate ignore count change"
476 }
477 -re ".*$srcfile:$value_inc_line:.*\032\032stopped\r\n$gdb_prompt$" {
5c44784c
JM
478 pass "annotate ignore count change"
479 }
5c44784c
JM
480}
481
482# check that ignore command is working, or the above can provide
483# misleading assurance ...
484
6acb16a2
MS
485gdb_test_multiple "next" "next to exit loop" {
486 -re "source .*annota1.c.*$gdb_prompt$" {
487 }
5c44784c
JM
488}
489
2c8910ba
TS
490set after_loop_line [gdb_get_line_number "after loop"]
491
6acb16a2 492gdb_test_multiple "next" "breakpoint ignore count" {
2c8910ba 493 -re ".*$srcfile:$after_loop_line:.*$gdb_prompt$" {
5c44784c
JM
494 pass "breakpoint ignore count"
495 }
5c44784c 496}
a4cb37cb 497
a391a2f6
PA
498# Get the inferior's PID for later.
499
a391a2f6 500set pid -1
3d63690a 501gdb_test_multiple "info inferior 1" "get inferior pid" {
a391a2f6
PA
502 -re "process (\[0-9\]*).*$gdb_prompt$" {
503 set pid $expect_out(1,string)
3d63690a 504 pass $gdb_test_name
a391a2f6
PA
505 }
506}
507
a4cb37cb
SS
508#
509# Send a signal that is not handled; test:
510# annotate-signalled
511# annotate-signal-name
512# annotate-signal-name-end
513# annotate-signal-string
514# annotate-signal-string-end
515# FIXME: annotate-signal not tested (requires that the inferior be
516# stopped by a "random" signal)
ab618a02
MC
517
518if [target_info exists gdb,nosignals] {
519 unsupported "signal sent"
520} else {
6acb16a2 521 gdb_test_multiple "signal SIGTRAP" "signal sent" {
1a3da2cd 522 -re ".*\032\032post-prompt\r\nContinuing with signal SIGTRAP.\r\n\r\n\032\032starting\(\r\n\r\n\032\032frames-invalid\)+\r\n\r\n\032\032signalled\r\n\r\nProgram terminated with signal \r\n\032\032signal-name\r\nSIGTRAP\r\n\032\032signal-name-end\r\n, \r\n\032\032signal-string\r\nTrace.breakpoint trap\r\n\032\032signal-string-end\r\n.\r\nThe program no longer exists.\r\n\r\n\032\032thread-exited,id=\"${decimal}\",group-id=\"i${decimal}\"\r\n\r\n\032\032stopped\r\n$gdb_prompt$" {
3d63690a 523 pass $gdb_test_name
6acb16a2 524 }
ab618a02 525 }
a4cb37cb
SS
526}
527
419e626b 528# Check for production of a core file and remove it!
c715d073 529remove_core $pid
a4cb37cb 530
79afeace 531proc thread_test {} {
a7b796db 532 global subdir srcdir testfile srcfile binfile
79afeace 533 global gdb_prompt old_gdb_prompt
1a3da2cd 534 global decimal
aa81e255 535 set srcfile watch_thread_num.c
a64d2530 536 set binfile [standard_output_file ${testfile}-watch_thread_num]
79afeace
NR
537 set gdb_prompt $old_gdb_prompt
538
9704b8b4 539 if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] == "" } {
79afeace 540
c95d486d 541 clean_restart $binfile
65a33d75 542 if {![runto_main]} {
79afeace
NR
543 return
544 }
545
a7b796db
PA
546 set linenum [gdb_get_line_number "all threads started"]
547 gdb_breakpoint "$linenum"
548
1a3da2cd
AB
549 set linenum [gdb_get_line_number "first child thread exited"]
550 gdb_breakpoint "$linenum"
551
79afeace
NR
552 set gdb_prompt \
553 "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n"
554
6acb16a2
MS
555 gdb_test_multiple "set annotate 2" "" {
556 -re "set annotate 2\r\n$gdb_prompt$" {
557 }
79afeace
NR
558 }
559
a7b796db
PA
560 gdb_test_multiple "continue" "new thread" {
561 -re "\032\032new-thread.*\r\n$gdb_prompt$" {
3d63690a 562 pass $gdb_test_name
79afeace 563 }
79afeace 564 }
1a3da2cd
AB
565
566 gdb_test_multiple "continue" "thread exit" {
567 -re "\032\032thread-exited,id=\"${decimal}\",group-id=\"i${decimal}\".*\r\n$gdb_prompt$" {
3d63690a 568 pass $gdb_test_name
1a3da2cd
AB
569 }
570 }
79afeace
NR
571 }
572}
573
47741aa5 574proc thread_switch {} {
6acb16a2
MS
575 gdb_test_multiple "thread 1" "thread switch" {
576 -re ".*\032\032thread-changed" {
3d63690a 577 pass $gdb_test_name
47741aa5 578 }
6acb16a2 579 }
47741aa5
NR
580}
581
79afeace 582thread_test
47741aa5 583thread_switch
79afeace 584
a4cb37cb
SS
585# restore the original prompt for the rest of the testsuite
586
587set gdb_prompt $old_gdb_prompt