ignore invalid DOF provider sections
[binutils-gdb.git] / gdb / testsuite / gdb.python / py-inferior.c
blob3ee9a4620604ecd0f7676b70dc4cb189275b186d
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdint.h>
4 #include <string.h>
5 #include <pthread.h>
7 #define CHUNK_SIZE 16000 /* same as findcmd.c's */
8 #define BUF_SIZE (2 * CHUNK_SIZE) /* at least two chunks */
9 #define NUMTH 8
11 int8_t int8_search_buf[100];
12 int16_t int16_search_buf[100];
13 int32_t int32_search_buf[100];
14 int64_t int64_search_buf[100];
16 static char *search_buf;
17 static int search_buf_size;
20 int f2 (int a)
22 /* We use a `char[]' type below rather than the typical `char *'
23 to make sure that `str' gets allocated on the stack. Otherwise,
24 the compiler may place the "hello, testsuite" string inside
25 a read-only section, preventing us from over-writing it from GDB. */
26 char str[] = "hello, testsuite";
28 puts (str); /* Break here. */
30 return ++a;
33 int f1 (int a, int b)
35 return f2(a) + b;
38 static void
39 init_bufs ()
41 search_buf_size = BUF_SIZE;
42 search_buf = malloc (search_buf_size);
43 if (search_buf == NULL)
44 exit (1);
45 memset (search_buf, 'x', search_buf_size);
48 static void *
49 thread (void *param)
51 pthread_barrier_t *barrier = (pthread_barrier_t *) param;
53 pthread_barrier_wait (barrier);
55 return param;
58 static void
59 check_threads (pthread_barrier_t *barrier)
61 pthread_barrier_wait (barrier);
64 extern int
65 test_threads (void)
67 pthread_t threads[NUMTH];
68 pthread_barrier_t barrier;
69 int i;
71 pthread_barrier_init (&barrier, NULL, NUMTH + 1);
73 for (i = 0; i < NUMTH; ++i)
74 pthread_create (&threads[i], NULL, thread, &barrier);
76 check_threads (&barrier);
78 for (i = 0; i < NUMTH; ++i)
79 pthread_join (threads[i], NULL);
81 pthread_barrier_destroy (&barrier);
83 return 0;
86 int main (int argc, char *argv[])
88 test_threads ();
89 init_bufs ();
91 return f1 (1, 2);