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