1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2009-2016 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
;
29 sigusr1_handler (int signo
)
39 child_function_3 (void *arg
)
41 int my_number
= (long) arg
;
42 volatile int *myp
= (int *) &args
[my_number
];
44 pthread_barrier_wait (&barrier
);
49 callme (); /* set breakpoint thread 3 here */
56 child_function_2 (void *arg
)
58 int my_number
= (long) arg
;
59 volatile int *myp
= (int *) &args
[my_number
];
61 pthread_barrier_wait (&barrier
);
66 callme (); /* set breakpoint thread 2 here */
75 return 1; /* in wait_threads */
84 signal (SIGUSR1
, sigusr1_handler
);
86 /* Call these early so that PLTs for these are resolved soon,
87 instead of in the threads. RTLD_NOW should work as well. */
89 pthread_barrier_init (&barrier
, NULL
, 1);
90 pthread_barrier_wait (&barrier
);
92 pthread_barrier_init (&barrier
, NULL
, 2);
96 res
= pthread_create (&child_thread_2
,
97 NULL
, child_function_2
, (void *) i
);
98 pthread_barrier_wait (&barrier
);
103 res
= pthread_create (&child_thread_3
,
104 NULL
, child_function_3
, (void *) i
);
105 pthread_barrier_wait (&barrier
);
106 wait_threads (); /* set wait-threads breakpoint here */
108 pthread_join (child_thread_2
, NULL
);
109 pthread_join (child_thread_3
, NULL
);