Blame SOURCES/gdb-6.8-bz442765-threaded-exec-test.patch

f9426a
Test various forms of threads tracking across exec(2).
f9426a
f9426a
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
f9426a
--- gdb-6.8/gdb/testsuite/gdb.threads/threaded-exec.c	2008-04-16 17:05:19.000000000 -0400
f9426a
+++ gdb-6.8-patched/gdb/testsuite/gdb.threads/threaded-exec.c	2008-04-16 14:43:50.000000000 -0400
f9426a
@@ -18,21 +18,95 @@
f9426a
    Boston, MA 02111-1307, USA.  */
f9426a
 
f9426a
 #include <stddef.h>
f9426a
-#include <pthread.h>
f9426a
 #include <assert.h>
f9426a
 #include <stdlib.h>
f9426a
 #include <unistd.h>
f9426a
+#include <stdio.h>
f9426a
 
f9426a
+#ifdef THREADS
f9426a
+
f9426a
+# include <pthread.h>
f9426a
 
f9426a
 static void *
f9426a
 threader (void *arg)
f9426a
 {
f9426a
-	return NULL;
f9426a
+  return NULL;
f9426a
 }
f9426a
 
f9426a
+#endif
f9426a
+
f9426a
 int
f9426a
-main (void)
f9426a
+main (int argc, char **argv)
f9426a
 {
f9426a
+  char *exec_nothreads, *exec_threads, *cmd;
f9426a
+  int phase;
f9426a
+  char phase_s[8];
f9426a
+
f9426a
+  setbuf (stdout, NULL);
f9426a
+
f9426a
+  if (argc != 4)
f9426a
+    {
f9426a
+      fprintf (stderr, "%s <non-threaded> <threaded> <phase>\n", argv[0]);
f9426a
+      return 1;
f9426a
+    }
f9426a
+
f9426a
+#ifdef THREADS
f9426a
+  puts ("THREADS: Y");
f9426a
+#else
f9426a
+  puts ("THREADS: N");
f9426a
+#endif
f9426a
+  exec_nothreads = argv[1];
f9426a
+  printf ("exec_nothreads: %s\n", exec_nothreads);
f9426a
+  exec_threads = argv[2];
f9426a
+  printf ("exec_threads: %s\n", exec_threads);
f9426a
+  phase = atoi (argv[3]);
f9426a
+  printf ("phase: %d\n", phase);
f9426a
+
f9426a
+  /* Phases: threading
f9426a
+     0: N -> N
f9426a
+     1: N -> Y
f9426a
+     2: Y -> Y
f9426a
+     3: Y -> N
f9426a
+     4: N -> exit  */
f9426a
+
f9426a
+  cmd = NULL;
f9426a
+
f9426a
+#ifndef THREADS
f9426a
+  switch (phase)
f9426a
+    {
f9426a
+    case 0:
f9426a
+      cmd = exec_nothreads;
f9426a
+      break;
f9426a
+    case 1:
f9426a
+      cmd = exec_threads;
f9426a
+      break;
f9426a
+    case 2:
f9426a
+      fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0],
f9426a
+	       phase);
f9426a
+      return 1;
f9426a
+    case 3:
f9426a
+      fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0],
f9426a
+	       phase);
f9426a
+      return 1;
f9426a
+    case 4:
f9426a
+      return 0;
f9426a
+    default:
f9426a
+      assert (0);
f9426a
+    }
f9426a
+#else	/* THREADS */
f9426a
+  switch (phase)
f9426a
+    {
f9426a
+    case 0:
f9426a
+      fprintf (stderr, "%s: We should not have threads for phase %d!\n",
f9426a
+	       argv[0], phase);
f9426a
+      return 1;
f9426a
+    case 1:
f9426a
+      fprintf (stderr, "%s: We should not have threads for phase %d!\n",
f9426a
+	       argv[0], phase);
f9426a
+      return 1;
f9426a
+    case 2:
f9426a
+      cmd = exec_threads;
f9426a
+      {
f9426a
 	pthread_t t1;
f9426a
 	int i;
f9426a
 
f9426a
@@ -40,7 +114,34 @@ main (void)
f9426a
 	assert (i == 0);
f9426a
 	i = pthread_join (t1, NULL);
f9426a
 	assert (i == 0);
f9426a
+      }
f9426a
+      break;
f9426a
+    case 3:
f9426a
+      cmd = exec_nothreads;
f9426a
+      {
f9426a
+	pthread_t t1;
f9426a
+	int i;
f9426a
+
f9426a
+	i = pthread_create (&t1, NULL, threader, (void *) NULL);
f9426a
+	assert (i == 0);
f9426a
+	i = pthread_join (t1, NULL);
f9426a
+	assert (i == 0);
f9426a
+      }
f9426a
+      break;
f9426a
+    case 4:
f9426a
+      fprintf (stderr, "%s: We should not have threads for phase %d!\n",
f9426a
+	       argv[0], phase);
f9426a
+      return 1;
f9426a
+    default:
f9426a
+      assert (0);
f9426a
+    }
f9426a
+#endif	/* THREADS */
f9426a
+
f9426a
+  assert (cmd != NULL);
f9426a
+
f9426a
+  phase++;
f9426a
+  snprintf (phase_s, sizeof phase_s, "%d", phase);
f9426a
 
f9426a
-	execl ("/bin/true", "/bin/true", NULL);
f9426a
-	abort ();
f9426a
+  execl (cmd, cmd, exec_nothreads, exec_threads, phase_s, NULL);
f9426a
+  assert (0);
f9426a
 }
f9426a
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
f9426a
--- gdb-6.8/gdb/testsuite/gdb.threads/threaded-exec.exp	2008-04-16 17:05:19.000000000 -0400
f9426a
+++ gdb-6.8-patched/gdb/testsuite/gdb.threads/threaded-exec.exp	2008-04-16 14:42:49.000000000 -0400
f9426a
@@ -20,9 +20,14 @@
f9426a
 
f9426a
 set testfile threaded-exec
f9426a
 set srcfile ${testfile}.c
f9426a
-set binfile ${objdir}/${subdir}/${testfile}
f9426a
+set binfile_nothreads ${objdir}/${subdir}/${testfile}N
f9426a
+set binfile_threads ${objdir}/${subdir}/${testfile}Y
f9426a
 
f9426a
-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } {
f9426a
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_nothreads}" executable {additional_flags=-UTHREADS}] != "" } {
f9426a
+    return -1
f9426a
+}
f9426a
+
f9426a
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile_threads}" executable {additional_flags=-DTHREADS}] != "" } {
f9426a
     return -1
f9426a
 }
f9426a
 
f9426a
@@ -30,9 +35,9 @@ gdb_exit
f9426a
 gdb_start
f9426a
 gdb_reinitialize_dir $srcdir/$subdir
f9426a
 
f9426a
-gdb_load ${binfile}
f9426a
+gdb_load ${binfile_nothreads}
f9426a
 
f9426a
-gdb_run_cmd
f9426a
+gdb_run_cmd ${binfile_nothreads} ${binfile_threads} 0
f9426a
 
f9426a
 gdb_test_multiple {} "Program exited" {
f9426a
    -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" {