1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2014 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/>. */
23 /* Used to individually advance each thread to the desired stopping point. */
26 sig_atomic_t sigusr1_received
;
27 sig_atomic_t sigusr2_received
;
28 sig_atomic_t sigabrt_received
;
31 sigusr1_handler (int sig
)
37 sigusr2_handler (int sig
)
43 sigabrt_handler (int sig
)
49 sigusr1_thread_function (void *unused
)
53 pthread_kill (pthread_self (), SIGUSR1
);
57 sigusr2_thread_function (void *unused
)
61 /* pthread_kill (pthread_self (), SIGUSR2); - manually injected by gdb */
65 all_threads_running (void)
72 all_threads_done (void)
79 pthread_t sigusr1_thread
, sigusr2_thread
;
81 /* Protect against running forever. */
84 signal (SIGUSR1
, sigusr1_handler
);
85 signal (SIGUSR2
, sigusr2_handler
);
86 signal (SIGABRT
, sigabrt_handler
);
88 /* Don't let any thread advance past initialization. */
91 pthread_create (&sigusr1_thread
, NULL
, sigusr1_thread_function
, NULL
);
92 pthread_create (&sigusr2_thread
, NULL
, sigusr2_thread_function
, NULL
);
93 all_threads_running ();
95 pthread_kill (pthread_self (), SIGABRT
);
97 pthread_join (sigusr1_thread
, NULL
);
98 pthread_join (sigusr2_thread
, NULL
);
This page took 0.031403 seconds and 4 git commands to generate.