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