]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.threads/threads-after-exec.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / threads-after-exec.exp
CommitLineData
1d506c26 1# Copyright 2023-2024 Free Software Foundation, Inc.
6a534f85
PA
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# 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.
18
19standard_testfile .c
20
21proc do_test { } {
22 if [prepare_for_testing "failed to prepare" $::testfile $::srcfile {debug pthreads}] {
23 return -1
24 }
25
26 if ![runto_main] {
27 return
28 }
29
30 gdb_test "catch exec" "Catchpoint $::decimal \\(exec\\)"
31
32 gdb_test "continue" "Catchpoint $::decimal .*" "continue until exec"
33
34 # Confirm we only have one thread in the thread list.
d2eca84d
PA
35 gdb_test "p \$_inferior_thread_count" " = 1"
36
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]
6a534f85
PA
40
41 if {[istarget *-*-linux*] && [gdb_is_target_native]} {
42 # Confirm there's only one LWP in the list as well, and that
d2eca84d 43 # it is bound to the existing GDB thread.
6a534f85
PA
44 set inf_pid [get_inferior_pid]
45 gdb_test_multiple "maint info linux-lwps" "" {
d2eca84d 46 -wrap -re "Thread ID *\r\n$inf_pid\.$inf_pid\.0\[ \t\]+1\.$cur_thr *" {
6a534f85
PA
47 pass $gdb_test_name
48 }
49 }
50 }
51
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"
59}
60
61do_test