Remove obsolete test from gdb.cp/var-tag.exp
[binutils-gdb.git] / gdb / testsuite / gdb.threads / threads-after-exec.exp
blob32aec6b39db5bfcaa342aebe5f5bf27fe791555d
1 # Copyright 2023-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Test that after an exec of a non-leader thread, we don't leave the
17 # non-leader thread listed in internal thread lists, causing problems.
19 standard_testfile .c
21 proc do_test { } {
22     if [prepare_for_testing "failed to prepare" $::testfile $::srcfile {debug pthreads}] {
23         return -1
24     }
26     if ![runto_main] {
27         return
28     }
30     gdb_test "catch exec" "Catchpoint $::decimal \\(exec\\)"
32     gdb_test "continue" "Catchpoint $::decimal .*" "continue until exec"
34     # Confirm we only have one thread in the thread list.
35     gdb_test "p \$_inferior_thread_count" " = 1"
37     # Get the post-exec thread number.  Due to PR gdb/31069 ("Zombie
38     # leader detection racy") this isn't always thread 1.1.
39     set cur_thr [get_integer_valueof "\$_thread" 0]
41     if {[istarget *-*-linux*] && [gdb_protocol_is_native]} {
42         # Confirm there's only one LWP in the list as well, and that
43         # it is bound to the existing GDB thread.
44         set inf_pid [get_inferior_pid]
45         gdb_test_multiple "maint info linux-lwps" "" {
46             -wrap -re "Thread ID *\r\n$inf_pid\.$inf_pid\.0\[ \t\]+1\.$cur_thr *" {
47                 pass $gdb_test_name
48             }
49         }
50     }
52     # Test that GDB is able to kill the inferior.  This used to crash
53     # on native Linux as GDB did not dispose of the pre-exec LWP for
54     # the non-leader (and that LWP did not have a matching thread in
55     # the core thread list).
56     gdb_test "with confirm off -- kill" \
57         "\\\[Inferior 1 (.*) killed\\\]" \
58         "kill inferior"
61 do_test