1# This testcase is part of GDB, the GNU debugger. 2 3# Copyright 2020 Free Software Foundation, Inc. 4 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 3 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18# Test that when setting breakpoints, setting a breakpoint on "foo" 19# creates locations for all external and static functions called "foo" 20# in the program, with and without debug info. 21 22standard_testfile .c msym-bp-2.c 23 24# Run "info breakpoints", and check that we find the two locations, 25# LOC_A and LOC_B, in either order. 26proc test_info_break_2 {loc_a loc_b} { 27 set re1 ".*\.1.*${loc_a}\r\n.*\.2.*${loc_b}" 28 set re2 ".*\.1.*${loc_b}\r\n.*\.2.*${loc_a}" 29 gdb_test "info breakpoint" "$re1|$re2" 30} 31 32proc test {debug} { 33 global testfile srcfile srcfile2 34 global decimal 35 36 if {$debug} { 37 set options "debug" 38 } else { 39 set options "" 40 } 41 42 if { [prepare_for_testing "failed to prepare" $testfile-$debug \ 43 [list $srcfile $srcfile2] $options] } { 44 return -1 45 } 46 47 # Should find two locations: the static foo in the msym-bp.c file, 48 # and the extern foo in the msym-bp-2.c file. Same result 49 # expected before and after running to main. 50 proc test_break {prefix} { 51 global decimal 52 upvar debug debug 53 54 with_test_prefix $prefix { 55 gdb_test "break foo" "\\(2 locations\\)" 56 57 if {$debug} { 58 test_info_break_2 \ 59 "in foo at .*msym-bp.c:$decimal" \ 60 "in foo at .*msym-bp-2.c:$decimal" 61 } else { 62 test_info_break_2 \ 63 "<foo\\+$decimal>" \ 64 "<foo\\+$decimal>" 65 } 66 } 67 } 68 69 test_break "before run" 70 71 if ![runto_main] { 72 fail "can't run to main" 73 return 74 } 75 76 delete_breakpoints 77 78 test_break "at main" 79} 80 81foreach_with_prefix debug {0 1} { 82 test $debug 83} 84