Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / annota1.exp
CommitLineData
88b9d363 1# Copyright 1999-2022 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#
300b6685 22if ![target_can_use_run_cmd] {
fc33412a
DT
23 return 0
24}
25
9c97429f 26set breakpoints_invalid "\r\n\032\032breakpoints-invalid\r\n"
fc33412a 27
a4cb37cb
SS
28#
29# test running programs
30#
a4cb37cb 31
a64d2530 32standard_testfile .c
a4cb37cb 33
fc91c6c2 34if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
84c93cd5 35 untested "failed to compile"
b60f0898 36 return -1
a4cb37cb
SS
37}
38
39
a64d2530 40clean_restart ${binfile}
a4cb37cb 41
a4cb37cb
SS
42# The commands we test here produce many lines of output; disable "press
43# <return> to continue" prompts.
6acb16a2 44gdb_test_no_output "set height 0"
a4cb37cb
SS
45
46#
495346f6 47# break in main
a4cb37cb 48#
2c8910ba
TS
49
50set main_line [gdb_get_line_number "break main"]
51
495346f6 52gdb_test "break ${srcfile}:${main_line}" \
2c8910ba 53 "Breakpoint.*at.* file .*$srcfile, line $main_line\\." \
a4cb37cb
SS
54 "breakpoint main"
55
56
57#
58# NOTE: this prompt is OK only when the annotation level is > 1
59# NOTE: When this prompt is in use the gdb_test procedure cannot be used because
60# it assumes that the last char after the gdb_prompt is a white space. This is not
61# true with this annotated prompt. So we must use send_gdb and gdb_expect.
62#
63
64set old_gdb_prompt $gdb_prompt
65set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n"
66
d99968dc
EZ
67#
68# Escape all the characters in the path that need it. For instance
69# the directory name could contain '+'.
70#
71set escapedsrcfile [string_to_regexp ${srcdir}/${subdir}/${srcfile}]
a4cb37cb
SS
72
73
74#
75# set the annotation level to 2
76#
77# of course, this will test:
78# annotate-pre-prompt
79# annotate-prompt
80# annotate-post-prompt (in the next block)
81#
82send_gdb "set annotate 2\n"
83gdb_expect {
84 -re "set annotate 2\r\n$gdb_prompt$" { pass "annotation set at level 2" }
85 -re ".*$gdb_prompt$" { fail "annotation set at level 2" }
86 timeout { fail "annotation set at level 2 (timeout)" }
87 }
88
89
90#
91# info break will test:
92# annotate-breakpoints-headers
93# annotate-field
94# annotate-breakpoints-table
95# annotate-record
96# annotate-breakpoints-table-end
97#
6acb16a2
MS
98gdb_test_multiple "info break" "breakpoint info" {
99 -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 100 pass $gdb_test_name
6acb16a2
MS
101 }
102 -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$" {
103 setup_xfail "*-*-*" 1270
3d63690a 104 fail $gdb_test_name
6acb16a2 105 }
a4cb37cb
SS
106}
107
108
109#
110# run to a break point will test:
111# annotate-frames-invalid
112# annotate-breakpoints-invalid (a.k.a. breakpoints-changed)
113# annotate-starting
114# annotate-breakpoint
115# annotate-frame-begin
116# annotate-frame-function-name
117# annotate-frame-args
118# annotate-frame-source-begin
119# annotate-frame-source-file
120# annotate-frame-source-file-end
121# annotate-frame-source-line
122# annotate-frame-source-end
123# annotate-source
124# annotate-frame-end
125# annotate-stopped
126#
392a587b 127#exp_internal 1
8c008720 128set binexp [string_to_regexp $binfile]
c9923e71
PA
129
130set run_re [join [list "\r\n\032\032post-prompt\r\nStarting program: $binexp " \
b001de23
AB
131 "\(\(\r\nReading \[^\r\n\]+\)|\(\r\nwarning: File transfers from remote targets can be slow\[^\r\n\]+\)\)*" \
132 "\(\r\nwarning: Skipping \[^\r\n\]+ .gdb_index section in \[^\r\n\]+\r\nDo \"set use-deprecated-index-sections on\" before the file is read\r\nto use the section anyway\\.\)?" \
133 "\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \
134 "\032\032starting\(\(\r\nReading \[^\r\n\]+\)|\(\r\nwarning: File transfers from remote targets can be slow\[^\r\n\]+\)\)*" \
135 "\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \
136 "\032\032breakpoint 1\r\n\r\n" \
137 "Breakpoint 1, \r\n" \
138 "\032\032frame-begin 0 $hex\r\n\r\n" \
139 "\032\032frame-function-name\r\n" \
140 "main\r\n" \
141 "\032\032frame-args\r\n \\(\\)\r\n" \
142 "\032\032frame-source-begin\r\n at \r\n" \
143 "\032\032frame-source-file\r\n.*annota1.c\r\n" \
144 "\032\032frame-source-file-end\r\n:\r\n" \
145 "\032\032frame-source-line\r\n$main_line\r\n" \
146 "\032\032frame-source-end\r\n\r\n\r\n" \
147 "\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n\r\n" \
148 "\032\032frame-end\r\n\r\n" \
c9923e71
PA
149 "\032\032stopped.*$gdb_prompt$" ] "" ]
150
151gdb_test_multiple "run" "run until main breakpoint" {
152 -re $run_re {
3d63690a 153 pass $gdb_test_name
7346e70f 154 }
6acb16a2 155}
392a587b
JM
156#exp_internal 0
157#exit 0
a4cb37cb
SS
158
159#
160# Let's do a next, to get to a point where the array is initialized
161# We don't care about the annotated output for this operation, it is the same as
162# the one produced by run above
163#
6acb16a2
MS
164gdb_test_multiple "next" "go after array init line" {
165 -re "source .*annota1.c.*$gdb_prompt$" {
3d63690a 166 pass $gdb_test_name
6acb16a2 167 }
a4cb37cb
SS
168}
169
170
171#
172# printing the array will test:
173# annotate-value-history-begin
174# annotate-value-history-value
175# annotate-array-section-begin
176# annotate-elt
177# FIXME: annotate-elt-rep and annotate-elt-rep-end not tested
178# annotate-array-section-end
179# annotate-value-history-end
180# FIXME: annotate-value-begin and annotate-value-end not tested (the gdb output
181# command would cause them to be used)
182#
6acb16a2
MS
183gdb_test_multiple "print my_array" "print array" {
184 -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 185 pass $gdb_test_name
6acb16a2 186 }
a4cb37cb
SS
187}
188
189
190#
191# this should generate an error message, so to test:
192# annotate-error-begin
193# FIXME: annotate-error not tested
194#
195
196#exp_internal 1
6acb16a2
MS
197gdb_test_multiple "print non_existent_value" "print non_existent_value" {
198 -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 199 pass $gdb_test_name
6acb16a2 200 }
a4cb37cb
SS
201}
202
203
204#
205# break at signal handler. So that, once we are in the sig handler, if we do a bt
206# we can test annotate-signal-handler-caller
207#
6acb16a2 208gdb_test_multiple "break handle_USR1" "break handle_USR1" {
9c97429f 209 -re "\r\n\032\032post-prompt\r\nBreakpoint.*at $hex: file.*$srcfile, line.*\r\n\032\032breakpoints-invalid\r\n.*$gdb_prompt$" {
3d63690a 210 pass $gdb_test_name
6acb16a2 211 }
a4cb37cb
SS
212}
213
214#
215# break at printf. When we are stopped at printf, we can test
216#
6acb16a2 217gdb_test_multiple "break printf" "break printf" {
9c97429f 218 -re "\r\n\032\032post-prompt\r\nBreakpoint.*at $hex.*\032\032breakpoints-invalid\r\n.*$gdb_prompt$" {
3d63690a 219 pass $gdb_test_name
6acb16a2
MS
220 }
221 -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 222 pass $gdb_test_name
6acb16a2 223 }
a4cb37cb
SS
224}
225
226#
227# get to printf
228#
6ad82919 229set 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 230set pat_adjust "warning: Breakpoint 3 address previously adjusted from $hex to $hex.\r\n"
e8f97270 231set 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 232
2fa63963
DJ
233gdb_test_multiple "continue" "continue to printf" {
234 -re "${pat_begin}($pat_adjust)?$pat_end" {
3d63690a 235 pass $gdb_test_name
2fa63963 236 }
3d63690a 237 -re ".*$gdb_prompt$" { fail $gdb_test_name }
a4cb37cb
SS
238}
239
240#
241# test:
242# annotate-frame-where
243# annotate-frame-address
244# annotate-frame-address-end
245#
e8f97270 246set pat_begin "\r\n\032\032post-prompt\r\n\r\n\032\032frame-begin 0 $hex\r\n.0 \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 \\(.*frame-end\r\n\r\n\032\032frame-begin 1 $hex\r\n.1 \r\n\032\032frame-address\r\n$hex\r\n\032\032frame-address-end\r\n in \r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n"
6acb16a2 247
2fa63963 248set pat_end "\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\032frame-end\r\n(\r\n\032\032frame-begin .*\r\n\r\n\032\032frame-end\r\n)*$gdb_prompt$"
6acb16a2
MS
249
250gdb_test_multiple "backtrace" "backtrace from shlibrary" {
251 -re "$pat_begin$escapedsrcfile$pat_end" {
3d63690a 252 pass $gdb_test_name
6acb16a2
MS
253 }
254 -re "$pat_begin.*$srcfile$pat_end" {
255 setup_xfail "*-*-*" 1270
3d63690a 256 fail $gdb_test_name
6acb16a2 257 }
a4cb37cb
SS
258}
259
260
261#
262# test printing a frame with some arguments:
263# annotate-arg-begin
264# annotate-arg-name-end
265# annotate-arg-value
266# annotate-arg-end
267#
a4cb37cb 268
ab618a02
MC
269if [target_info exists gdb,nosignals] {
270 unsupported "send SIGUSR1"
271 unsupported "backtrace @ signal handler"
272} else {
6acb16a2 273 gdb_test_multiple "signal SIGUSR1" "send SIGUSR1" {
7c13f4e8 274 -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 275 pass $gdb_test_name
6acb16a2 276 }
7c13f4e8 277 -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$" {
6acb16a2 278 setup_xfail "*-*-*" 1270
3d63690a 279 fail $gdb_test_name
6acb16a2 280 }
ab618a02 281 }
a4cb37cb 282
ab618a02
MC
283 #
284 # test:
285 # annotate-signal-handler-caller
286 #
6acb16a2 287 gdb_test_multiple "backtrace" "backtrace @ signal handler" {
ab618a02 288 -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 289 pass $gdb_test_name
ab618a02 290 }
0a791409 291 }
a4cb37cb
SS
292}
293
294#
295# delete all the breakpoints
296#
6acb16a2 297gdb_test_multiple "delete 1" "delete bp 1" {
9c97429f 298 -re "\r\n\032\032post-prompt\r\n${breakpoints_invalid}$gdb_prompt$" {
3d63690a 299 pass $gdb_test_name
6acb16a2 300 }
a4cb37cb
SS
301}
302
6acb16a2 303gdb_test_multiple "delete 2" "delete bp 2" {
9c97429f 304 -re "\r\n\032\032post-prompt\r\n${breakpoints_invalid}$gdb_prompt$" {
3d63690a 305 pass $gdb_test_name
6acb16a2 306 }
a4cb37cb
SS
307}
308
6acb16a2 309gdb_test_multiple "delete 3" "delete bp 3" {
9c97429f 310 -re "\r\n\032\032post-prompt\r\n${breakpoints_invalid}$gdb_prompt$" {
3d63690a 311 pass $gdb_test_name
6acb16a2 312 }
a4cb37cb
SS
313}
314
315#
495346f6 316# break in main, after value is initialized. This is in preparation
a4cb37cb
SS
317# to test the annotate output for the display command.
318#
3d63690a 319gdb_test_multiple "break ${srcfile}:${main_line}" "break in main" {
9c97429f 320 -re "post-prompt.*Breakpoint 4 at $hex: file ${escapedsrcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" {
3d63690a 321 pass $gdb_test_name
6acb16a2 322 }
9c97429f 323 -re "post-prompt.*Breakpoint 4 at $hex: file .*${srcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" {
6acb16a2 324 setup_xfail "*-*-*" 1270
3d63690a 325 fail $gdb_test_name
6acb16a2 326 }
a4cb37cb
SS
327}
328
329#
330# display the value; test:
331# annotate-display-begin
332# annotate-display-number-end
333# annotate-display-format
334# annotate-display-expression
335# annotate-display-expression-end
336# annotate-display-end
337# FIXME: annotate-display-value not tested
338#
6acb16a2
MS
339gdb_test_multiple "display value" "set up display" {
340 -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$" {
341 pass "set up display"
342 }
a4cb37cb
SS
343}
344
345
346# should ask query. Test annotate-query.
347# we don't care about anything else here, only the query.
348
349send_gdb "run\n"
350gdb_expect {
351 -re "pre-query.*already.*\\(y or n\\).*query\r\n" {
352 send_gdb "y\n"
353 gdb_expect {
354 -re ".*post-query.*$gdb_prompt$" \
355 { pass "re-run" }
356 -re ".*$gdb_prompt$" { fail "re-run" }
357 timeout { fail "re-run (timeout)" }
358 }
359 }
360 -re ".*$gdb_prompt$" { fail "re-run" }
361 timeout { fail "re-run (timeout)" }
362}
363
5c44784c
JM
364#
365# Test that breakpoints-invalid is issued once and only once for
366# breakpoint ignore count changes, after annotation stopped.
367#
2c8910ba
TS
368
369set value_inc_line [gdb_get_line_number "increment value"]
370
371gdb_test_multiple "break $value_inc_line" "break at value++" {
372 -re "Breakpoint 5 at $hex: file .*$srcfile, line $value_inc_line.*$gdb_prompt$" {
373 pass "break at value++"
5c44784c 374 }
5c44784c
JM
375}
376
6acb16a2 377gdb_test_multiple "ignore 5 4" "ignore 5 4" {
5c44784c
JM
378 -re "Will ignore next 4 crossings of breakpoint 5.*$gdb_prompt$" {
379 pass "ignore 5 4"
380 }
5c44784c
JM
381}
382
6acb16a2 383gdb_test_multiple "continue" "annotate ignore count change" {
187d10dd
PA
384 -re ".*breakpoints-invalid.*breakpoints-invalid.*$gdb_prompt$" {
385 fail "annotate ignore count change"
386 }
387 -re ".*$srcfile:$value_inc_line:.*\032\032stopped\r\n$gdb_prompt$" {
5c44784c
JM
388 pass "annotate ignore count change"
389 }
5c44784c
JM
390}
391
392# check that ignore command is working, or the above can provide
393# misleading assurance ...
394
6acb16a2
MS
395gdb_test_multiple "next" "next to exit loop" {
396 -re "source .*annota1.c.*$gdb_prompt$" {
397 }
5c44784c
JM
398}
399
2c8910ba
TS
400set after_loop_line [gdb_get_line_number "after loop"]
401
6acb16a2 402gdb_test_multiple "next" "breakpoint ignore count" {
2c8910ba 403 -re ".*$srcfile:$after_loop_line:.*$gdb_prompt$" {
5c44784c
JM
404 pass "breakpoint ignore count"
405 }
5c44784c 406}
a4cb37cb 407
a391a2f6
PA
408# Get the inferior's PID for later.
409
a391a2f6 410set pid -1
3d63690a 411gdb_test_multiple "info inferior 1" "get inferior pid" {
a391a2f6
PA
412 -re "process (\[0-9\]*).*$gdb_prompt$" {
413 set pid $expect_out(1,string)
3d63690a 414 pass $gdb_test_name
a391a2f6
PA
415 }
416}
417
a4cb37cb
SS
418#
419# Send a signal that is not handled; test:
420# annotate-signalled
421# annotate-signal-name
422# annotate-signal-name-end
423# annotate-signal-string
424# annotate-signal-string-end
425# FIXME: annotate-signal not tested (requires that the inferior be
426# stopped by a "random" signal)
ab618a02
MC
427
428if [target_info exists gdb,nosignals] {
429 unsupported "signal sent"
430} else {
6acb16a2 431 gdb_test_multiple "signal SIGTRAP" "signal sent" {
1a3da2cd 432 -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 433 pass $gdb_test_name
6acb16a2 434 }
ab618a02 435 }
a4cb37cb
SS
436}
437
419e626b 438# Check for production of a core file and remove it!
a4cb37cb 439
419e626b 440set test "cleanup core file"
a391a2f6
PA
441if { [remote_file host exists core] } {
442 remote_file host delete core
443 pass "$test (removed)"
444} elseif { $pid != -1 && [remote_file host exists core.$pid] } {
445 remote_file host delete core.$pid
446 pass "$test (removed)"
a4cb37cb 447} else {
a391a2f6 448 pass "$test (not dumped)"
a4cb37cb
SS
449}
450
79afeace 451proc thread_test {} {
a7b796db 452 global subdir srcdir testfile srcfile binfile
79afeace 453 global gdb_prompt old_gdb_prompt
1a3da2cd 454 global decimal
aa81e255 455 set srcfile watch_thread_num.c
a64d2530 456 set binfile [standard_output_file ${testfile}-watch_thread_num]
79afeace
NR
457 set gdb_prompt $old_gdb_prompt
458
4c93b1db 459 if { ![get_compiler_info] && [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] == "" } {
79afeace
NR
460
461 gdb_exit
462 gdb_start
463 gdb_reinitialize_dir $srcdir/$subdir
464 gdb_load ${binfile}
50441f0f 465 if { ![runto_main] } then {
79afeace
NR
466 fail "run to main"
467 return
468 }
469
a7b796db
PA
470 set linenum [gdb_get_line_number "all threads started"]
471 gdb_breakpoint "$linenum"
472
1a3da2cd
AB
473 set linenum [gdb_get_line_number "first child thread exited"]
474 gdb_breakpoint "$linenum"
475
79afeace
NR
476 set gdb_prompt \
477 "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n"
478
6acb16a2
MS
479 gdb_test_multiple "set annotate 2" "" {
480 -re "set annotate 2\r\n$gdb_prompt$" {
481 }
79afeace
NR
482 }
483
a7b796db
PA
484 gdb_test_multiple "continue" "new thread" {
485 -re "\032\032new-thread.*\r\n$gdb_prompt$" {
3d63690a 486 pass $gdb_test_name
79afeace 487 }
79afeace 488 }
1a3da2cd
AB
489
490 gdb_test_multiple "continue" "thread exit" {
491 -re "\032\032thread-exited,id=\"${decimal}\",group-id=\"i${decimal}\".*\r\n$gdb_prompt$" {
3d63690a 492 pass $gdb_test_name
1a3da2cd
AB
493 }
494 }
79afeace
NR
495 }
496}
497
47741aa5 498proc thread_switch {} {
6acb16a2
MS
499 gdb_test_multiple "thread 1" "thread switch" {
500 -re ".*\032\032thread-changed" {
3d63690a 501 pass $gdb_test_name
47741aa5 502 }
6acb16a2 503 }
47741aa5
NR
504}
505
79afeace 506thread_test
47741aa5 507thread_switch
79afeace 508
a4cb37cb
SS
509# restore the original prompt for the rest of the testsuite
510
511set gdb_prompt $old_gdb_prompt
This page took 3.085763 seconds and 4 git commands to generate.