Rename gdb/ChangeLog to gdb/ChangeLog-2021
[binutils-gdb.git] / gdb / testsuite / gdb.multi / multi-target.c
blobafcffa82abb4bdeb3cd731e7e987b04e3f4b32ed
1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2017-2021 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/>. */
18 #include <stdlib.h>
19 #include <stdio.h>
20 #include <unistd.h>
21 #include <limits.h>
22 #include <string.h>
23 #include <pthread.h>
25 #define NUM_THREADS 1
27 static pthread_barrier_t barrier;
29 volatile int exit_thread;
31 static void *
32 thread_start (void *arg)
34 pthread_barrier_wait (&barrier);
36 while (!exit_thread)
37 sleep (1);
38 return NULL;
41 static void
42 all_started (void)
46 int wait_for_gdb;
48 static void
49 function1 (void)
51 while (wait_for_gdb)
52 sleep (1);
55 static void
56 function2 (void)
58 while (wait_for_gdb)
59 sleep (1);
62 static void
63 function3 (void)
67 static void
68 function4 (void)
72 static void
73 function5 (void)
77 int
78 main (int argc, char ** argv)
80 pthread_t thread;
81 int len;
83 alarm (360);
85 pthread_barrier_init (&barrier, NULL, NUM_THREADS + 1);
86 pthread_create (&thread, NULL, thread_start, NULL);
88 pthread_barrier_wait (&barrier);
89 all_started ();
91 while (1)
93 function1 (); /* set break 1 here */
94 function2 (); /* set break 2 here */
95 function3 ();
96 function4 ();
97 function5 ();
98 sleep (1);
101 return 0;