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