tids-gid-reset.exp revision 1.1.1.3 1 # Copyright 2015-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 letting the inferior exit and restarting it again resets
17 # the global TID counter, and thus the new thread 1.1 should end up
18 # with global TID == 1.
19 #
20 # Also, check the same but with another inferior still running, in
21 # which case the new thread 1.1 should end up with global TID == 3.
22
23 standard_testfile
24
25 if { [build_executable "failed to prepare" ${testfile} ${srcfile} \
26 {pthreads debug}] } {
27 return -1
28 }
29
30 with_test_prefix "single-inferior" {
31 with_test_prefix "before restart" {
32 clean_restart ${testfile}
33
34 if {![runto_main]} {
35 return -1
36 }
37
38 gdb_test "info threads -gid" "\\* 1 +1 +.*"
39 }
40
41 with_test_prefix "restart" {
42 gdb_continue_to_end
43 if {![runto_main]} {
44 return -1
45 }
46 }
47
48 with_test_prefix "after restart" {
49 gdb_test "info threads -gid" "\\* 1 +1 +.*"
50 }
51 }
52
53 # For the following tests, multiple inferiors are needed, therefore
54 # non-extended gdbserver is not supported.
55 require !use_gdb_stub
56
57 # Test with multiple inferiors. This time, since we restart inferior
58 # 1 while inferior 2 still has threads, then the new thread 1.1 should
59 # end up with GID == 3, since we won't be able to reset the global
60 # thread ID counter.
61 with_test_prefix "multi-inferior" {
62 gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2"
63 gdb_test "inferior 2" "Switching to inferior 2 .*" "switch to inferior 2"
64 gdb_load ${binfile}
65
66 if {![runto_main]} {
67 return
68 }
69
70 gdb_test "inferior 1" "Switching to inferior 1 .*" \
71 "switch back to inferior 1"
72
73 with_test_prefix "before restart" {
74 gdb_test "info threads -gid" \
75 [multi_line \
76 "\\* 1\.1 +1 +.*" \
77 " 2\.1 +2 +.*"]
78 }
79
80 with_test_prefix "restart" {
81 gdb_continue_to_end
82 if {![runto_main]} {
83 return -1
84 }
85 }
86
87 with_test_prefix "after restart" {
88 gdb_test "info threads -gid" \
89 [multi_line \
90 "\\* 1\.1 +3 +.*" \
91 " 2\.1 +2 +.*"]
92 }
93 }
94