aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.linespec/linespec.exp
blob: 0b703466d0e4d6238832caffd415300143637626 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Copyright 2011-2013 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Tests of ambiguous linespecs.

standard_testfile lspec.cc

set exefile $testfile

set baseone base/one/thefile.cc
set basetwo base/two/thefile.cc

if {[skip_cplus_tests]} {
    unsupported linespec.exp
    return
}

if {[prepare_for_testing ${testfile}.exp $exefile \
	 [list $srcfile $baseone $basetwo] \
	 {debug nowarnings c++}]} {
    return -1
}

gdb_test_no_output "set multiple-symbols all" \
    "set multiple-symbols to all for linespec tests"

set l1 [gdb_get_line_number "thefile breakpoint" $baseone]
set l2 [gdb_get_line_number "thefile breakpoint" $basetwo]

if {$l1 != $l2} {
    error "somebody incompatibly modified the source files needed by linespec.exp"
}

gdb_test "break one/thefile.cc:$l1" \
    "Breakpoint $decimal at $hex: file .*thefile.cc, line $l1." \
    "single-location break using dir/file:line"

gdb_test "clear one/thefile.cc:$l1" \
    "Deleted breakpoint $decimal *" \
    "clear breakpoint using dir/file:line"

gdb_test "break thefile.cc:$l1" \
    "Breakpoint $decimal at $hex: thefile.cc:$l1. \[(\]2 locations\[)\]" \
    "multi-location break using file:line"

gdb_test "break dupname" \
    "Breakpoint $decimal at $hex: dupname. \[(\]2 locations\[)\]" \
    "multi-location break using duplicate function name"

gdb_test "break dupname:label" \
    "Breakpoint $decimal at $hex: dupname:label. \[(\]2 locations\[)\]" \
    "multi-location break using duplicate function name and label"

gdb_test_no_output "set breakpoint pending off" \
    "disable pending breakpoints for linespec tests"

# This is PR breakpoints/12856.
gdb_test "break lspec.cc:nosuchfunction" \
    "Function \"nosuchfunction\" not defined in \"lspec.cc\"." \
    "set breakpoint on non-existent function"

gdb_test "break NameSpace::overload" \
    "Breakpoint \[0-9\]+ at $hex: NameSpace::overload. \[(\]3 locations\[)\]" \
    "set breakpoint at all instances of NameSpace::overload"

gdb_test "break lspec.cc:NameSpace::overload" \
    "Breakpoint \[0-9\]+ at $hex: file .*lspec.cc, line 7." \
    "set breakpoint at lspec.cc instance of NameSpace::overload"

gdb_test "break lspec.cc:NameSpace::overload(double)" \
    "Function \"NameSpace::overload\\(double\\)\" not defined in \"lspec.cc\"." \
    "set breakpoint at non-existent lspec.cc instance of NameSpace::overload"

gdb_test "break NameSpace::overload()" \
    "Breakpoint \[0-9\]+ at $hex: file .*lspec.cc, line 7." \
    "set breakpoint at specific instance of NameSpace::overload"

# This should manage to set a breakpoint even though body.h does not
# include all of the function in question.
set line [gdb_get_line_number "body breakpoint no code" body.h]
gdb_test "break body.h:$line" \
    "Breakpoint \[0-9\]+.*" \
    "set breakpoint in body.h"

# This should only have a single location -- in f1.
set line [gdb_get_line_number "f1 breakpoint" lspec.h]
gdb_test "break lspec.h:$line" \
    "Breakpoint \[0-9\]+ at $hex: file .*lspec.h, line $line." \
    "set breakpoint in f1"

#
# Multi-inferior tests.
#

gdb_test "add-inferior" "Added inferior 2" \
    "add inferior for linespec tests"

gdb_test "inferior 2" "Switching to inferior 2 .*" \
    "switch to inferior 2 for linespec tests"

# Note that in particular this should not cause errors when re-setting
# breakpoints.
gdb_test "file $binfile" \
    "Reading symbols from .*done." \
    "set the new inferior file for linespec tests"

gdb_test "break main" \
    "Breakpoint \[0-9\]+ at $hex: main. .2 locations." \
    "set breakpoint at main in both inferiors"