]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.threads/infcall-thread-announce.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / infcall-thread-announce.exp
1 # Copyright 2023-2024 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 3 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, see <http://www.gnu.org/licenses/>.
15
16 # Check that thread creation and thread exit events are correctly
17 # announced when a thread starts, or exits, as a result of an inferior
18 # function call from GDB.
19
20 standard_testfile
21
22 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] == -1} {
23 return -1
24 }
25
26 if ![runto_main] {
27 return -1
28 }
29
30 gdb_breakpoint breakpt
31 gdb_continue_to_breakpoint "first breakpt call"
32
33 set thr_count 1
34
35 proc check_thread_count { adjustment } {
36 incr ::thr_count $adjustment
37
38 gdb_test "p \$_inferior_thread_count" \
39 "^\\\$$::decimal = $::thr_count"
40 }
41
42 with_test_prefix "starting threads" {
43 gdb_test "call (void) start_thread()" \
44 "\\\[New Thread \[^\r\n\]+\\\]" \
45 "start a new thread, return value discarded"
46 check_thread_count +1
47
48 foreach_with_prefix call_type { print call } {
49 gdb_test "$call_type start_thread()" \
50 "\\\[New Thread \[^\r\n\]+\\\]\r\n\\\$$decimal = 1" \
51 "start another new thread"
52 check_thread_count +1
53 }
54 }
55
56 with_test_prefix "stopping threads" {
57 gdb_test "call (void) stop_thread()" \
58 "\\\[Thread \[^\r\n\]+ exited\\\]" \
59 "stop a thread, return value discarded"
60 check_thread_count -1
61
62 foreach_with_prefix call_type { print call } {
63 gdb_test "$call_type stop_thread()" \
64 "\\\[Thread \[^\r\n\]+ exited\\\]\r\n\\\$$decimal = 1" \
65 "stop another thread"
66 check_thread_count -1
67 }
68 }
69
70 gdb_continue_to_breakpoint "second breakpt call"
71 gdb_continue_to_end