1 1.1.1.3 christos # Copyright 2015-2024 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos # Check that letting the inferior exit and restarting it again resets 17 1.1 christos # the global TID counter, and thus the new thread 1.1 should end up 18 1.1 christos # with global TID == 1. 19 1.1 christos # 20 1.1 christos # Also, check the same but with another inferior still running, in 21 1.1 christos # which case the new thread 1.1 should end up with global TID == 3. 22 1.1 christos 23 1.1 christos standard_testfile 24 1.1 christos 25 1.1.1.2 christos if { [build_executable "failed to prepare" ${testfile} ${srcfile} \ 26 1.1.1.2 christos {pthreads debug}] } { 27 1.1 christos return -1 28 1.1 christos } 29 1.1 christos 30 1.1 christos with_test_prefix "single-inferior" { 31 1.1 christos with_test_prefix "before restart" { 32 1.1 christos clean_restart ${testfile} 33 1.1 christos 34 1.1.1.2 christos if {![runto_main]} { 35 1.1 christos return -1 36 1.1 christos } 37 1.1 christos 38 1.1 christos gdb_test "info threads -gid" "\\* 1 +1 +.*" 39 1.1 christos } 40 1.1 christos 41 1.1 christos with_test_prefix "restart" { 42 1.1 christos gdb_continue_to_end 43 1.1.1.2 christos if {![runto_main]} { 44 1.1 christos return -1 45 1.1 christos } 46 1.1 christos } 47 1.1 christos 48 1.1 christos with_test_prefix "after restart" { 49 1.1 christos gdb_test "info threads -gid" "\\* 1 +1 +.*" 50 1.1 christos } 51 1.1 christos } 52 1.1 christos 53 1.1 christos # For the following tests, multiple inferiors are needed, therefore 54 1.1 christos # non-extended gdbserver is not supported. 55 1.1.1.3 christos require !use_gdb_stub 56 1.1 christos 57 1.1 christos # Test with multiple inferiors. This time, since we restart inferior 58 1.1 christos # 1 while inferior 2 still has threads, then the new thread 1.1 should 59 1.1 christos # end up with GID == 3, since we won't be able to reset the global 60 1.1 christos # thread ID counter. 61 1.1 christos with_test_prefix "multi-inferior" { 62 1.1 christos gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2" 63 1.1 christos gdb_test "inferior 2" "Switching to inferior 2 .*" "switch to inferior 2" 64 1.1 christos gdb_load ${binfile} 65 1.1 christos 66 1.1.1.2 christos if {![runto_main]} { 67 1.1 christos return 68 1.1 christos } 69 1.1 christos 70 1.1 christos gdb_test "inferior 1" "Switching to inferior 1 .*" \ 71 1.1 christos "switch back to inferior 1" 72 1.1 christos 73 1.1 christos with_test_prefix "before restart" { 74 1.1 christos gdb_test "info threads -gid" \ 75 1.1 christos [multi_line \ 76 1.1 christos "\\* 1\.1 +1 +.*" \ 77 1.1 christos " 2\.1 +2 +.*"] 78 1.1 christos } 79 1.1 christos 80 1.1 christos with_test_prefix "restart" { 81 1.1 christos gdb_continue_to_end 82 1.1.1.2 christos if {![runto_main]} { 83 1.1 christos return -1 84 1.1 christos } 85 1.1 christos } 86 1.1 christos 87 1.1 christos with_test_prefix "after restart" { 88 1.1 christos gdb_test "info threads -gid" \ 89 1.1 christos [multi_line \ 90 1.1 christos "\\* 1\.1 +3 +.*" \ 91 1.1 christos " 2\.1 +2 +.*"] 92 1.1 christos } 93 1.1 christos } 94