1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2016-2022 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 static volatile int unblock_main
[NUM_THREADS
];
29 child_sub_function (int child_idx
)
31 volatile int dummy
= 0;
33 unblock_main
[child_idx
] = 1;
36 /* Dummy loop body to allow setting breakpoint. */
37 dummy
= !dummy
; /* thread loop line */
41 child_function (void *args
)
43 int child_idx
= (int) (uintptr_t) args
;
45 child_sub_function (child_idx
); /* thread caller line */
54 pthread_t threads
[NUM_THREADS
];
56 /* Make the test exit eventually. */
59 for (i
= 0; i
< NUM_THREADS
; i
++)
60 pthread_create (&threads
[i
], NULL
, child_function
, (void *) (uintptr_t) i
);
62 /* Wait for child threads to reach child_sub_function. */
63 for (i
= 0; i
< NUM_THREADS
; i
++)
64 while (!unblock_main
[i
])
67 volatile int dummy
= 0;
69 /* Dummy loop body to allow setting breakpoint. */
70 dummy
= !dummy
; /* main break line */