Skip to content

Commit 02a0f28

Browse files
debuginfo: Support for destructured function arguments.
1 parent c9e51ce commit 02a0f28

File tree

4 files changed

+429
-7
lines changed

4 files changed

+429
-7
lines changed

src/librustc/middle/trans/debuginfo.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,16 @@ pub fn create_argument_metadata(bcx: @mut Block, arg: &ast::arg, span: span) {
200200
let fcx = bcx.fcx;
201201
let cx = fcx.ccx;
202202

203-
if fcx.span.is_none() {
204-
return;
205-
}
206-
207-
if "<intrinsic>" == span_start(cx, span).file.name {
203+
if fcx.id == -1 ||
204+
fcx.span.is_none() ||
205+
"<intrinsic>" == span_start(cx, span).file.name {
208206
return;
209207
}
210208

211209
let def_map = cx.tcx.def_map;
212210
let pattern = arg.pat;
213211

214-
let mut argument_index = match dbg_cx(cx).argument_index_counters.find_copy(&arg.id) {
212+
let mut argument_index = match dbg_cx(cx).argument_index_counters.find_copy(&fcx.id) {
215213
Some(value) => value,
216214
None => 0
217215
};
@@ -266,7 +264,7 @@ pub fn create_argument_metadata(bcx: @mut Block, arg: &ast::arg, span: span) {
266264
}
267265
}
268266

269-
dbg_cx(cx).argument_index_counters.insert(arg.id, argument_index);
267+
dbg_cx(cx).argument_index_counters.insert(fcx.id, argument_index);
270268
}
271269

272270
/// Sets the current debug location at the beginning of the span
Lines changed: 316 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,316 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags:-Z extra-debug-info
12+
// debugger:break zzz
13+
// debugger:run
14+
15+
// debugger:finish
16+
// debugger:print a
17+
// check:$1 = 1
18+
// debugger:print b
19+
// check:$2 = false
20+
// debugger:continue
21+
22+
// debugger:finish
23+
// debugger:print a
24+
// check:$3 = 2
25+
// debugger:print b
26+
// check:$4 = 3
27+
// debugger:print c
28+
// check:$5 = 4
29+
// debugger:continue
30+
31+
// debugger:finish
32+
// debugger:print a
33+
// check:$6 = 5
34+
// debugger:print b
35+
// check:$7 = {6, 7}
36+
// debugger:continue
37+
38+
// debugger:finish
39+
// debugger:print h
40+
// check:$8 = 8
41+
// debugger:print i
42+
// check:$9 = {a = 9, b = 10}
43+
// debugger:print j
44+
// check:$10 = 11
45+
// debugger:continue
46+
47+
// debugger:finish
48+
// debugger:print k
49+
// check:$11 = 12
50+
// debugger:print l
51+
// check:$12 = 13
52+
// debugger:continue
53+
54+
// debugger:finish
55+
// debugger:print m
56+
// check:$13 = 14
57+
// debugger:print n
58+
// check:$14 = 16
59+
// debugger:continue
60+
61+
// debugger:finish
62+
// debugger:print o
63+
// check:$15 = 18
64+
// debugger:continue
65+
66+
// debugger:finish
67+
// debugger:print p
68+
// check:$16 = 19
69+
// debugger:print q
70+
// check:$17 = 20
71+
// debugger:print r
72+
// check:$18 = {a = 21, b = 22}
73+
// debugger:continue
74+
75+
// debugger:finish
76+
// debugger:print s
77+
// check:$19 = 24
78+
// debugger:print t
79+
// check:$20 = 23
80+
// debugger:continue
81+
82+
// debugger:finish
83+
// debugger:print u
84+
// check:$21 = 25
85+
// debugger:print v
86+
// check:$22 = 26
87+
// debugger:print w
88+
// check:$23 = 27
89+
// debugger:print x
90+
// check:$24 = 28
91+
// debugger:print y
92+
// check:$25 = 29
93+
// debugger:print z
94+
// check:$26 = 30
95+
// debugger:print ae
96+
// check:$27 = 31
97+
// debugger:print oe
98+
// check:$28 = 32
99+
// debugger:print ue
100+
// check:$29 = 33
101+
// debugger:continue
102+
103+
// debugger:finish
104+
// debugger:print aa
105+
// check:$30 = {34, 35}
106+
// debugger:continue
107+
108+
// debugger:finish
109+
// debugger:print bb
110+
// check:$31 = {36, 37}
111+
// debugger:continue
112+
113+
// debugger:finish
114+
// debugger:print cc
115+
// check:$32 = 38
116+
// debugger:continue
117+
118+
// debugger:finish
119+
// debugger:print dd
120+
// check:$33 = {40, 41, 42}
121+
// debugger:continue
122+
123+
// debugger:finish
124+
// debugger:print *ee
125+
// check:$34 = {43, 44, 45}
126+
// debugger:continue
127+
128+
// debugger:finish
129+
// debugger:print *ff
130+
// check:$35 = 46
131+
// debugger:print gg
132+
// check:$36 = {47, 48}
133+
// debugger:continue
134+
135+
// debugger:finish
136+
// debugger:print *hh
137+
// check:$37 = 50
138+
// debugger:continue
139+
140+
// debugger:finish
141+
// debugger:print ii
142+
// check:$38 = 51
143+
// debugger:continue
144+
145+
// debugger:finish
146+
// debugger:print *jj
147+
// check:$39 = 52
148+
// debugger:continue
149+
150+
// debugger:finish
151+
// debugger:print kk
152+
// check:$40 = 53
153+
// debugger:print ll
154+
// check:$41 = 54
155+
// debugger:continue
156+
157+
// debugger:finish
158+
// debugger:print mm
159+
// check:$42 = 55
160+
// debugger:print *nn
161+
// check:$43 = 56
162+
// debugger:continue
163+
164+
// debugger:finish
165+
// debugger:print oo
166+
// check:$44 = 57
167+
// debugger:print pp
168+
// check:$45 = 58
169+
// debugger:print qq
170+
// check:$46 = 59
171+
// debugger:continue
172+
173+
// debugger:finish
174+
// debugger:print rr
175+
// check:$47 = 60
176+
// debugger:print ss
177+
// check:$48 = 61
178+
// debugger:print tt
179+
// check:$49 = 62
180+
// debugger:continue
181+
182+
183+
struct Struct {
184+
a: i64,
185+
b: i32
186+
}
187+
188+
enum Univariant {
189+
Unit(i32)
190+
}
191+
192+
struct TupleStruct (float, int);
193+
194+
195+
fn simple_tuple((a, b): (int, bool)) {
196+
zzz();
197+
}
198+
199+
fn nested_tuple((a, (b, c)): (int, (u16, u16))) {
200+
zzz();
201+
}
202+
203+
fn destructure_only_first_level((a, b): (int, (u32, u32))) {
204+
zzz();
205+
}
206+
207+
fn struct_as_tuple_element((h, i, j): (i16, Struct, i16)) {
208+
zzz();
209+
}
210+
211+
fn struct_pattern(Struct { a: k, b: l }: Struct) {
212+
zzz();
213+
}
214+
215+
fn ignored_tuple_element((m, _, n): (int, u16, i32)) {
216+
zzz();
217+
}
218+
219+
fn ignored_struct_field(Struct { b: o, _ }: Struct) {
220+
zzz();
221+
}
222+
223+
fn one_struct_destructured_one_not((Struct { a: p, b: q }, r): (Struct, Struct)) {
224+
zzz();
225+
}
226+
227+
fn different_order_of_struct_fields(Struct { b: s, a: t }: Struct ) {
228+
zzz();
229+
}
230+
231+
fn complex_nesting(((u, v ), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue ):
232+
((i16, i32), ((i64, (i32, Struct, )), Struct ), u16)) {
233+
zzz();
234+
}
235+
236+
fn managed_box(@aa: @(int, int)) {
237+
zzz();
238+
}
239+
240+
fn borrowed_pointer(&bb: &(int, int)) {
241+
zzz();
242+
}
243+
244+
fn contained_borrowed_pointer((&cc, _): (&int, int)) {
245+
zzz();
246+
}
247+
248+
fn unique_pointer(~dd: ~(int, int, int)) {
249+
zzz();
250+
}
251+
252+
fn ref_binding(ref ee: (int, int, int)) {
253+
zzz();
254+
}
255+
256+
fn ref_binding_in_tuple((ref ff, gg): (int, (int, int))) {
257+
zzz();
258+
}
259+
260+
fn ref_binding_in_struct(Struct { b: ref hh, _ }: Struct) {
261+
zzz();
262+
}
263+
264+
fn univariant_enum(Unit(ii): Univariant) {
265+
zzz();
266+
}
267+
268+
fn univariant_enum_with_ref_binding(Unit(ref jj): Univariant) {
269+
zzz();
270+
}
271+
272+
fn tuple_struct(TupleStruct(kk, ll): TupleStruct) {
273+
zzz();
274+
}
275+
276+
fn tuple_struct_with_ref_binding(TupleStruct(mm, ref nn): TupleStruct) {
277+
zzz();
278+
}
279+
280+
fn multiple_arguments((oo, pp): (int, int), qq : int) {
281+
zzz();
282+
}
283+
284+
fn main() {
285+
simple_tuple((1, false));
286+
nested_tuple((2, (3, 4)));
287+
destructure_only_first_level((5, (6, 7)));
288+
struct_as_tuple_element((8, Struct { a: 9, b: 10 }, 11));
289+
struct_pattern(Struct { a: 12, b: 13 });
290+
ignored_tuple_element((14, 15, 16));
291+
ignored_struct_field(Struct { a: 17, b: 18 });
292+
one_struct_destructured_one_not((Struct { a: 19, b: 20 }, Struct { a: 21, b: 22 }));
293+
different_order_of_struct_fields(Struct { a: 23, b: 24 });
294+
complex_nesting(((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33));
295+
managed_box(@(34, 35));
296+
borrowed_pointer(&(36, 37));
297+
contained_borrowed_pointer((&38, 39));
298+
unique_pointer(~(40, 41, 42));
299+
ref_binding((43, 44, 45));
300+
ref_binding_in_tuple((46, (47, 48)));
301+
ref_binding_in_struct(Struct { a: 49, b: 50 });
302+
univariant_enum(Unit(51));
303+
univariant_enum_with_ref_binding(Unit(52));
304+
tuple_struct(TupleStruct(53.0, 54));
305+
tuple_struct_with_ref_binding(TupleStruct(55.0, 56));
306+
multiple_arguments((57, 58), 59);
307+
308+
fn nested_function(rr: int, (ss, tt): (int, int)) {
309+
zzz();
310+
}
311+
312+
nested_function(60, (61, 62));
313+
}
314+
315+
316+
fn zzz() {()}

0 commit comments

Comments
 (0)