1 /* Test program for non-stop debugging.
2 Copyright 1996-2021 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 int exit_first_thread
= 0;
26 void break_at_me (int id
, int i
)
36 /* When gdb is running, it sets hidden breakpoints in the thread
37 library. The signals caused by these hidden breakpoints can
38 cause system calls such as 'sleep' to return early. Pay attention
39 to the return value from 'sleep' to get the full sleep. */
44 unslept
= sleep (unslept
);
46 if (exit_first_thread
&& id
== 0)
54 create_thread (int id
)
57 /* This memory will be leaked, we don't care for a test. */
58 int *id2
= malloc (sizeof (int));
61 if (pthread_create (&tid
, NULL
, worker
, (void *) id2
))
63 perror ("pthread_create 1");
70 main (int argc
, char *argv
[])
75 tid
= create_thread (1);
76 pthread_join (tid
, NULL
);