1# Copyright 2007-2017 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 16# This test verifies that setting breakpoint on line in template 17# function will fire in all instantiations of that template. 18 19if { [skip_stl_tests] } { continue } 20 21# On SPU this test fails because the executable exceeds local storage size. 22if { [istarget "spu*-*-*"] } { 23 return 0 24} 25 26 27standard_testfile .cc 28 29if [get_compiler_info "c++"] { 30 return -1 31} 32 33if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { 34 return -1 35} 36 37set bp_location [gdb_get_line_number "set breakpoint here"] 38 39# Set a breakpoint with multiple locations 40# and a condition. 41 42gdb_test "break $srcfile:$bp_location if i==1" \ 43 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \ 44 "initial condition: set breakpoint" 45 46gdb_run_cmd 47 48set test "initial condition: run to breakpoint" 49gdb_test_multiple "" $test { 50 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" { 51 pass $test 52 break 53 } 54} 55 56gdb_test "continue" \ 57 ".*Breakpoint.*foo<double> \\(i=1\\).*" \ 58 "initial condition: run to breakpoint 2" 59 60# Set breakpoint with multiple locations. 61# Separately set the condition. 62 63delete_breakpoints 64gdb_test "kill" "" "kill" \ 65 {Kill the program being debugged\? \(y or n\) } "y" 66 67gdb_test "break $srcfile:$bp_location" \ 68 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \ 69 "separate condition: set breakpoint" 70 71gdb_test_no_output {condition $bpnum i==1} \ 72 "separate condition: set condition" 73 74gdb_run_cmd 75gdb_test "" "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*" "separate condition: run to breakpoint" 76 77gdb_test "continue" \ 78 ".*Breakpoint.*foo<double> \\(i=1\\).*" \ 79 "separate condition: run to breakpoint 2" 80 81# Try disabling a single location. We also test 82# that at least in simple cases, the enable/disable 83# state of locations surive "run". 84gdb_test_no_output {disable $bpnum.1} "disabling location: disable" 85 86gdb_run_cmd 87gdb_test "" "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*" "disabling location: run to breakpoint" 88 89# Try disabling entire breakpoint 90gdb_test_no_output {enable $bpnum.1} "disabling location: enable" 91 92 93gdb_test_no_output {disable $bpnum} "disable breakpoint: disable" 94 95gdb_run_cmd 96gdb_test "" "$inferior_exited_re normally.*" "disable breakpoint: run to breakpoint" 97 98# Make sure breakpoint can be set on a specific instantion. 99delete_breakpoints 100gdb_test "break 'void foo<int>(int)'" ".*" \ 101 "instantiation: set breakpoint" 102 103 104gdb_run_cmd 105gdb_test "" "Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*" "instantiation: run to breakpoint" 106 107gdb_test "continue" \ 108 ".*Breakpoint.*foo<int> \\(i=1\\).*" \ 109 "instantiation: run to breakpoint 2" 110 111 112# Make sure we can set a breakpoint on a source statement that spans 113# multiple lines. 114 115delete_breakpoints 116 117set bp_location [gdb_get_line_number "set multi-line breakpoint here"] 118 119if { ![runto_main] } { 120 fail "can't run to main for multi_line_foo tests." 121 return 0 122} 123 124gdb_test "break $srcfile:$bp_location" \ 125 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \ 126 "set multi_line_foo breakpoint" 127gdb_test "continue" \ 128 ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \ 129 "run to multi_line_foo breakpoint 2 <int>" 130gdb_test "continue" \ 131 ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \ 132 "run to multi_line_foo breakpoint 2 <double>" 133