xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.threads/execl.exp (revision cc576e1d8e4f4078fd4e81238abca9fca216f6ec)
1# Copyright (C) 2008-2015 Free Software Foundation, Inc.
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
18if { [is_remote target] } then {
19    continue
20}
21
22# Original image, loads a thread library.
23standard_testfile
24
25if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
26    return -1
27}
28
29# New image, that does not load a thread library.
30set testfile1 "execl1"
31set srcfile1 ${testfile1}.c
32set binfile1 [standard_output_file ${testfile1}]
33
34if {[gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug}] != "" } {
35    return -1
36}
37
38clean_restart ${binfile}
39
40runto_main
41
42gdb_test "b [gdb_get_line_number "breakpoint here"]" \
43         ".*Breakpoint .*execl.*" "set breakpoint at execl"
44
45gdb_test "continue" ".*breakpoint here.*" "continue to exec"
46
47gdb_test "info threads" ".*3 *Thread.*2 *Thread.*1 *Thread.*" "info threads before exec"
48
49# When continuing from this point we'll hit the breakpoint in main()
50# again, this time in the exec'd process.
51gdb_test "continue" ".*Breakpoint 1, main.*" \
52    "continue across exec"
53
54gdb_test "info threads" ".*" "info threads after exec"
55
56set test "info threads after exec"
57gdb_test_multiple "info threads" "$test" {
58    -re "2 *Thread .*$gdb_prompt $" {
59	# Old threads left behind.
60	fail "$test"
61    }
62    -re "4 *Thread .*$gdb_prompt $" {
63	# New threads registered.
64	fail "$test"
65    }
66    -re "$gdb_prompt $" {
67	# Target doesn't register the main thread, pass for now.
68	pass "$test"
69    }
70}
71
72gdb_continue_to_end
73