Skip to content

Commit c4888e9

Browse files
committed
---
yaml --- r: 10439 b: refs/heads/snap-stage3 c: 07bba39 h: refs/heads/master i: 10437: 39e9ac6 10435: 0028e76 10431: 3a66306 v: v3
1 parent 81af9dc commit c4888e9

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 41df9cbb448ab7b4fd352d64776cdfd02ed83a56
4+
refs/heads/snap-stage3: 07bba397c5b46c96cfb8de23c34b9bae47e07947
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/libcore/stackwalk.rs

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,69 @@
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;
28

39
class frame {
4-
let fp: uintptr_t;
10+
let fp: *word;
511

6-
new(fp: uintptr_t) {
12+
new(fp: *word) {
713
self.fp = fp;
814
}
915
}
1016

1117
fn walk_stack(visit: fn(frame) -> bool) {
18+
19+
#debug("beginning stack walk");
20+
1221
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)
1524
};
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 == 0u {
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+
}
1742
}
1843
}
1944

2045
#[test]
21-
fn test() {
46+
fn test_simple() {
2247
for walk_stack { |frame|
23-
#debug("frame: %x", frame.fp);
24-
// breakpoint();
2548
}
2649
}
2750

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+
2867
fn breakpoint() {
2968
rustrt::rust_dbg_breakpoint()
3069
}

0 commit comments

Comments
 (0)