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