1 1.6 christos # Copyright 2009-2016 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos if { [is_remote target] || ![isnative] } then { 17 1.1 christos continue 18 1.1 christos } 19 1.1 christos 20 1.1 christos # Until "catch exec" is implemented on other targets... 21 1.1 christos # 22 1.6 christos if {![istarget "*-linux*"]} then { 23 1.1 christos continue 24 1.1 christos } 25 1.1 christos 26 1.1 christos set testfile "bkpt-multi-exec" 27 1.1 christos 28 1.1 christos set exec1 "bkpt-multi-exec" 29 1.1 christos set srcfile1 ${exec1}.c 30 1.1 christos set binfile1 [standard_output_file ${exec1}] 31 1.1 christos 32 1.1 christos set exec2 "crashme" 33 1.1 christos set srcfile2 ${exec2}.c 34 1.1 christos set binfile2 [standard_output_file ${exec2}] 35 1.1 christos 36 1.6 christos set compile_options {debug} 37 1.1 christos 38 1.1 christos if { [build_executable ${testfile}.exp ${exec1} "${srcfile1}" $compile_options] == -1 } { 39 1.1 christos return -1 40 1.1 christos } 41 1.1 christos 42 1.1 christos if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}" $compile_options] == -1 } { 43 1.1 christos return -1 44 1.1 christos } 45 1.1 christos 46 1.1 christos # Start with a fresh gdb 47 1.1 christos 48 1.1 christos clean_restart ${exec1} 49 1.1 christos 50 1.1 christos # Start the program running, and stop at main. 51 1.1 christos # 52 1.1 christos if ![runto_main] then { 53 1.1 christos perror "Couldn't run ${binfile1}" 54 1.1 christos return 55 1.1 christos } 56 1.1 christos 57 1.1 christos delete_breakpoints 58 1.1 christos 59 1.1 christos # continuing should exec and trigger the bug 60 1.1 christos gdb_test "continue" "SIGSEGV.*" 61 1.1 christos 62 1.1 christos # Start over, but this time, set a breakpoint before the app crashes. 63 1.1 christos 64 1.1 christos clean_restart ${exec1} 65 1.1 christos 66 1.1 christos gdb_test "add-inferior -exec ${binfile2}" \ 67 1.1 christos "Added inferior 2.*" \ 68 1.1 christos "add inferior 2 with -exec ${exec2}" 69 1.1 christos 70 1.1 christos set bp_location [gdb_get_line_number "set breakpoint here" ${srcfile2}] 71 1.1 christos 72 1.1 christos gdb_test "inferior 2" 73 1.1 christos gdb_test "break ${srcfile2}:${bp_location}" ".*" 74 1.1 christos 75 1.1 christos # Start the program running, and stop at main. 76 1.1 christos # 77 1.1 christos gdb_test "inferior 1" 78 1.1 christos 79 1.1 christos # Now run to the breakpoint. This should cross the exec, and stop at 80 1.1 christos # the breakpoint before the crash. 81 1.1 christos gdb_test "run" "${srcfile2}:${bp_location}.*set breakpoint here.*" 82 1.1 christos 83 1.1 christos return 0 84