Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / execl.exp
CommitLineData
88b9d363 1# Copyright (C) 2008-2022 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
49fd4a42 18# Original image, loads a thread library.
0efbbabc 19standard_testfile
49fd4a42
PA
20
21if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
22 return -1
23}
24
25# New image, that does not load a thread library.
26set testfile1 "execl1"
27set srcfile1 ${testfile1}.c
0efbbabc 28set binfile1 [standard_output_file ${testfile1}]
49fd4a42
PA
29
30if {[gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug}] != "" } {
31 return -1
32}
33
0efbbabc 34clean_restart ${binfile}
49fd4a42
PA
35
36runto_main
37
38gdb_test "b [gdb_get_line_number "breakpoint here"]" \
39 ".*Breakpoint .*execl.*" "set breakpoint at execl"
40
41gdb_test "continue" ".*breakpoint here.*" "continue to exec"
42
b05b1202 43gdb_test "info threads" "1 *Thread.*2 *Thread.*3 *Thread.*" "info threads before exec"
49fd4a42 44
14e9c72c
TV
45# Work around PR25656, where the breakpoint above sets 2 breakpoint locations:
46# - one on gdb.threads/execl.c:$linenumber, and
47# - one in GLIBC's execl.c:$linenumber, in __GI_execl
48# Delete the breakpoint to make sure we hit main upon continue, rather than
49# __GI_execl.
50gdb_test_no_output "delete 2"
51
49fd4a42
PA
52# When continuing from this point we'll hit the breakpoint in main()
53# again, this time in the exec'd process.
54gdb_test "continue" ".*Breakpoint 1, main.*" \
55 "continue across exec"
56
f302f9e2 57gdb_test_multiple "info threads" "info threads after exec" {
a283af87 58 -re "2 *Thread .*$gdb_prompt $" {
49fd4a42 59 # Old threads left behind.
f302f9e2 60 fail "$gdb_test_name"
49fd4a42 61 }
a283af87 62 -re "4 *Thread .*$gdb_prompt $" {
49fd4a42 63 # New threads registered.
f302f9e2 64 fail "$gdb_test_name"
49fd4a42
PA
65 }
66 -re "$gdb_prompt $" {
67 # Target doesn't register the main thread, pass for now.
f302f9e2 68 pass "$gdb_test_name"
49fd4a42
PA
69 }
70}
71
fda326dd 72gdb_continue_to_end
This page took 1.551674 seconds and 4 git commands to generate.