Blame SOURCES/gdb-6.3-bz202689-exec-from-pthread-test.patch

2f9ed3
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
2f9ed3
From: Jan Kratochvil <jan.kratochvil@redhat.com>
2f9ed3
Date: Fri, 27 Oct 2017 21:07:50 +0200
2f9ed3
Subject: gdb-6.3-bz202689-exec-from-pthread-test.patch
2f9ed3
2f9ed3
;; Testcase for exec() from threaded program (BZ 202689).
2f9ed3
;;=fedoratest
2f9ed3
2f9ed3
2007-01-17  Jan Kratochvil <jan.kratochvil@redhat.com>
2f9ed3
2f9ed3
	* gdb.threads/threaded-exec.exp, gdb.threads/threaded-exec.c: New files.
2f9ed3
2f9ed3
diff --git a/gdb/testsuite/gdb.threads/threaded-exec.c b/gdb/testsuite/gdb.threads/threaded-exec.c
2f9ed3
new file mode 100644
2f9ed3
--- /dev/null
2f9ed3
+++ b/gdb/testsuite/gdb.threads/threaded-exec.c
2f9ed3
@@ -0,0 +1,46 @@
2f9ed3
+/* This testcase is part of GDB, the GNU debugger.
2f9ed3
+
2f9ed3
+   Copyright 2007 Free Software Foundation, Inc.
2f9ed3
+
2f9ed3
+   This program is free software; you can redistribute it and/or modify
2f9ed3
+   it under the terms of the GNU General Public License as published by
2f9ed3
+   the Free Software Foundation; either version 2 of the License, or
2f9ed3
+   (at your option) any later version.
2f9ed3
+
2f9ed3
+   This program is distributed in the hope that it will be useful,
2f9ed3
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2f9ed3
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2f9ed3
+   GNU General Public License for more details.
2f9ed3
+
2f9ed3
+   You should have received a copy of the GNU General Public License
2f9ed3
+   along with this program; if not, write to the Free Software
2f9ed3
+   Foundation, Inc., 59 Temple Place - Suite 330,
2f9ed3
+   Boston, MA 02111-1307, USA.  */
2f9ed3
+
2f9ed3
+#include <stddef.h>
2f9ed3
+#include <pthread.h>
2f9ed3
+#include <assert.h>
2f9ed3
+#include <stdlib.h>
2f9ed3
+#include <unistd.h>
2f9ed3
+
2f9ed3
+
2f9ed3
+static void *
2f9ed3
+threader (void *arg)
2f9ed3
+{
2f9ed3
+	return NULL;
2f9ed3
+}
2f9ed3
+
2f9ed3
+int
2f9ed3
+main (void)
2f9ed3
+{
2f9ed3
+	pthread_t t1;
2f9ed3
+	int i;
2f9ed3
+
2f9ed3
+	i = pthread_create (&t1, NULL, threader, (void *) NULL);
2f9ed3
+	assert (i == 0);
2f9ed3
+	i = pthread_join (t1, NULL);
2f9ed3
+	assert (i == 0);
2f9ed3
+
2f9ed3
+	execl ("/bin/true", "/bin/true", NULL);
2f9ed3
+	abort ();
2f9ed3
+}
2f9ed3
diff --git a/gdb/testsuite/gdb.threads/threaded-exec.exp b/gdb/testsuite/gdb.threads/threaded-exec.exp
2f9ed3
new file mode 100644
2f9ed3
--- /dev/null
2f9ed3
+++ b/gdb/testsuite/gdb.threads/threaded-exec.exp
2f9ed3
@@ -0,0 +1,41 @@
2f9ed3
+# threaded-exec.exp -- Check reset of the tracked threads on exec*(2)
2f9ed3
+# Copyright (C) 2007 Free Software Foundation, Inc.
2f9ed3
+
2f9ed3
+# This program is free software; you can redistribute it and/or modify
2f9ed3
+# it under the terms of the GNU General Public License as published by
2f9ed3
+# the Free Software Foundation; either version 2 of the License, or
2f9ed3
+# (at your option) any later version.
2f9ed3
+# 
2f9ed3
+# This program is distributed in the hope that it will be useful,
2f9ed3
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2f9ed3
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2f9ed3
+# GNU General Public License for more details.
2f9ed3
+# 
2f9ed3
+# You should have received a copy of the GNU General Public License
2f9ed3
+# along with this program; if not, write to the Free Software
2f9ed3
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
2f9ed3
+
2f9ed3
+# Please email any bugs, comments, and/or additions to this file to:
2f9ed3
+# bug-gdb@prep.ai.mit.edu
2f9ed3
+
2f9ed3
+set testfile threaded-exec
2f9ed3
+set srcfile ${testfile}.c
2f9ed3
+set binfile [standard_output_file ${testfile}]
2f9ed3
+
2f9ed3
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } {
2f9ed3
+    return -1
2f9ed3
+}
2f9ed3
+
2f9ed3
+gdb_exit
2f9ed3
+gdb_start
2f9ed3
+gdb_reinitialize_dir $srcdir/$subdir
2f9ed3
+
2f9ed3
+gdb_load ${binfile}
2f9ed3
+
2f9ed3
+gdb_run_cmd
2f9ed3
+
2f9ed3
+gdb_test_multiple {} "Program exited" {
2f9ed3
+   -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" {
2f9ed3
+       pass "Program exited"
2f9ed3
+   }
2f9ed3
+}