]>
Commit | Line | Data |
---|---|---|
4c38e0a4 | 1 | # Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. |
49fd4a42 PA |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # Test handling of threads across an execl. | |
17 | ||
18 | ||
19 | # Original image, loads a thread library. | |
20 | set testfile "execl" | |
21 | set srcfile ${testfile}.c | |
22 | set binfile ${objdir}/${subdir}/${testfile} | |
23 | ||
24 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
25 | return -1 | |
26 | } | |
27 | ||
28 | # New image, that does not load a thread library. | |
29 | set testfile1 "execl1" | |
30 | set srcfile1 ${testfile1}.c | |
31 | set binfile1 ${objdir}/${subdir}/${testfile1} | |
32 | ||
33 | if {[gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug}] != "" } { | |
34 | return -1 | |
35 | } | |
36 | ||
37 | gdb_exit | |
38 | gdb_start | |
39 | gdb_reinitialize_dir $srcdir/$subdir | |
40 | gdb_load ${binfile} | |
41 | ||
42 | runto_main | |
43 | ||
44 | gdb_test "b [gdb_get_line_number "breakpoint here"]" \ | |
45 | ".*Breakpoint .*execl.*" "set breakpoint at execl" | |
46 | ||
47 | gdb_test "continue" ".*breakpoint here.*" "continue to exec" | |
48 | ||
49 | gdb_test "info threads" ".*3 Thread.*2 Thread.*1 Thread.*" "info threads before exec" | |
50 | ||
51 | # When continuing from this point we'll hit the breakpoint in main() | |
52 | # again, this time in the exec'd process. | |
53 | gdb_test "continue" ".*Breakpoint 1, main.*" \ | |
54 | "continue across exec" | |
55 | ||
56 | gdb_test "info threads" ".*" "info threads after exec" | |
57 | ||
58 | set test "info threads after exec" | |
59 | gdb_test_multiple "info threads" "$test" { | |
60 | -re "2 Thread .*$gdb_prompt $" { | |
61 | # Old threads left behind. | |
62 | fail "$test" | |
63 | } | |
64 | -re "4 Thread .*$gdb_prompt $" { | |
65 | # New threads registered. | |
66 | fail "$test" | |
67 | } | |
68 | -re "$gdb_prompt $" { | |
69 | # Target doesn't register the main thread, pass for now. | |
70 | pass "$test" | |
71 | } | |
72 | } | |
73 | ||
74 | gdb_test "continue" ".*Program exited normally\\." \ | |
75 | "continue to end" |