File tree Expand file tree Collapse file tree 2 files changed +49
-10
lines changed
branches/snap-stage3/src/libcore Expand file tree Collapse file tree 2 files changed +49
-10
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
- refs/heads/snap-stage3: 41df9cbb448ab7b4fd352d64776cdfd02ed83a56
4
+ refs/heads/snap-stage3: 07bba397c5b46c96cfb8de23c34b9bae47e07947
5
5
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
Original file line number Diff line number Diff line change 1
- import libc:: uintptr_t;
1
+ // NB: Don't rely on other core mods here as this has to move into the rt
2
+
3
+ import unsafe:: reinterpret_cast;
4
+ import ptr:: offset;
5
+ import sys:: size_of;
6
+
7
+ type word = uint ;
2
8
3
9
class frame {
4
- let fp: uintptr_t ;
10
+ let fp: * word ;
5
11
6
- new ( fp: uintptr_t ) {
12
+ new ( fp: * word ) {
7
13
self . fp = fp;
8
14
}
9
15
}
10
16
11
17
fn walk_stack ( visit : fn ( frame ) -> bool ) {
18
+
19
+ #debug ( "beginning stack walk" ) ;
20
+
12
21
frame_address { |frame_pointer|
13
- let frame_address = unsafe {
14
- unsafe :: reinterpret_cast ( frame_pointer)
22
+ let mut frame_address: * word = unsafe {
23
+ reinterpret_cast ( frame_pointer)
15
24
} ;
16
- visit ( frame ( frame_address) ) ;
25
+ loop {
26
+ let frame = frame ( frame_address) ;
27
+
28
+ #debug ( "frame: %x" , unsafe { reinterpret_cast ( frame. fp ) } ) ;
29
+ visit ( frame) ;
30
+
31
+ unsafe {
32
+ let next_fp: * * word = reinterpret_cast ( frame_address) ;
33
+ frame_address = * next_fp;
34
+ if * frame_address == 0 u {
35
+ #debug ( "encountered task_start_wrapper. ending walk" ) ;
36
+ // This is the task_start_wrapper_frame. There is
37
+ // no stack beneath it and it is a native frame.
38
+ break ;
39
+ }
40
+ }
41
+ }
17
42
}
18
43
}
19
44
20
45
#[ test]
21
- fn test ( ) {
46
+ fn test_simple ( ) {
22
47
for walk_stack { |frame|
23
- #debug( "frame: %x" , frame. fp) ;
24
- // breakpoint();
25
48
}
26
49
}
27
50
51
+ #[ test]
52
+ fn test_simple_deep ( ) {
53
+ fn run ( i : int ) {
54
+ if i == 0 { ret }
55
+
56
+ for walk_stack { |frame|
57
+ unsafe {
58
+ breakpoint( ) ;
59
+ }
60
+ }
61
+ run ( i - 1 ) ;
62
+ }
63
+
64
+ run ( 10 ) ;
65
+ }
66
+
28
67
fn breakpoint ( ) {
29
68
rustrt:: rust_dbg_breakpoint ( )
30
69
}
You can’t perform that action at this time.
0 commit comments