diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-08-06 16:18:58 -0700 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-08-06 16:18:58 -0700 |
| commit | 8567611adfa69c4488133e18d3ec4fc195afadd1 (patch) | |
| tree | 80e325db23f407d643e2ada480de23b1fb8b4fc6 /src/libstd/stackwalk.rs | |
| parent | fb9b27910b41e714dfd6b3ccc48161260943c9cf (diff) | |
| parent | d89ff7eef969aee6b493bc846b64d68358fafbcd (diff) | |
| download | rust-8567611adfa69c4488133e18d3ec4fc195afadd1.tar.gz rust-8567611adfa69c4488133e18d3ec4fc195afadd1.zip | |
Merge commit 'd89ff7eef969aee6b493bc846b64d68358fafbcd' into remove-str-trailing-nulls
Diffstat (limited to 'src/libstd/stackwalk.rs')
| -rw-r--r-- | src/libstd/stackwalk.rs | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/src/libstd/stackwalk.rs b/src/libstd/stackwalk.rs deleted file mode 100644 index cc516fb559e..00000000000 --- a/src/libstd/stackwalk.rs +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[allow(missing_doc)]; - -use cast::transmute; -use unstable::intrinsics; - -pub type Word = uint; - -pub struct Frame { - fp: *Word -} - -pub fn Frame(fp: *Word) -> Frame { - Frame { - fp: fp - } -} - -pub fn walk_stack(visit: &fn(Frame)) { - - 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; - } - } - } - } -} - -#[test] -fn test_simple() { - do walk_stack |_frame| { - } -} - -#[test] -fn test_simple_deep() { - fn run(i: int) { - if i == 0 { return } - - do walk_stack |_frame| { - // Would be nice to test something here... - } - run(i - 1); - } - - run(10); -} - -fn frame_address(f: &fn(x: *u8)) { - unsafe { - intrinsics::frame_address(f) - } -} |
