Sha256: 564d799ce613569b9d8b65ecf027e01719409fcf3d07c9179f3c7935e364bb41

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

#![cfg(all(target_env = "sgx", target_vendor = "fortanix"))]
#![feature(sgx_platform)]

#[cfg(feature = "std")]
#[test]
fn sgx_image_base_with_std() {
    use backtrace::trace;

    let image_base = std::os::fortanix_sgx::mem::image_base();

    let mut frame_ips = Vec::new();
    trace(|frame| {
        frame_ips.push(frame.ip());
        true
    });

    assert!(frame_ips.len() > 0);
    for ip in frame_ips {
        let ip: u64 = ip as _;
        assert!(ip < image_base);
    }
}

#[cfg(not(feature = "std"))]
#[test]
fn sgx_image_base_no_std() {
    use backtrace::trace_unsynchronized;

    fn guess_image_base() -> u64 {
        let mut top_frame_ip = None;
        unsafe {
            trace_unsynchronized(|frame| {
                top_frame_ip = Some(frame.ip());
                false
            });
        }
        top_frame_ip.unwrap() as u64 & 0xFFFFFF000000
    }

    let image_base = guess_image_base();
    backtrace::set_image_base(image_base as _);

    let mut frame_ips = Vec::new();
    unsafe {
        trace_unsynchronized(|frame| {
            frame_ips.push(frame.ip());
            true
        });
    }

    assert!(frame_ips.len() > 0);
    for ip in frame_ips {
        let ip: u64 = ip as _;
        assert!(ip < image_base);
    }
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/backtrace-0.3.74/tests/sgx-image-base.rs
wasmtime-28.0.0 ./ext/cargo-vendor/backtrace-0.3.74/tests/sgx-image-base.rs
wasmtime-27.0.0 ./ext/cargo-vendor/backtrace-0.3.74/tests/sgx-image-base.rs
wasmtime-26.0.0 ./ext/cargo-vendor/backtrace-0.3.74/tests/sgx-image-base.rs
wasmtime-25.0.2 ./ext/cargo-vendor/backtrace-0.3.73/tests/sgx-image-base.rs
wasmtime-25.0.1 ./ext/cargo-vendor/backtrace-0.3.73/tests/sgx-image-base.rs
wasmtime-25.0.0 ./ext/cargo-vendor/backtrace-0.3.73/tests/sgx-image-base.rs
wasmtime-24.0.0 ./ext/cargo-vendor/backtrace-0.3.73/tests/sgx-image-base.rs