]>
Commit | Line | Data |
---|---|---|
3a58abaf AM |
1 | 2007-07-07 Jan Kratochvil <jan.kratochvil@redhat.com> |
2 | ||
3 | * gdb.threads/leader-exit.c, gdb.threads/leader-exit.exp: New files. | |
4 | ||
5 | --- /dev/null 1 Jan 1970 00:00:00 -0000 | |
6 | +++ ./gdb/testsuite/gdb.threads/leader-exit.c 7 Jul 2007 15:21:57 -0000 | |
7 | @@ -0,0 +1,47 @@ | |
8 | +/* Clean exit of the thread group leader should not break GDB. | |
9 | + | |
10 | + Copyright 2007 Free Software Foundation, Inc. | |
11 | + | |
12 | + This file is part of GDB. | |
13 | + | |
14 | + This program is free software; you can redistribute it and/or modify | |
15 | + it under the terms of the GNU General Public License as published by | |
16 | + the Free Software Foundation; either version 2 of the License, or | |
17 | + (at your option) any later version. | |
18 | + | |
19 | + This program is distributed in the hope that it will be useful, | |
20 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | + GNU General Public License for more details. | |
23 | + | |
24 | + You should have received a copy of the GNU General Public License | |
25 | + along with this program; if not, write to the Free Software | |
26 | + Foundation, Inc., 59 Temple Place - Suite 330, | |
27 | + Boston, MA 02111-1307, USA. */ | |
28 | + | |
29 | +#include <pthread.h> | |
30 | +#include <assert.h> | |
31 | +#include <unistd.h> | |
32 | + | |
33 | +static void *start (void *arg) | |
34 | +{ | |
35 | + for (;;) | |
36 | + pause (); | |
37 | + /* NOTREACHED */ | |
38 | + assert (0); | |
39 | + return arg; | |
40 | +} | |
41 | + | |
42 | +int main (void) | |
43 | +{ | |
44 | + pthread_t thread; | |
45 | + int i; | |
46 | + | |
47 | + i = pthread_create (&thread, NULL, start, NULL); /* create1 */ | |
48 | + assert (i == 0); | |
49 | + | |
50 | + pthread_exit (NULL); | |
51 | + /* NOTREACHED */ | |
52 | + assert (0); | |
53 | + return 0; | |
54 | +} | |
55 | --- /dev/null 1 Jan 1970 00:00:00 -0000 | |
56 | +++ ./gdb/testsuite/gdb.threads/leader-exit.exp 7 Jul 2007 15:21:57 -0000 | |
57 | @@ -0,0 +1,64 @@ | |
58 | +# Copyright (C) 2007 Free Software Foundation, Inc. | |
59 | + | |
60 | +# This program is free software; you can redistribute it and/or modify | |
61 | +# it under the terms of the GNU General Public License as published by | |
62 | +# the Free Software Foundation; either version 2 of the License, or | |
63 | +# (at your option) any later version. | |
64 | +# | |
65 | +# This program is distributed in the hope that it will be useful, | |
66 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
67 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
68 | +# GNU General Public License for more details. | |
69 | +# | |
70 | +# You should have received a copy of the GNU General Public License | |
71 | +# along with this program; if not, write to the Free Software | |
72 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
73 | + | |
74 | +# Exit of the thread group leader should not break GDB. | |
75 | + | |
76 | +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>. | |
77 | + | |
78 | +if $tracelevel then { | |
79 | + strace $tracelevel | |
80 | +} | |
81 | + | |
82 | +set testfile "leader-exit" | |
83 | +set srcfile ${testfile}.c | |
84 | +set binfile ${objdir}/${subdir}/${testfile} | |
85 | + | |
86 | +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
87 | + return -1 | |
88 | +} | |
89 | + | |
90 | +gdb_exit | |
91 | +gdb_start | |
92 | +gdb_reinitialize_dir $srcdir/$subdir | |
93 | +gdb_load ${binfile} | |
94 | +gdb_run_cmd | |
95 | + | |
96 | +proc stop_process { description } { | |
97 | + global gdb_prompt | |
98 | + | |
99 | + # For this to work we must be sure to consume the "Continuing." | |
100 | + # message first, or GDB's signal handler may not be in place. | |
101 | + after 1000 {send_gdb "\003"} | |
102 | + gdb_expect { | |
103 | + -re "Program received signal SIGINT.*$gdb_prompt $" | |
104 | + { | |
105 | + pass $description | |
106 | + } | |
107 | + timeout | |
108 | + { | |
109 | + fail "$description (timeout)" | |
110 | + } | |
111 | + } | |
112 | +} | |
113 | + | |
114 | +# Prevent races. | |
115 | +sleep 8 | |
116 | + | |
117 | +stop_process "Threads could be stopped" | |
118 | + | |
119 | +gdb_test "info threads" \ | |
120 | + "\\* 2 Thread \[^\r\n\]* in \[^\r\n\]*" \ | |
121 | + "Single thread has been left" |