1# Copyright 2016-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
16# Regression test for PR breakpoints/18303.  Tests that the correct
17# errors is generated when setting a breakpoint in a non-existent
18# file with a Windows-style logical drive names and C++.
19
20if {[skip_cplus_tests]} {
21    return
22}
23
24load_lib mi-support.exp
25set MIFLAGS "-i=mi"
26
27standard_testfile .cc
28set exefile $testfile
29
30if {[build_executable "failed to prepare" $exefile $srcfile {debug c++}]} {
31    return -1
32}
33
34mi_clean_restart $binfile
35
36# Turn off the pending breakpoint queries.
37mi_gdb_test "-interpreter-exec console \"set breakpoint pending off\"" \
38  {=cmd-param-changed,param=\"breakpoint pending\",.*\^done} \
39  "-interpreter-exec console \"set breakpoint pending off\""
40
41mi_runto_main
42
43# Run to a location in the file.
44set bp_location [gdb_get_line_number "set breakpoint here"]
45
46mi_gdb_test "-break-insert ${srcfile}:${bp_location}" \
47    {\^done,bkpt=.number="2",type="breakpoint".*\}} "set breakpoint"
48
49mi_execute_to "exec-continue" "breakpoint-hit" "myfunction" ".*" ".*" "24" \
50    { "" "disp=\"keep\"" } "breakpoint hit"
51
52# Set a breakpoint in a C++ source file whose name contains a
53# Windows-style logical drive.
54mi_gdb_test \
55    "-break-insert -f \"c:/uu.cpp:13\"" \
56    ".*No source file named c:/uu.cpp.*"
57