keiths / rpms / gdb

Forked from rpms/gdb 5 months ago
Clone
5c49e68
2007-07-07  Jan Kratochvil  <jan.kratochvil@redhat.com>
5c49e68
5c49e68
	* gdb.threads/leader-exit.c, gdb.threads/leader-exit.exp: New files.
5c49e68
5c49e68
--- /dev/null	1 Jan 1970 00:00:00 -0000
5c49e68
+++ ./gdb/testsuite/gdb.threads/leader-exit.c	7 Jul 2007 15:21:57 -0000
5c49e68
@@ -0,0 +1,47 @@
5c49e68
+/* Clean exit of the thread group leader should not break GDB.
5c49e68
+
5c49e68
+   Copyright 2007 Free Software Foundation, Inc.
5c49e68
+
5c49e68
+   This file is part of GDB.
5c49e68
+
5c49e68
+   This program is free software; you can redistribute it and/or modify
5c49e68
+   it under the terms of the GNU General Public License as published by
5c49e68
+   the Free Software Foundation; either version 2 of the License, or
5c49e68
+   (at your option) any later version.
5c49e68
+
5c49e68
+   This program is distributed in the hope that it will be useful,
5c49e68
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5c49e68
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5c49e68
+   GNU General Public License for more details.
5c49e68
+
5c49e68
+   You should have received a copy of the GNU General Public License
5c49e68
+   along with this program; if not, write to the Free Software
5c49e68
+   Foundation, Inc., 59 Temple Place - Suite 330,
5c49e68
+   Boston, MA 02111-1307, USA.  */
5c49e68
+
5c49e68
+#include <pthread.h>
5c49e68
+#include <assert.h>
5c49e68
+#include <unistd.h>
5c49e68
+
5c49e68
+static void *start (void *arg)
5c49e68
+{
5c49e68
+  for (;;)
5c49e68
+    pause ();
5c49e68
+  /* NOTREACHED */
5c49e68
+  assert (0);
5c49e68
+  return arg;
5c49e68
+}
5c49e68
+
5c49e68
+int main (void)
5c49e68
+{
5c49e68
+  pthread_t thread;
5c49e68
+  int i;
5c49e68
+
5c49e68
+  i = pthread_create (&thread, NULL, start, NULL);	/* create1 */
5c49e68
+  assert (i == 0);
5c49e68
+
5c49e68
+  pthread_exit (NULL);
5c49e68
+  /* NOTREACHED */
5c49e68
+  assert (0);
5c49e68
+  return 0;
5c49e68
+}
5c49e68
--- /dev/null	1 Jan 1970 00:00:00 -0000
5c49e68
+++ ./gdb/testsuite/gdb.threads/leader-exit.exp	7 Jul 2007 15:21:57 -0000
5c49e68
@@ -0,0 +1,64 @@
5c49e68
+# Copyright (C) 2007 Free Software Foundation, Inc.
5c49e68
+
5c49e68
+# This program is free software; you can redistribute it and/or modify
5c49e68
+# it under the terms of the GNU General Public License as published by
5c49e68
+# the Free Software Foundation; either version 2 of the License, or
5c49e68
+# (at your option) any later version.
5c49e68
+# 
5c49e68
+# This program is distributed in the hope that it will be useful,
5c49e68
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
5c49e68
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5c49e68
+# GNU General Public License for more details.
5c49e68
+# 
5c49e68
+# You should have received a copy of the GNU General Public License
5c49e68
+# along with this program; if not, write to the Free Software
5c49e68
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
5c49e68
+
5c49e68
+# Exit of the thread group leader should not break GDB.
5c49e68
+
5c49e68
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
5c49e68
+
5c49e68
+if $tracelevel then {
5c49e68
+	strace $tracelevel
5c49e68
+}
5c49e68
+
5c49e68
+set testfile "leader-exit"
5c49e68
+set srcfile ${testfile}.c
5c49e68
+set binfile ${objdir}/${subdir}/${testfile}
5c49e68
+
5c49e68
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
5c49e68
+    return -1
5c49e68
+}
5c49e68
+
5c49e68
+gdb_exit
5c49e68
+gdb_start
5c49e68
+gdb_reinitialize_dir $srcdir/$subdir
5c49e68
+gdb_load ${binfile}
5c49e68
+gdb_run_cmd
5c49e68
+
5c49e68
+proc stop_process { description } {
5c49e68
+  global gdb_prompt
5c49e68
+
5c49e68
+  # For this to work we must be sure to consume the "Continuing."
5c49e68
+  # message first, or GDB's signal handler may not be in place.
5c49e68
+  after 1000 {send_gdb "\003"}
5c49e68
+  gdb_expect {
5c49e68
+    -re "Program received signal SIGINT.*$gdb_prompt $"
5c49e68
+      {
5c49e68
+	pass $description
5c49e68
+      }
5c49e68
+    timeout
5c49e68
+      {
5c49e68
+	fail "$description (timeout)"
5c49e68
+      }
5c49e68
+  }
5c49e68
+}
5c49e68
+
5c49e68
+# Prevent races.
3f52bbd
+sleep 8
5c49e68
+
5c49e68
+stop_process "Threads could be stopped"
5c49e68
+
5c49e68
+gdb_test "info threads" \
2d64357
+         "\\* 2 Thread \[^\r\n\]* in \[^\r\n\]*" \
5c49e68
+         "Single thread has been left"