Skip to content

Commit 983cc77

Browse files
debuginfo: Add some tests for visibiliy scopes within closures.
1 parent 9c7d9eb commit 983cc77

File tree

4 files changed

+239
-2
lines changed

4 files changed

+239
-2
lines changed

src/librustc/middle/trans/debuginfo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub struct FunctionDebugContext {
128128
}
129129

130130
impl FunctionDebugContext {
131-
priv fn new() -> FunctionDebugContext {
131+
fn new() -> FunctionDebugContext {
132132
return FunctionDebugContext {
133133
scope_map: HashMap::new(),
134134
argument_counter: 1,
@@ -449,7 +449,7 @@ fn declare_local(bcx: @mut Block,
449449
let type_metadata = type_metadata(cx, variable_type, span);
450450
let scope = scope_metadata(bcx.fcx, node_id, span);
451451

452-
let var_metadata = do name.as_c_str |name| {
452+
let var_metadata = do name.to_c_str().with_ref |name| {
453453
unsafe {
454454
llvm::LLVMDIBuilderCreateLocalVariable(
455455
DIB(cx),
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:break zzz
15+
// debugger:run
16+
17+
// debugger:finish
18+
// debugger:print x
19+
// check:$1 = false
20+
// debugger:continue
21+
22+
// debugger:finish
23+
// debugger:print x
24+
// check:$2 = false
25+
// debugger:continue
26+
27+
// debugger:finish
28+
// debugger:print x
29+
// check:$3 = 1000
30+
// debugger:continue
31+
32+
// debugger:finish
33+
// debugger:print x
34+
// check:$4 = 2.5
35+
// debugger:continue
36+
37+
// debugger:finish
38+
// debugger:print x
39+
// check:$5 = true
40+
// debugger:continue
41+
42+
// debugger:finish
43+
// debugger:print x
44+
// check:$6 = false
45+
// debugger:continue
46+
47+
fn main() {
48+
49+
let x = false;
50+
51+
zzz();
52+
sentinel();
53+
54+
let managed_closure: @fn(int) = |x| {
55+
zzz();
56+
sentinel();
57+
58+
let x = 2.5;
59+
60+
zzz();
61+
sentinel();
62+
63+
let x = true;
64+
65+
zzz();
66+
sentinel();
67+
};
68+
69+
zzz();
70+
sentinel();
71+
72+
managed_closure(1000);
73+
74+
zzz();
75+
sentinel();
76+
}
77+
78+
fn zzz() {()}
79+
fn sentinel() {()}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:break zzz
15+
// debugger:run
16+
17+
// debugger:finish
18+
// debugger:print x
19+
// check:$1 = false
20+
// debugger:continue
21+
22+
// debugger:finish
23+
// debugger:print x
24+
// check:$2 = false
25+
// debugger:continue
26+
27+
// debugger:finish
28+
// debugger:print x
29+
// check:$3 = 1000
30+
// debugger:continue
31+
32+
// debugger:finish
33+
// debugger:print x
34+
// check:$4 = 2.5
35+
// debugger:continue
36+
37+
// debugger:finish
38+
// debugger:print x
39+
// check:$5 = true
40+
// debugger:continue
41+
42+
// debugger:finish
43+
// debugger:print x
44+
// check:$6 = false
45+
// debugger:continue
46+
47+
fn main() {
48+
49+
let x = false;
50+
51+
zzz();
52+
sentinel();
53+
54+
let stack_closure: &fn(int) = |x| {
55+
zzz();
56+
sentinel();
57+
58+
let x = 2.5;
59+
60+
zzz();
61+
sentinel();
62+
63+
let x = true;
64+
65+
zzz();
66+
sentinel();
67+
};
68+
69+
zzz();
70+
sentinel();
71+
72+
stack_closure(1000);
73+
74+
zzz();
75+
sentinel();
76+
}
77+
78+
fn zzz() {()}
79+
fn sentinel() {()}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:break zzz
15+
// debugger:run
16+
17+
// debugger:finish
18+
// debugger:print x
19+
// check:$1 = false
20+
// debugger:continue
21+
22+
// debugger:finish
23+
// debugger:print x
24+
// check:$2 = false
25+
// debugger:continue
26+
27+
// debugger:finish
28+
// debugger:print x
29+
// check:$3 = 1000
30+
// debugger:continue
31+
32+
// debugger:finish
33+
// debugger:print x
34+
// check:$4 = 2.5
35+
// debugger:continue
36+
37+
// debugger:finish
38+
// debugger:print x
39+
// check:$5 = true
40+
// debugger:continue
41+
42+
// debugger:finish
43+
// debugger:print x
44+
// check:$6 = false
45+
// debugger:continue
46+
47+
fn main() {
48+
49+
let x = false;
50+
51+
zzz();
52+
sentinel();
53+
54+
let unique_closure: ~fn(int) = |x| {
55+
zzz();
56+
sentinel();
57+
58+
let x = 2.5;
59+
60+
zzz();
61+
sentinel();
62+
63+
let x = true;
64+
65+
zzz();
66+
sentinel();
67+
};
68+
69+
zzz();
70+
sentinel();
71+
72+
unique_closure(1000);
73+
74+
zzz();
75+
sentinel();
76+
}
77+
78+
fn zzz() {()}
79+
fn sentinel() {()}

0 commit comments

Comments
 (0)