1# Copyright 2013-2023 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 16standard_testfile lspec.cc 17 18if {[skip_cplus_tests]} { 19 unsupported "skipping C++ tests" 20 return 21} 22 23set opts {debug c++} 24set objfile1 [standard_output_file ${testfile}one.o] 25set objfile2 [standard_output_file ${testfile}two.o] 26 27if { [file pathtype $objdir] == "relative" } { 28 untested "objdir $objdir should be absolute" 29 return 30} 31 32with_cwd $srcdir/${subdir}/base/one { 33 if { [gdb_compile "thefile.cc" $objfile1 object $opts] != "" } { 34 untested "compilation failed" 35 return 36 } 37} 38 39with_cwd $srcdir/${subdir}/base/two { 40 if { [gdb_compile "thefile.cc" $objfile2 object $opts] != "" } { 41 untested "compilation failed" 42 return 43 } 44} 45 46if { [gdb_compile "$srcdir/${subdir}/$srcfile $objfile1 $objfile2" \ 47 $binfile executable $opts] != "" } { 48 return -1 49} 50 51clean_restart ${testfile} 52 53gdb_test_no_output "set multiple-symbols ask" 54 55gdb_test_no_output "set filename-display absolute" 56set cmd "break twodup" 57set test "break twodup absolute" 58gdb_test_multiple $cmd $test { 59 -re "^$cmd\r\n\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] \[^\r\n\]+base.one.thefile\\.cc:twodup\\\(\\\)\r\n\\\[3\\\] \[^\r\n\]+base.two.thefile\\.cc:twodup\\\(\\\)\r\n> $" { 60 pass $test 61 } 62} 63gdb_test "0" "canceled" 64 65gdb_test_no_output "set filename-display relative" 66 67set cmd "break twodup" 68set test "break twodup relative" 69gdb_test_multiple $cmd $test { 70 -re "^$cmd\r\n\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] thefile\\.cc:twodup\\\(\\\)\r\n\\\[3\\\] thefile\\.cc:twodup\\\(\\\)\r\n> $" { 71 pass $test 72 } 73} 74gdb_test "2" "^2\r\nBreakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\." 75 76gdb_breakpoint "body_elsewhere" 77 78gdb_run_cmd 79gdb_test "" "Breakpoint \[0-9\]+, twodup \\(\\) at thefile.cc:\[0-9\]+\r\n.*" "expect breakpoint" 80 81gdb_test "info source" "\r\nLocated in \[^\r\n\]+base.one.thefile\\.cc\r\n.*" 82 83gdb_continue_to_breakpoint "body_elsewhere" ".* body_elsewhere marker .*" 84 85delete_breakpoints 86 87set cmd "break twodup" 88set test "break twodup relative other" 89gdb_test_multiple $cmd $test { 90 -re "^$cmd\r\n\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] thefile\\.cc:twodup\\\(\\\)\r\n\\\[3\\\] thefile\\.cc:twodup\\\(\\\)\r\n> $" { 91 pass $test 92 } 93} 94gdb_test "3" "^3\r\nBreakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\." 95 96gdb_breakpoint "body_elsewhere" 97 98gdb_run_cmd 99gdb_test "" "Breakpoint \[0-9\]+, twodup \\(\\) at thefile.cc:\[0-9\]+\r\n.*" "expect breakpoint other" 100 101gdb_test "info source" "\r\nLocated in \[^\r\n\]+.base.two.thefile\\.cc\r\n.*" "info source other" 102 103gdb_continue_to_breakpoint "body_elsewhere other" ".* body_elsewhere marker .*" 104