|
|
4416f5 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
4416f5 |
From: Fedora GDB patches <invalid@email.com>
|
|
|
4416f5 |
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
4416f5 |
Subject: gdb-6.8-bz442765-threaded-exec-test.patch
|
|
|
4416f5 |
|
|
|
4416f5 |
;; Test various forms of threads tracking across exec() (BZ 442765).
|
|
|
4416f5 |
;;=fedoratest
|
|
|
4416f5 |
|
|
|
4416f5 |
Test various forms of threads tracking across exec(2).
|
|
|
4416f5 |
|
|
|
4416f5 |
diff --git a/gdb/testsuite/gdb.threads/threaded-exec.c b/gdb/testsuite/gdb.threads/threaded-exec.c
|
|
|
4416f5 |
--- a/gdb/testsuite/gdb.threads/threaded-exec.c
|
|
|
4416f5 |
+++ b/gdb/testsuite/gdb.threads/threaded-exec.c
|
|
|
4416f5 |
@@ -18,21 +18,95 @@
|
|
|
4416f5 |
Boston, MA 02111-1307, USA. */
|
|
|
4416f5 |
|
|
|
4416f5 |
#include <stddef.h>
|
|
|
4416f5 |
-#include <pthread.h>
|
|
|
4416f5 |
#include <assert.h>
|
|
|
4416f5 |
#include <stdlib.h>
|
|
|
4416f5 |
#include <unistd.h>
|
|
|
4416f5 |
+#include <stdio.h>
|
|
|
4416f5 |
|
|
|
4416f5 |
+#ifdef THREADS
|
|
|
4416f5 |
+
|
|
|
4416f5 |
+# include <pthread.h>
|
|
|
4416f5 |
|
|
|
4416f5 |
static void *
|
|
|
4416f5 |
threader (void *arg)
|
|
|
4416f5 |
{
|
|
|
4416f5 |
- return NULL;
|
|
|
4416f5 |
+ return NULL;
|
|
|
4416f5 |
}
|
|
|
4416f5 |
|
|
|
4416f5 |
+#endif
|
|
|
4416f5 |
+
|
|
|
4416f5 |
int
|
|
|
4416f5 |
-main (void)
|
|
|
4416f5 |
+main (int argc, char **argv)
|
|
|
4416f5 |
{
|
|
|
4416f5 |
+ char *exec_nothreads, *exec_threads, *cmd;
|
|
|
4416f5 |
+ int phase;
|
|
|
4416f5 |
+ char phase_s[8];
|
|
|
4416f5 |
+
|
|
|
4416f5 |
+ setbuf (stdout, NULL);
|
|
|
4416f5 |
+
|
|
|
4416f5 |
+ if (argc != 4)
|
|
|
4416f5 |
+ {
|
|
|
4416f5 |
+ fprintf (stderr, "%s <non-threaded> <threaded> <phase>\n", argv[0]);
|
|
|
4416f5 |
+ return 1;
|
|
|
4416f5 |
+ }
|
|
|
4416f5 |
+
|
|
|
4416f5 |
+#ifdef THREADS
|
|
|
4416f5 |
+ puts ("THREADS: Y");
|
|
|
4416f5 |
+#else
|
|
|
4416f5 |
+ puts ("THREADS: N");
|
|
|
4416f5 |
+#endif
|
|
|
4416f5 |
+ exec_nothreads = argv[1];
|
|
|
4416f5 |
+ printf ("exec_nothreads: %s\n", exec_nothreads);
|
|
|
4416f5 |
+ exec_threads = argv[2];
|
|
|
4416f5 |
+ printf ("exec_threads: %s\n", exec_threads);
|
|
|
4416f5 |
+ phase = atoi (argv[3]);
|
|
|
4416f5 |
+ printf ("phase: %d\n", phase);
|
|
|
4416f5 |
+
|
|
|
4416f5 |
+ /* Phases: threading
|
|
|
4416f5 |
+ 0: N -> N
|
|
|
4416f5 |
+ 1: N -> Y
|
|
|
4416f5 |
+ 2: Y -> Y
|
|
|
4416f5 |
+ 3: Y -> N
|
|
|
4416f5 |
+ 4: N -> exit */
|
|
|
4416f5 |
+
|
|
|
4416f5 |
+ cmd = NULL;
|
|
|
4416f5 |
+
|
|
|
4416f5 |
+#ifndef THREADS
|
|
|
4416f5 |
+ switch (phase)
|
|
|
4416f5 |
+ {
|
|
|
4416f5 |
+ case 0:
|
|
|
4416f5 |
+ cmd = exec_nothreads;
|
|
|
4416f5 |
+ break;
|
|
|
4416f5 |
+ case 1:
|
|
|
4416f5 |
+ cmd = exec_threads;
|
|
|
4416f5 |
+ break;
|
|
|
4416f5 |
+ case 2:
|
|
|
4416f5 |
+ fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0],
|
|
|
4416f5 |
+ phase);
|
|
|
4416f5 |
+ return 1;
|
|
|
4416f5 |
+ case 3:
|
|
|
4416f5 |
+ fprintf (stderr, "%s: We should have threads for phase %d!\n", argv[0],
|
|
|
4416f5 |
+ phase);
|
|
|
4416f5 |
+ return 1;
|
|
|
4416f5 |
+ case 4:
|
|
|
4416f5 |
+ return 0;
|
|
|
4416f5 |
+ default:
|
|
|
4416f5 |
+ assert (0);
|
|
|
4416f5 |
+ }
|
|
|
4416f5 |
+#else /* THREADS */
|
|
|
4416f5 |
+ switch (phase)
|
|
|
4416f5 |
+ {
|
|
|
4416f5 |
+ case 0:
|
|
|
4416f5 |
+ fprintf (stderr, "%s: We should not have threads for phase %d!\n",
|
|
|
4416f5 |
+ argv[0], phase);
|
|
|
4416f5 |
+ return 1;
|
|
|
4416f5 |
+ case 1:
|
|
|
4416f5 |
+ fprintf (stderr, "%s: We should not have threads for phase %d!\n",
|
|
|
4416f5 |
+ argv[0], phase);
|
|
|
4416f5 |
+ return 1;
|
|
|
4416f5 |
+ case 2:
|
|
|
4416f5 |
+ cmd = exec_threads;
|
|
|
4416f5 |
+ {
|
|
|
4416f5 |
pthread_t t1;
|
|
|
4416f5 |
int i;
|
|
|
4416f5 |
|
|
|
4416f5 |
@@ -40,7 +114,34 @@ main (void)
|
|
|
4416f5 |
assert (i == 0);
|
|
|
4416f5 |
i = pthread_join (t1, NULL);
|
|
|
4416f5 |
assert (i == 0);
|
|
|
4416f5 |
+ }
|
|
|
4416f5 |
+ break;
|
|
|
4416f5 |
+ case 3:
|
|
|
4416f5 |
+ cmd = exec_nothreads;
|
|
|
4416f5 |
+ {
|
|
|
4416f5 |
+ pthread_t t1;
|
|
|
4416f5 |
+ int i;
|
|
|
4416f5 |
+
|
|
|
4416f5 |
+ i = pthread_create (&t1, NULL, threader, (void *) NULL);
|
|
|
4416f5 |
+ assert (i == 0);
|
|
|
4416f5 |
+ i = pthread_join (t1, NULL);
|
|
|
4416f5 |
+ assert (i == 0);
|
|
|
4416f5 |
+ }
|
|
|
4416f5 |
+ break;
|
|
|
4416f5 |
+ case 4:
|
|
|
4416f5 |
+ fprintf (stderr, "%s: We should not have threads for phase %d!\n",
|
|
|
4416f5 |
+ argv[0], phase);
|
|
|
4416f5 |
+ return 1;
|
|
|
4416f5 |
+ default:
|
|
|
4416f5 |
+ assert (0);
|
|
|
4416f5 |
+ }
|
|
|
4416f5 |
+#endif /* THREADS */
|
|
|
4416f5 |
+
|
|
|
4416f5 |
+ assert (cmd != NULL);
|
|
|
4416f5 |
+
|
|
|
4416f5 |
+ phase++;
|
|
|
4416f5 |
+ snprintf (phase_s, sizeof phase_s, "%d", phase);
|
|
|
4416f5 |
|
|
|
4416f5 |
- execl ("/bin/true", "/bin/true", NULL);
|
|
|
4416f5 |
- abort ();
|
|
|
4416f5 |
+ execl (cmd, cmd, exec_nothreads, exec_threads, phase_s, NULL);
|
|
|
4416f5 |
+ assert (0);
|
|
|
4416f5 |
}
|
|
|
4416f5 |
diff --git a/gdb/testsuite/gdb.threads/threaded-exec.exp b/gdb/testsuite/gdb.threads/threaded-exec.exp
|
|
|
4416f5 |
--- a/gdb/testsuite/gdb.threads/threaded-exec.exp
|
|
|
4416f5 |
+++ b/gdb/testsuite/gdb.threads/threaded-exec.exp
|
|
|
4416f5 |
@@ -20,9 +20,14 @@
|
|
|
4416f5 |
|
|
|
4416f5 |
set testfile threaded-exec
|
|
|
4416f5 |
set srcfile ${testfile}.c
|
|
|
4416f5 |
-set binfile [standard_output_file ${testfile}]
|
|
|
4416f5 |
+set binfile_nothreads [standard_output_file ${testfile}N]
|
|
|
4416f5 |
+set binfile_threads [standard_output_file ${testfile}Y]
|
|
|
4416f5 |
|
|
|
4416f5 |
-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } {
|
|
|
4416f5 |
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_nothreads}" executable {additional_flags=-UTHREADS}] != "" } {
|
|
|
4416f5 |
+ return -1
|
|
|
4416f5 |
+}
|
|
|
4416f5 |
+
|
|
|
4416f5 |
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile_threads}" executable {additional_flags=-DTHREADS}] != "" } {
|
|
|
4416f5 |
return -1
|
|
|
4416f5 |
}
|
|
|
4416f5 |
|
|
|
4416f5 |
@@ -30,9 +35,9 @@ gdb_exit
|
|
|
4416f5 |
gdb_start
|
|
|
4416f5 |
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
4416f5 |
|
|
|
4416f5 |
-gdb_load ${binfile}
|
|
|
4416f5 |
+gdb_load ${binfile_nothreads}
|
|
|
4416f5 |
|
|
|
4416f5 |
-gdb_run_cmd
|
|
|
4416f5 |
+gdb_run_cmd [list ${binfile_nothreads} ${binfile_threads} 0]
|
|
|
4416f5 |
|
|
|
4416f5 |
gdb_test_multiple {} "Program exited" {
|
|
|
4416f5 |
-re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" {
|