1 1.1 christos # Copyright 2009-2014 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.1 christos if {![istarget "hppa*-hp-hpux*"] && ![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.1 christos set compile_options {debug nowarnings} 37 1.1 christos set dirname [relative_filename [pwd] [file dirname $binfile1]] 38 1.1 christos lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\"" 39 1.1 christos 40 1.1 christos if { [build_executable ${testfile}.exp ${exec1} "${srcfile1}" $compile_options] == -1 } { 41 1.1 christos return -1 42 1.1 christos } 43 1.1 christos 44 1.1 christos if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}" $compile_options] == -1 } { 45 1.1 christos return -1 46 1.1 christos } 47 1.1 christos 48 1.1 christos # Start with a fresh gdb 49 1.1 christos 50 1.1 christos clean_restart ${exec1} 51 1.1 christos 52 1.1 christos # Start the program running, and stop at main. 53 1.1 christos # 54 1.1 christos if ![runto_main] then { 55 1.1 christos perror "Couldn't run ${binfile1}" 56 1.1 christos return 57 1.1 christos } 58 1.1 christos 59 1.1 christos delete_breakpoints 60 1.1 christos 61 1.1 christos # continuing should exec and trigger the bug 62 1.1 christos gdb_test "continue" "SIGSEGV.*" 63 1.1 christos 64 1.1 christos # Start over, but this time, set a breakpoint before the app crashes. 65 1.1 christos 66 1.1 christos clean_restart ${exec1} 67 1.1 christos 68 1.1 christos gdb_test "add-inferior -exec ${binfile2}" \ 69 1.1 christos "Added inferior 2.*" \ 70 1.1 christos "add inferior 2 with -exec ${exec2}" 71 1.1 christos 72 1.1 christos set bp_location [gdb_get_line_number "set breakpoint here" ${srcfile2}] 73 1.1 christos 74 1.1 christos gdb_test "inferior 2" 75 1.1 christos gdb_test "break ${srcfile2}:${bp_location}" ".*" 76 1.1 christos 77 1.1 christos # Start the program running, and stop at main. 78 1.1 christos # 79 1.1 christos gdb_test "inferior 1" 80 1.1 christos 81 1.1 christos # Now run to the breakpoint. This should cross the exec, and stop at 82 1.1 christos # the breakpoint before the crash. 83 1.1 christos gdb_test "run" "${srcfile2}:${bp_location}.*set breakpoint here.*" 84 1.1 christos 85 1.1 christos return 0 86