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