Home | History | Annotate | Line # | Download | only in gdb.ada
file-then-restart.exp revision 1.1
      1  1.1  christos # Copyright 2023-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.1  christos load_lib "ada.exp"
     17  1.1  christos 
     18  1.1  christos require allow_ada_tests
     19  1.1  christos 
     20  1.1  christos # This testcase verifies the behavior of the `start' command, which
     21  1.1  christos # does not work when we use the gdb stub...
     22  1.1  christos require !use_gdb_stub
     23  1.1  christos 
     24  1.1  christos standard_ada_testfile first
     25  1.1  christos 
     26  1.1  christos if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
     27  1.1  christos     return -1
     28  1.1  christos }
     29  1.1  christos 
     30  1.1  christos # Build the second test program
     31  1.1  christos set srcfile2 ${srcdir}/${subdir}/${testdir}/second.adb
     32  1.1  christos set binfile2 [standard_output_file second]
     33  1.1  christos 
     34  1.1  christos if {[gdb_compile_ada "${srcfile2}" "${binfile2}" executable {debug}] != ""} {
     35  1.1  christos     return -1
     36  1.1  christos }
     37  1.1  christos 
     38  1.1  christos foreach_with_prefix scenario {kill no-kill} {
     39  1.1  christos     clean_restart $binfile
     40  1.1  christos 
     41  1.1  christos     # Start the program, we should land in the program main procedure
     42  1.1  christos     if {[gdb_start_cmd] < 0} {
     43  1.1  christos 	fail start
     44  1.1  christos 	return -1
     45  1.1  christos     }
     46  1.1  christos 
     47  1.1  christos     gdb_test "" \
     48  1.1  christos 	"first \\(\\) at .*first.adb.*" \
     49  1.1  christos 	"start first"
     50  1.1  christos 
     51  1.1  christos     gdb_test_no_output "set confirm off"
     52  1.1  christos 
     53  1.1  christos     set result [gdb_file_cmd $binfile2 [expr {$scenario == "kill"}]]
     54  1.1  christos     gdb_assert {$result == 0} "switch to second executable"
     55  1.1  christos 
     56  1.1  christos     # Start the program a second time, GDB should land in procedure
     57  1.1  christos     # Second this time.
     58  1.1  christos     if {[gdb_start_cmd] < 0} {
     59  1.1  christos 	fail "start second"
     60  1.1  christos     } else {
     61  1.1  christos 	gdb_test "" \
     62  1.1  christos 	    "second \\(\\) at .*second.adb.*" \
     63  1.1  christos 	    "start second"
     64  1.1  christos     }
     65  1.1  christos }
     66