the "ambiguous linespec" series
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.linespec / linespec.exp
CommitLineData
f8eba3c6
TT
1# Copyright 2011 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# Tests of ambiguous linespecs.
17
18set testfile linespec
19
20set exefile lspec
21set binfile ${objdir}/${subdir}/${exefile}
22
23set baseone base/one/thefile.cc
24set basetwo base/two/thefile.cc
25
26if {[skip_cplus_tests]} {
27 unsupported linespec.exp
28 return
29}
30
31if {[prepare_for_testing ${testfile}.exp $exefile \
32 [list lspec.cc $baseone $basetwo] \
33 {debug nowarnings}]} {
34 return -1
35}
36
37gdb_test_no_output "set multiple-symbols all" \
38 "set multiple-symbols to all for linespec tests"
39
40set l1 [gdb_get_line_number "thefile breakpoint" $baseone]
41set l2 [gdb_get_line_number "thefile breakpoint" $basetwo]
42
43if {$l1 != $l2} {
44 error "somebody incompatibly modified the source files needed by linespec.exp"
45}
46
47gdb_test "break thefile.cc:$l1" \
48 "Breakpoint 1 at $hex: thefile.cc:$l1. \[(\]2 locations\[)\]" \
49 "multi-location break using file:line"
50
51# We'd like this to work, but it currently does not.
52# gdb_test "break one/thefile.cc:$l1"
53
54gdb_test "break dupname" \
55 "Breakpoint 2 at $hex: dupname. \[(\]2 locations\[)\]" \
56 "multi-location break using duplicate function name"
57
58gdb_test "break dupname:label" \
59 "Breakpoint 3 at $hex: dupname:label. \[(\]2 locations\[)\]" \
60 "multi-location break using duplicate function name and label"
61
62gdb_test_no_output "set breakpoint pending off" \
63 "disable pending breakpoints for linespec tests"
64
65# This is PR breakpoints/12856.
66gdb_test "break lspec.cc:nosuchfunction" \
67 "Function \"nosuchfunction\" not defined in \"lspec.cc\"." \
68 "set breakpoint on non-existent function"
69
70gdb_test "break NameSpace::overload" \
71 "Breakpoint \[0-9\]+ at $hex: NameSpace::overload. \[(\]3 locations\[)\]" \
72 "set breakpoint at all instances of NameSpace::overload"
73
74gdb_test "break lspec.cc:NameSpace::overload" \
75 "Breakpoint \[0-9\]+ at $hex: file .*lspec.cc, line 7." \
76 "set breakpoint at lspec.cc instance of NameSpace::overload"
77
78gdb_test "break lspec.cc:NameSpace::overload(double)" \
79 "Function \"NameSpace::overload\\(double\\)\" not defined in \"lspec.cc\"." \
80 "set breakpoint at non-existent lspec.cc instance of NameSpace::overload"
81
82gdb_test "break NameSpace::overload()" \
83 "Breakpoint \[0-9\]+ at $hex: file .*lspec.cc, line 7." \
84 "set breakpoint at specific instance of NameSpace::overload"
85
86# This should manage to set a breakpoint even though body.h does not
87# include all of the function in question.
88set line [gdb_get_line_number "body breakpoint no code" body.h]
89gdb_test "break body.h:$line" \
90 "Breakpoint \[0-9\]+.*" \
91 "set breakpoint in body.h"
92
93# This should only have a single location -- in f1.
94set line [gdb_get_line_number "f1 breakpoint" lspec.h]
95gdb_test "break lspec.h:$line" \
96 "Breakpoint \[0-9\]+ at $hex: file .*lspec.h, line $line." \
97 "set breakpoint in f1"
98
99#
100# Multi-inferior tests.
101#
102
103gdb_test "add-inferior" "Added inferior 2" \
104 "add inferior for linespec tests"
105
106gdb_test "inferior 2" "Switching to inferior 2 .*" \
107 "switch to inferior 2 for linespec tests"
108
109# Note that in particular this should not cause errors when re-setting
110# breakpoints.
111gdb_test "file $binfile" \
112 "Reading symbols from .*done." \
113 "set the new inferior file for linespec tests"
114
115gdb_test "break main" \
116 "Breakpoint \[0-9\]+ at $hex: main. .2 locations." \
117 "set breakpoint at main in both inferiors"
This page took 0.027753 seconds and 4 git commands to generate.