1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2009-2015 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
;
34 child_function_3 (void *arg
)
36 int my_number
= (long) arg
;
37 volatile int *myp
= (int *) &args
[my_number
];
39 pthread_barrier_wait (&barrier
);
44 callme (); /* set breakpoint thread 3 here */
51 child_function_2 (void *arg
)
53 int my_number
= (long) arg
;
54 volatile int *myp
= (int *) &args
[my_number
];
56 pthread_barrier_wait (&barrier
);
61 callme (); /* set breakpoint thread 2 here */
70 return 1; /* in wait_threads */
79 /* Call these early so that PLTs for these are resolved soon,
80 instead of in the threads. RTLD_NOW should work as well. */
82 pthread_barrier_init (&barrier
, NULL
, 1);
83 pthread_barrier_wait (&barrier
);
85 pthread_barrier_init (&barrier
, NULL
, 2);
89 res
= pthread_create (&child_thread_2
,
90 NULL
, child_function_2
, (void *) i
);
91 pthread_barrier_wait (&barrier
);
96 res
= pthread_create (&child_thread_3
,
97 NULL
, child_function_3
, (void *) i
);
98 pthread_barrier_wait (&barrier
);
99 wait_threads (); /* set wait-threads breakpoint here */
101 pthread_join (child_thread_2
, NULL
);
102 pthread_join (child_thread_3
, NULL
);