Testcase for previous handle_no_resumed fixes
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.multi / multi-target.c
CommitLineData
1dadb1dd
PA
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
27static pthread_barrier_t barrier;
28
1fcb3bd3
PA
29volatile int exit_thread;
30
1dadb1dd
PA
31static void *
32thread_start (void *arg)
33{
34 pthread_barrier_wait (&barrier);
35
1fcb3bd3 36 while (!exit_thread)
1dadb1dd
PA
37 sleep (1);
38 return NULL;
39}
40
41static void
42all_started (void)
43{
44}
45
46int wait_for_gdb;
47
48static void
49function1 (void)
50{
51 while (wait_for_gdb)
52 sleep (1);
53}
54
55static void
56function2 (void)
57{
58 while (wait_for_gdb)
59 sleep (1);
60}
61
62static void
63function3 (void)
64{
65}
66
67static void
68function4 (void)
69{
70}
71
72static void
73function5 (void)
74{
75}
76
77int
78main (int argc, char ** argv)
79{
80 pthread_t thread;
81 int len;
82
83 alarm (360);
84
85 pthread_barrier_init (&barrier, NULL, NUM_THREADS + 1);
86 pthread_create (&thread, NULL, thread_start, NULL);
87
88 pthread_barrier_wait (&barrier);
89 all_started ();
90
91 while (1)
92 {
93 function1 (); /* set break 1 here */
94 function2 (); /* set break 2 here */
95 function3 ();
96 function4 ();
97 function5 ();
98 sleep (1);
99 }
100
101 return 0;
102}
This page took 0.105782 seconds and 4 git commands to generate.