Multi-arch exec, more register reading avoidance
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.multi / multi-arch-exec.c
CommitLineData
9107fc8d
PA
1/* This testcase is part of GDB, the GNU debugger.
2
61baf725 3 Copyright 2012-2017 Free Software Foundation, Inc.
9107fc8d
PA
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
762f7747 18#include <stdlib.h>
9107fc8d
PA
19#include <stdio.h>
20#include <unistd.h>
31d913c7
YQ
21#include <limits.h>
22#include <string.h>
cbd2b4e3
PA
23#include <pthread.h>
24
25#define NUM_THREADS 1
26
27static pthread_barrier_t barrier;
28
29static void *
30thread_start (void *arg)
31{
32 pthread_barrier_wait (&barrier);
33
34 while (1)
35 sleep (1);
36 return NULL;
37}
38
39static void
40all_started (void)
41{
42}
9107fc8d
PA
43
44int
31d913c7 45main (int argc, char ** argv)
9107fc8d 46{
31d913c7 47 char prog[PATH_MAX];
cbd2b4e3 48 pthread_t thread;
31d913c7
YQ
49 int len;
50
51 strcpy (prog, argv[0]);
52 len = strlen (prog);
53 /* Replace "multi-arch-exec" with "multi-arch-exec-hello". */
54 memcpy (prog + len - 15, "multi-arch-exec-hello", 21);
55 prog[len + 6] = 0;
56
cbd2b4e3
PA
57 pthread_barrier_init (&barrier, NULL, NUM_THREADS + 1);
58 pthread_create (&thread, NULL, thread_start, NULL);
59
60 pthread_barrier_wait (&barrier);
61 all_started ();
62
31d913c7
YQ
63 execl (prog,
64 prog,
9107fc8d
PA
65 (char *) NULL);
66 perror ("execl failed");
67 exit (1);
68}
This page took 0.562003 seconds and 4 git commands to generate.