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

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