Add multi-target tests
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.multi / multi-target.c
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 2017-2020 Free Software Foundation, Inc.
4
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.
9
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.
14
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/>. */
17
18 #include <stdlib.h>
19 #include <stdio.h>
20 #include <unistd.h>
21 #include <limits.h>
22 #include <string.h>
23 #include <pthread.h>
24
25 #define NUM_THREADS 1
26
27 static pthread_barrier_t barrier;
28
29 static void *
30 thread_start (void *arg)
31 {
32 pthread_barrier_wait (&barrier);
33
34 while (1)
35 sleep (1);
36 return NULL;
37 }
38
39 static void
40 all_started (void)
41 {
42 }
43
44 int wait_for_gdb;
45
46 static void
47 function1 (void)
48 {
49 while (wait_for_gdb)
50 sleep (1);
51 }
52
53 static void
54 function2 (void)
55 {
56 while (wait_for_gdb)
57 sleep (1);
58 }
59
60 static void
61 function3 (void)
62 {
63 }
64
65 static void
66 function4 (void)
67 {
68 }
69
70 static void
71 function5 (void)
72 {
73 }
74
75 int
76 main (int argc, char ** argv)
77 {
78 pthread_t thread;
79 int len;
80
81 alarm (360);
82
83 pthread_barrier_init (&barrier, NULL, NUM_THREADS + 1);
84 pthread_create (&thread, NULL, thread_start, NULL);
85
86 pthread_barrier_wait (&barrier);
87 all_started ();
88
89 while (1)
90 {
91 function1 (); /* set break 1 here */
92 function2 (); /* set break 2 here */
93 function3 ();
94 function4 ();
95 function5 ();
96 sleep (1);
97 }
98
99 return 0;
100 }
This page took 0.033776 seconds and 4 git commands to generate.