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

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