1 1.1 christos # This testcase is part of GDB, the GNU debugger. 2 1.1 christos 3 1.1 christos # Copyright 2014-2015 Free Software Foundation, Inc. 4 1.1 christos 5 1.1 christos # This program is free software; you can redistribute it and/or modify 6 1.1 christos # it under the terms of the GNU General Public License as published by 7 1.1 christos # the Free Software Foundation; either version 3 of the License, or 8 1.1 christos # (at your option) any later version. 9 1.1 christos # 10 1.1 christos # This program is distributed in the hope that it will be useful, 11 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 1.1 christos # GNU General Public License for more details. 14 1.1 christos # 15 1.1 christos # You should have received a copy of the GNU General Public License 16 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 1.1 christos 18 1.1 christos standard_testfile 19 1.1 christos 20 1.1 christos # Run the test proper. THREADED indicates whether to build a threaded 21 1.1 christos # program and spawn several threads before trying to kill the program. 22 1.1 christos 23 1.1 christos proc test {threaded} { 24 1.1 christos global testfile srcfile 25 1.1 christos 26 1.1 christos with_test_prefix [expr ($threaded)?"threaded":"non-threaded"] { 27 1.1 christos 28 1.1 christos set options {debug} 29 1.1 christos if {$threaded} { 30 1.1 christos lappend options "pthreads" 31 1.1 christos lappend options "additional_flags=-DUSE_THREADS" 32 1.1 christos set prog ${testfile}_threads 33 1.1 christos } else { 34 1.1 christos set prog ${testfile}_nothreads 35 1.1 christos } 36 1.1 christos 37 1.1 christos if {[prepare_for_testing "failed to prepare" $prog $srcfile $options] == -1} { 38 1.1 christos return -1 39 1.1 christos } 40 1.1 christos 41 1.1 christos if { ![runto main] } then { 42 1.1 christos fail "run to main" 43 1.1 christos return 44 1.1 christos } 45 1.1 christos 46 1.1 christos set linenum [gdb_get_line_number "set break here"] 47 1.1 christos gdb_breakpoint "$srcfile:$linenum" 48 1.1 christos gdb_continue_to_breakpoint "break here" ".*break here.*" 49 1.1 christos 50 1.1 christos if {$threaded} { 51 1.1 christos gdb_test "info threads" "6.*5.*4.*3.*2.*1.*" "all threads started" 52 1.1 christos } 53 1.1 christos 54 1.1 christos # This kills and ensures no output other than the prompt comes out, 55 1.1 christos # like: 56 1.1 christos # 57 1.1 christos # (gdb) kill 58 1.1 christos # Kill the program being debugged? (y or n) y 59 1.1 christos # (gdb) 60 1.1 christos # 61 1.1 christos # If we instead saw more output, like e.g., with an extended-remote 62 1.1 christos # connection: 63 1.1 christos # 64 1.1 christos # (gdb) kill 65 1.1 christos # Kill the program being debugged? (y or n) y 66 1.1 christos # Remote connection closed 67 1.1 christos # (gdb) 68 1.1 christos # 69 1.1 christos # the above would mean that the remote end crashed. 70 1.1 christos 71 1.1 christos gdb_test "kill" "^y" "kill program" "Kill the program being debugged\\? \\(y or n\\) $" "y" 72 1.1 christos } 73 1.1 christos } 74 1.1 christos 75 1.1 christos foreach threaded {true false} { 76 1.1 christos test $threaded 77 1.1 christos } 78