]>
Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 2009-2015 Free Software Foundation, Inc. |
b321dd90 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 | if { [is_remote target] || ![isnative] } then { | |
17 | continue | |
18 | } | |
19 | ||
2d4e0376 YQ |
20 | # Until "catch exec" is implemented on other targets... |
21 | # | |
3ca22649 | 22 | if {![istarget "*-linux*"]} then { |
2d4e0376 YQ |
23 | continue |
24 | } | |
25 | ||
b321dd90 PA |
26 | set testfile "bkpt-multi-exec" |
27 | ||
28 | set exec1 "bkpt-multi-exec" | |
29 | set srcfile1 ${exec1}.c | |
7bb18ae2 | 30 | set binfile1 [standard_output_file ${exec1}] |
b321dd90 PA |
31 | |
32 | set exec2 "crashme" | |
33 | set srcfile2 ${exec2}.c | |
7bb18ae2 | 34 | set binfile2 [standard_output_file ${exec2}] |
b321dd90 | 35 | |
762f7747 | 36 | set compile_options {debug} |
3fef966c TT |
37 | set dirname [relative_filename [pwd] [file dirname $binfile1]] |
38 | lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\"" | |
39 | ||
40 | if { [build_executable ${testfile}.exp ${exec1} "${srcfile1}" $compile_options] == -1 } { | |
b321dd90 PA |
41 | return -1 |
42 | } | |
43 | ||
3fef966c | 44 | if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}" $compile_options] == -1 } { |
b321dd90 PA |
45 | return -1 |
46 | } | |
b321dd90 PA |
47 | |
48 | # Start with a fresh gdb | |
49 | ||
d8053d4d | 50 | clean_restart ${exec1} |
b321dd90 PA |
51 | |
52 | # Start the program running, and stop at main. | |
53 | # | |
54 | if ![runto_main] then { | |
55 | perror "Couldn't run ${binfile1}" | |
56 | return | |
57 | } | |
58 | ||
59 | delete_breakpoints | |
60 | ||
61 | # continuing should exec and trigger the bug | |
62 | gdb_test "continue" "SIGSEGV.*" | |
63 | ||
64 | # Start over, but this time, set a breakpoint before the app crashes. | |
65 | ||
d8053d4d | 66 | clean_restart ${exec1} |
b321dd90 | 67 | |
d8053d4d PA |
68 | gdb_test "add-inferior -exec ${binfile2}" \ |
69 | "Added inferior 2.*" \ | |
70 | "add inferior 2 with -exec ${exec2}" | |
b321dd90 PA |
71 | |
72 | set bp_location [gdb_get_line_number "set breakpoint here" ${srcfile2}] | |
73 | ||
74 | gdb_test "inferior 2" | |
f6978de9 | 75 | gdb_test "break ${srcfile2}:${bp_location}" ".*" |
b321dd90 PA |
76 | |
77 | # Start the program running, and stop at main. | |
78 | # | |
79 | gdb_test "inferior 1" | |
80 | ||
81 | # Now run to the breakpoint. This should cross the exec, and stop at | |
82 | # the breakpoint before the crash. | |
83 | gdb_test "run" "${srcfile2}:${bp_location}.*set breakpoint here.*" | |
84 | ||
85 | return 0 |