]> git.ipfire.org Git - people/amarx/ipfire-3.x.git/blob - gdb/patches/gdb-6.8-bz442765-threaded-exec-test.patch
gdb: Update to 7.3.50.20110722.
[people/amarx/ipfire-3.x.git] / gdb / patches / gdb-6.8-bz442765-threaded-exec-test.patch
1 Test various forms of threads tracking across exec(2).
2
3 diff -up -u -X /root/jkratoch/.diffi.list -rup gdb-6.8/gdb/testsuite/gdb.threads/threaded-exec.c gdb-6.8-patched/gdb/testsuite/gdb.threads/threaded-exec.c
4 --- gdb-6.8/gdb/testsuite/gdb.threads/threaded-exec.c 2008-04-16 17:05:19.000000000 -0400
5 +++ gdb-6.8-patched/gdb/testsuite/gdb.threads/threaded-exec.c 2008-04-16 14:43:50.000000000 -0400
6 @@ -18,21 +18,95 @@
7 Boston, MA 02111-1307, USA. */
8
9 #include <stddef.h>
10 -#include <pthread.h>
11 #include <assert.h>
12 #include <stdlib.h>
13 #include <unistd.h>
14 +#include <stdio.h>
15
16 +#ifdef THREADS
17 +
18 +# include <pthread.h>
19
20 static void *
21 threader (void *arg)
22 {
23 - return NULL;
24 + return NULL;
25 }
26
27 +#endif
28 +
29 int
30 -main (void)
31 +main (int argc, char **argv)
32 {
33 + char *exec_nothreads, *exec_threads, *cmd;
34 + int phase;
35 + char phase_s[8];
36 +
37 + setbuf (stdout, NULL);
38 +
39 + if (argc != 4)
40 + {
41 + fprintf (stderr, "%s <non-threaded> <threaded> <phase>\n", argv[0]);
42 + return 1;
43 + }
44 +
45 +#ifdef THREADS
46 + puts ("THREADS: Y");
47 +#else
48 + puts ("THREADS: N");
49 +#endif
50 + exec_nothreads = argv[1];
51 + printf ("exec_nothreads: %s\n", exec_nothreads);
52 + exec_threads = argv[2];
53 + printf ("exec_threads: %s\n", exec_threads);
54 + phase = atoi (argv[3]);
55 + printf ("phase: %d\n", phase);
56 +
57 + /* Phases: threading
58 + 0: N -> N
59 + 1: N -> Y
60 + 2: Y -> Y
61 + 3: Y -> N
62 + 4: N -> exit */
63 +
64 + cmd = NULL;
65 +
66 +#ifndef THREADS
67 + switch (phase)
68 + {
69 + case 0:
70 + cmd = exec_nothreads;
71 + break;
72 + case 1:
73 + cmd = exec_threads;
74 + break;
75 + case 2:
76 + fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0],
77 + phase);
78 + return 1;
79 + case 3:
80 + fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0],
81 + phase);
82 + return 1;
83 + case 4:
84 + return 0;
85 + default:
86 + assert (0);
87 + }
88 +#else /* THREADS */
89 + switch (phase)
90 + {
91 + case 0:
92 + fprintf (stderr, "%s: We should not have threads for phase %d!\n",
93 + argv[0], phase);
94 + return 1;
95 + case 1:
96 + fprintf (stderr, "%s: We should not have threads for phase %d!\n",
97 + argv[0], phase);
98 + return 1;
99 + case 2:
100 + cmd = exec_threads;
101 + {
102 pthread_t t1;
103 int i;
104
105 @@ -40,7 +114,34 @@ main (void)
106 assert (i == 0);
107 i = pthread_join (t1, NULL);
108 assert (i == 0);
109 + }
110 + break;
111 + case 3:
112 + cmd = exec_nothreads;
113 + {
114 + pthread_t t1;
115 + int i;
116 +
117 + i = pthread_create (&t1, NULL, threader, (void *) NULL);
118 + assert (i == 0);
119 + i = pthread_join (t1, NULL);
120 + assert (i == 0);
121 + }
122 + break;
123 + case 4:
124 + fprintf (stderr, "%s: We should not have threads for phase %d!\n",
125 + argv[0], phase);
126 + return 1;
127 + default:
128 + assert (0);
129 + }
130 +#endif /* THREADS */
131 +
132 + assert (cmd != NULL);
133 +
134 + phase++;
135 + snprintf (phase_s, sizeof phase_s, "%d", phase);
136
137 - execl ("/bin/true", "/bin/true", NULL);
138 - abort ();
139 + execl (cmd, cmd, exec_nothreads, exec_threads, phase_s, NULL);
140 + assert (0);
141 }
142 diff -up -u -X /root/jkratoch/.diffi.list -rup gdb-6.8/gdb/testsuite/gdb.threads/threaded-exec.exp gdb-6.8-patched/gdb/testsuite/gdb.threads/threaded-exec.exp
143 --- gdb-6.8/gdb/testsuite/gdb.threads/threaded-exec.exp 2008-04-16 17:05:19.000000000 -0400
144 +++ gdb-6.8-patched/gdb/testsuite/gdb.threads/threaded-exec.exp 2008-04-16 14:42:49.000000000 -0400
145 @@ -20,9 +20,14 @@
146
147 set testfile threaded-exec
148 set srcfile ${testfile}.c
149 -set binfile ${objdir}/${subdir}/${testfile}
150 +set binfile_nothreads ${objdir}/${subdir}/${testfile}N
151 +set binfile_threads ${objdir}/${subdir}/${testfile}Y
152
153 -if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } {
154 +if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_nothreads}" executable {additional_flags=-UTHREADS}] != "" } {
155 + return -1
156 +}
157 +
158 +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile_threads}" executable {additional_flags=-DTHREADS}] != "" } {
159 return -1
160 }
161
162 @@ -30,9 +35,9 @@ gdb_exit
163 gdb_start
164 gdb_reinitialize_dir $srcdir/$subdir
165
166 -gdb_load ${binfile}
167 +gdb_load ${binfile_nothreads}
168
169 -gdb_run_cmd
170 +gdb_run_cmd ${binfile_nothreads} ${binfile_threads} 0
171
172 gdb_test_multiple {} "Program exited" {
173 -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" {