about summary refs log tree commit diff
path: root/src/libcore/stackwalk.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-05-10 17:56:02 -0700
committerbors <bors@rust-lang.org>2013-05-10 17:56:02 -0700
commit3e0400fb86170baff30282edcdccff73e243fd6e (patch)
treeec7cc5de5ce7c80845c77fdcbb670cd54c120783 /src/libcore/stackwalk.rs
parentd546493096f35e68cbcd9b5d3d7654e7a9345744 (diff)
parent606bd75586419948f109de313ab37e31397ca7a3 (diff)
downloadrust-3e0400fb86170baff30282edcdccff73e243fd6e.tar.gz
rust-3e0400fb86170baff30282edcdccff73e243fd6e.zip
auto merge of #6223 : alexcrichton/rust/issue-6183, r=pcwalton
Closes #6183.

The first commit changes the compiler's method of treating a `for` loop, and all the remaining commits are just dealing with the fallout.

The biggest fallout was the `IterBytes` trait, although it's really a whole lot nicer now because all of the `iter_bytes_XX` methods are just and-ed together. Sadly there was a huge amount of stuff that's `cfg(stage0)` gated, but whoever lands the next snapshot is going to have a lot of fun deleting all this code!

Diffstat (limited to 'src/libcore/stackwalk.rs')
-rw-r--r--src/libcore/stackwalk.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs
index 1958b5b9d80..e86416f2499 100644
--- a/src/libcore/stackwalk.rs
+++ b/src/libcore/stackwalk.rs
@@ -24,6 +24,7 @@ pub fn Frame(fp: *Word) -> Frame {
     }
 }
 
+#[cfg(stage0)]
 pub fn walk_stack(visit: &fn(Frame) -> bool) {
 
     debug!("beginning stack walk");
@@ -51,6 +52,35 @@ pub fn walk_stack(visit: &fn(Frame) -> bool) {
         }
     }
 }
+#[cfg(not(stage0))]
+pub fn walk_stack(visit: &fn(Frame) -> bool) -> bool {
+
+    debug!("beginning stack walk");
+
+    do frame_address |frame_pointer| {
+        let mut frame_address: *Word = unsafe {
+            transmute(frame_pointer)
+        };
+        loop {
+            let fr = Frame(frame_address);
+
+            debug!("frame: %x", unsafe { transmute(fr.fp) });
+            visit(fr);
+
+            unsafe {
+                let next_fp: **Word = transmute(frame_address);
+                frame_address = *next_fp;
+                if *frame_address == 0u {
+                    debug!("encountered task_start_wrapper. ending walk");
+                    // This is the task_start_wrapper_frame. There is
+                    // no stack beneath it and it is a foreign frame.
+                    break;
+                }
+            }
+        }
+    }
+    return true;
+}
 
 #[test]
 fn test_simple() {