xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.threads/fork-child-threads.exp (revision 8e33eff89e26cf71871ead62f0d5063e1313c33a)
1# Copyright (C) 2008-2023 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# Only GNU/Linux is known to support `set follow-fork-mode child'.
17if { ! [istarget "*-*-linux*"] } {
18    return 0
19}
20
21standard_testfile
22
23if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
24    return -1
25}
26
27clean_restart ${binfile}
28
29if {![runto_main]} {
30   return 0
31}
32
33gdb_test "set follow-fork-mode child"
34gdb_breakpoint "start"
35
36# Make sure we can step over fork without losing our breakpoint.
37gdb_test "next" ".*pthread_create \\(&thread, NULL, start, NULL\\);.*" "next over fork"
38
39gdb_test "continue" "Breakpoint 2, start.*" "get to the spawned thread"
40
41# Wrong:
42# * 2 LWP 4466  start (arg=0x0) at fork-child-threads.c:28
43# Correct:
44# * 3 Thread 0x40a00950 (LWP 5553)  start (arg=0x0) at ../.././gdb/testsuite/gdb.threads/fork-child-threads.c:28
45#   2 Thread 0x2aaaaaac3000 (LWP 5552)  0x00000031674076dd in pthread_join (threadid=<optimized out>, thread_return=<optimized out>) at pthread_join.c:89
46
47gdb_test "info threads" " Thread .* Thread .*" "two threads found"
48