Commit | Line | Data |
---|---|---|
e2882c85 | 1 | # Copyright (C) 2016-2018 Free Software Foundation, Inc. |
bb805577 JK |
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 | if {![can_spawn_for_attach]} { | |
17 | return 0 | |
18 | } | |
19 | ||
20 | standard_testfile .c | |
21 | set executable ${testfile} | |
22 | ||
23 | if { [build_executable ${testfile}.exp $executable $srcfile \ | |
dc196b23 | 24 | [list debug pthreads "additional_flags=-fPIE" "ldflags=-pie"]] } { |
bb805577 JK |
25 | return -1 |
26 | } | |
27 | ||
28 | # Start the program running and then wait for a bit, to be sure | |
29 | # that it can be attached to. | |
30 | ||
31 | set test_spawn_id [spawn_wait_for_attach $binfile] | |
32 | set testpid [spawn_id_get_pid $test_spawn_id] | |
33 | ||
34 | # gdb_load ("file" command) must not be executed for the bug reproducibility. | |
35 | # That includes prepare_for_testing or clean_restart. | |
36 | gdb_start | |
37 | ||
38 | set test "attach" | |
39 | gdb_test_multiple "attach $testpid" $test { | |
40 | -re "Attaching to process $testpid\r\n.*Cannot insert breakpoint .*\r\n$gdb_prompt $" { | |
41 | fail $test | |
42 | } | |
43 | -re "Attaching to process $testpid\r\n.*\r\n$gdb_prompt $" { | |
44 | pass $test | |
45 | } | |
46 | } | |
47 | ||
48 | kill_wait_spawned_process $test_spawn_id |