1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2009-2019 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/>. */
25 pthread_barrier_t barrier;
26 pthread_t child_thread_2, child_thread_3;
31 /* so that thread 3 is sure to run, in case the bug is present. */
41 child_function_3 (void *arg)
43 int my_number = (long) arg;
44 volatile int *myp = (int *) &args[my_number];
46 pthread_barrier_wait (&barrier);
50 (*myp) ++; /* set breakpoint child_two here */
58 child_function_2 (void *arg)
60 int my_number = (long) arg;
61 volatile int *myp = (int *) &args[my_number];
63 pthread_barrier_wait (&barrier);
68 callme (); /* set breakpoint child_one here */
88 signal (SIGUSR1, handler);
90 /* Call these early so that PLTs for these are resolved soon,
91 instead of in the threads. RTLD_NOW should work as well. */
93 pthread_barrier_init (&barrier, NULL, 1);
94 pthread_barrier_wait (&barrier);
96 pthread_barrier_init (&barrier, NULL, 2);
100 res = pthread_create (&child_thread_2,
101 NULL, child_function_2, (void *) i);
102 pthread_barrier_wait (&barrier);
103 callme (); /* set wait-thread-2 breakpoint here */
107 res = pthread_create (&child_thread_3,
108 NULL, child_function_3, (void *) i);
109 pthread_barrier_wait (&barrier);
110 callme (); /* set wait-thread-3 breakpoint here */
112 pthread_kill (child_thread_2, SIGUSR1);
114 pthread_join (child_thread_2, NULL);
115 pthread_join (child_thread_3, NULL);