Commit | Line | Data |
---|---|---|
61baf725 | 1 | # Copyright 2012-2017 Free Software Foundation, Inc. |
481860b3 GB |
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 | # Note that the testcase gdb.dwarf2/dw2-inline-break.exp largely | |
17 | # mirrors this testcase, and should be updated if this testcase is | |
18 | # changed. | |
19 | ||
efc9d70a | 20 | standard_testfile |
481860b3 | 21 | |
5b362f04 | 22 | if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ |
1f960ced | 23 | {debug additional_flags=-Winline}] } { |
481860b3 GB |
24 | return -1 |
25 | } | |
26 | ||
4a27f119 KS |
27 | # Return a string that may be used to match the output of "info break NUM". |
28 | # | |
29 | # Optional arguments: | |
30 | # | |
31 | # source - the name of the source file | |
32 | # func - the name of the function | |
33 | # disp - the event disposition | |
34 | # enabled - enable state | |
35 | # locs - number of locations | |
36 | # line - source line number (ignored without -source) | |
37 | ||
38 | proc break_info_1 {num args} { | |
39 | global decimal | |
40 | ||
41 | # Column delimiter | |
42 | set c {[\t ]+} | |
43 | ||
44 | # Row delimiter | |
45 | set end {[\r\n \t]+} | |
46 | ||
47 | # Table header | |
48 | set header "[join [list Num Type Disp Enb Address What] ${c}]" | |
49 | ||
50 | # Get/configure any optional parameters. | |
51 | parse_args [list {source ""} {func ".*"} {disp "keep"} \ | |
52 | {enabled "y"} {locs 1} [list line $decimal] \ | |
53 | {type "breakpoint"}] | |
54 | ||
55 | if {$source != ""} { | |
56 | set source "$source:$line" | |
57 | } | |
58 | ||
59 | # Result starts with the standard header. | |
60 | set result "$header${end}" | |
61 | ||
62 | # Set up for multi-location breakpoint marker. | |
63 | if {$locs == 1} { | |
64 | set multi ".*" | |
65 | } else { | |
66 | set multi "<MULTIPLE>${end}" | |
67 | } | |
68 | append result "[join [list $num $type $disp $enabled $multi] $c]" | |
69 | ||
70 | # Add location info. | |
71 | for {set i 1} {$i <= $locs} {incr i} { | |
72 | if {$locs > 1} { | |
73 | append result "[join [list $num.$i $enabled] $c].*" | |
74 | } | |
75 | ||
76 | # Add function/source file info. | |
77 | append result "in $func at .*$source${end}" | |
78 | } | |
79 | ||
80 | return $result | |
81 | } | |
82 | ||
481860b3 GB |
83 | # |
84 | # func1 is a static inlined function that is called once. | |
85 | # The result should be a single-location breakpoint. | |
86 | # | |
87 | gdb_test "break func1" \ | |
efc9d70a | 88 | "Breakpoint.*at.* file .*$srcfile, line.*" |
481860b3 GB |
89 | |
90 | # | |
91 | # func2 is a non-static inlined function that is called once. | |
92 | # The result should be a breakpoint with two locations: the | |
93 | # out-of-line function and the single inlined instance. | |
94 | # | |
95 | gdb_test "break func2" \ | |
96 | "Breakpoint.*at.*func2.*\\(2 locations\\)" | |
97 | ||
98 | # | |
99 | # func3b is a static inlined function that is called once from | |
100 | # within another static inlined function. The result should be | |
101 | # a single-location breakpoint. | |
102 | # | |
103 | gdb_test "break func3b" \ | |
efc9d70a | 104 | "Breakpoint.*at.* file .*$srcfile, line.*" |
481860b3 GB |
105 | |
106 | # | |
107 | # func4b is a static inlined function that is called once from | |
108 | # within a non-static inlined function. The result should be | |
109 | # a breakpoint with two locations: the inlined instance within | |
110 | # the inlined call to func4a in main, and the inlined instance | |
111 | # within the out-of-line func4a. | |
112 | # | |
113 | gdb_test "break func4b" \ | |
114 | "Breakpoint.*at.*func4b.*\\(2 locations\\)" | |
115 | ||
116 | # | |
117 | # func5b is a non-static inlined function that is called once | |
118 | # from within a static inlined function. The result should be a | |
119 | # breakpoint with two locations: the out-of-line function and the | |
120 | # inlined instance within the inlined call to func5a in main. | |
121 | # | |
122 | gdb_test "break func5b" \ | |
123 | "Breakpoint.*at.*func5b.*\\(2 locations\\)" | |
124 | # | |
125 | # func6b is a non-static inlined function that is called once from | |
126 | # within another non-static inlined function. The result should be | |
127 | # a breakpoint with three locations: the out-of-line function, the | |
128 | # inlined instance within the out-of-line func6a, and the inlined | |
129 | # instance within the inlined call to func6a in main, | |
130 | # | |
131 | gdb_test "break func6b" \ | |
132 | "Breakpoint.*at.*func6b.*\\(3 locations\\)" | |
133 | ||
134 | # | |
135 | # func7b is a static inlined function that is called twice: once from | |
136 | # func7a, and once from main. The result should be a breakpoint with | |
137 | # two locations: the inlined instance within the inlined instance of | |
138 | # func7a, and the inlined instance within main. | |
139 | # | |
140 | gdb_test "break func7b" \ | |
141 | "Breakpoint.*at.*func7b.*\\(2 locations\\)" | |
142 | ||
143 | # | |
144 | # func8b is a non-static inlined function that is called twice: once | |
145 | # func8a, and once from main. The result should be a breakpoint with | |
146 | # three locations: the out-of-line function, the inlined instance | |
147 | # within the inlined instance of func7a, and the inlined instance | |
148 | # within main. | |
149 | # | |
150 | gdb_test "break func8b" \ | |
151 | "Breakpoint.*at.*func8b.*\\(3 locations\\)" | |
152 | ||
153 | # | |
154 | # func1 is a static inlined function. The result should be that no | |
155 | # symbol is found to print. | |
156 | # | |
157 | gdb_test "print func1" \ | |
158 | "No symbol \"func1\" in current context." | |
159 | ||
160 | # | |
161 | # func2 is a non-static inlined function. The result should be that | |
162 | # one symbol is found to print, and that the printed symbol is called | |
163 | # "func2". Note that this does not cover the failure case that two | |
164 | # symbols were found, but that gdb chose the out-of-line copy to | |
165 | # print, but if this was failing the "print func1" test would likely | |
166 | # fail instead. | |
167 | # | |
168 | gdb_test "print func2" \ | |
169 | "\\\$.* = {int \\(int\\)} .* <func2>" | |
4a27f119 KS |
170 | |
171 | # Test that "info break" reports the location of the breakpoints "inside" | |
172 | # the inlined functions | |
173 | ||
174 | set results(1) [break_info_1 1 -source $srcfile -func "func1"] | |
175 | set results(2) [break_info_1 2 -locs 2 -source $srcfile -func "func2"] | |
176 | set results(3) [break_info_1 3 -source $srcfile -func "func3b"] | |
177 | set results(4) [break_info_1 4 -locs 2 -source $srcfile -func "func4b"] | |
178 | set results(5) [break_info_1 5 -locs 2 -source $srcfile -func "func5b"] | |
179 | set results(6) [break_info_1 6 -locs 3 -source $srcfile -func "func6b"] | |
180 | set results(7) [break_info_1 7 -locs 2 -source $srcfile -func "func7b"] | |
181 | set results(8) [break_info_1 8 -locs 3 -source $srcfile -func "func8b"] | |
182 | ||
183 | for {set i 1} {$i <= [array size results]} {incr i} { | |
184 | send_log "Expecting: $results($i)\n" | |
185 | gdb_test "info break $i" $results($i) | |
186 | } | |
187 | ||
188 | unset -nocomplain results |