OLD | NEW |
1 /* This testcase is part of GDB, the GNU debugger. | 1 /* This testcase is part of GDB, the GNU debugger. |
2 | 2 |
3 Copyright 2009-2012 Free Software Foundation, Inc. | 3 Copyright 2013 Free Software Foundation, Inc. |
4 | 4 |
5 This program is free software; you can redistribute it and/or modify | 5 This program is free software; you can redistribute it and/or modify |
6 it under the terms of the GNU General Public License as published by | 6 it under the terms of the GNU General Public License as published by |
7 the Free Software Foundation; either version 3 of the License, or | 7 the Free Software Foundation; either version 3 of the License, or |
8 (at your option) any later version. | 8 (at your option) any later version. |
9 | 9 |
10 This program is distributed in the hope that it will be useful, | 10 This program is distributed in the hope that it will be useful, |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 GNU General Public License for more details. | 13 GNU General Public License for more details. |
14 | 14 |
15 You should have received a copy of the GNU General Public License | 15 You should have received a copy of the GNU General Public License |
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
17 | 17 |
18 #include <pthread.h> | 18 template<typename T> |
19 #include <unistd.h> | 19 void |
20 #include <stdlib.h> | 20 throwit (T val) |
| 21 { |
| 22 throw val; |
| 23 } |
21 | 24 |
22 static const char *image; | 25 template<typename T> |
| 26 void |
| 27 rethrowit (T val) |
| 28 { |
| 29 try |
| 30 { |
| 31 try |
| 32 » { |
| 33 » throwit (val); |
| 34 » } |
| 35 catch (...) |
| 36 » { |
| 37 » throw; |
| 38 » } |
| 39 } |
| 40 catch (...) |
| 41 { |
| 42 // Ignore. |
| 43 } |
| 44 } |
23 | 45 |
24 void * | 46 struct maude |
25 thread_execler (void *arg) | |
26 { | 47 { |
27 /* Exec ourselves again. */ | 48 int mv; |
28 if (execl (image, image, NULL) == -1) | |
29 { | |
30 perror ("execl"); | |
31 abort (); | |
32 } | |
33 | 49 |
34 return NULL; | 50 maude (int x) : mv (x) { } |
35 } | 51 }; |
36 | 52 |
37 int | 53 int |
38 main (int argc, char **argv) | 54 main (int argc, char **argv) |
39 { | 55 { |
40 pthread_t thread; | 56 maude mm (77); |
| 57 maude &mmm (mm); |
41 | 58 |
42 image = argv[0]; | 59 rethrowit ("hi bob"); |
43 | 60 rethrowit (23); |
44 pthread_create (&thread, NULL, thread_execler, NULL); | 61 rethrowit (mm); |
45 pthread_join (thread, NULL); | 62 rethrowit (mmm); |
46 | 63 |
47 return 0; | 64 return 0; |
48 } | 65 } |
OLD | NEW |