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