Commit | Line | Data |
---|---|---|
873657b9 PA |
1 | # Copyright 2015-2020 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 { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {pthreads debug}] } { | |
26 | return -1 | |
27 | } | |
28 | ||
29 | with_test_prefix "single-inferior" { | |
30 | with_test_prefix "before restart" { | |
31 | clean_restart ${testfile} | |
32 | ||
33 | if { ![runto_main] } then { | |
34 | return -1 | |
35 | } | |
36 | ||
37 | gdb_test "info threads -gid" "\\* 1 +1 +.*" | |
38 | } | |
39 | ||
40 | with_test_prefix "restart" { | |
41 | gdb_continue_to_end | |
42 | if { ![runto_main] } then { | |
43 | return -1 | |
44 | } | |
45 | } | |
46 | ||
47 | with_test_prefix "after restart" { | |
48 | gdb_test "info threads -gid" "\\* 1 +1 +.*" | |
49 | } | |
50 | } | |
51 | ||
52 | # For the following tests, multiple inferiors are needed, therefore | |
53 | # non-extended gdbserver is not supported. | |
54 | if [use_gdb_stub] { | |
55 | untested "using gdb stub" | |
56 | return | |
57 | } | |
58 | ||
59 | # Test with multiple inferiors. This time, since we restart inferior | |
60 | # 1 while inferior 2 still has threads, then the new thread 1.1 should | |
61 | # end up with GID == 3, since we won't be able to reset the global | |
62 | # thread ID counter. | |
63 | with_test_prefix "multi-inferior" { | |
64 | gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2" | |
65 | gdb_test "inferior 2" "Switching to inferior 2 .*" "switch to inferior 2" | |
66 | gdb_load ${binfile} | |
67 | ||
68 | if ![runto_main] then { | |
69 | fail "starting inferior 2" | |
70 | return | |
71 | } | |
72 | ||
73 | gdb_test "inferior 1" "Switching to inferior 1 .*" \ | |
74 | "switch back to inferior 1" | |
75 | ||
76 | with_test_prefix "before restart" { | |
77 | gdb_test "info threads -gid" \ | |
78 | [multi_line \ | |
79 | "\\* 1\.1 +1 +.*" \ | |
80 | " 2\.1 +2 +.*"] | |
81 | } | |
82 | ||
83 | with_test_prefix "restart" { | |
84 | gdb_continue_to_end | |
85 | if { ![runto_main] } then { | |
86 | return -1 | |
87 | } | |
88 | } | |
89 | ||
90 | with_test_prefix "after restart" { | |
91 | gdb_test "info threads -gid" \ | |
92 | [multi_line \ | |
93 | "\\* 1\.1 +3 +.*" \ | |
94 | " 2\.1 +2 +.*"] | |
95 | } | |
96 | } |