Skip to content

Commit

Permalink
Fix miri imports for inclusion in libstd
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Oct 10, 2020
1 parent 8eee2e4 commit f6a691f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/backtrace/miri.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::boxed::Box;
use std::ffi::c_void;
use alloc::boxed::Box;
use core::ffi::c_void;

extern "Rust" {
fn miri_get_backtrace(flags: u64) -> Box<[*mut ()]>;
Expand Down Expand Up @@ -32,7 +32,7 @@ impl Frame {
}

pub fn sp(&self) -> *mut c_void {
std::ptr::null_mut()
core::ptr::null_mut()
}

pub fn symbol_address(&self) -> *mut c_void {
Expand Down
20 changes: 14 additions & 6 deletions src/symbolize/miri.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
use core::ffi::c_void;
use core::marker::PhantomData;

use crate::backtrace::miri::{resolve_addr, Frame};
use crate::symbolize::{ResolveWhat, SymbolName};
use crate::types::BytesOrWideString;
use super::super::backtrace::miri::{resolve_addr, Frame};
use super::BytesOrWideString;
use super::{ResolveWhat, SymbolName};

#[cfg(backtrace_in_libstd)]
mod mystd {
pub use crate::*;
}
#[cfg(not(backtrace_in_libstd))]
extern crate std as mystd;

use mystd::path::Path;

pub unsafe fn resolve(what: ResolveWhat<'_>, cb: &mut dyn FnMut(&super::Symbol)) {
let sym = match what {
Expand Down Expand Up @@ -45,10 +54,9 @@ impl<'a> Symbol<'a> {
Some(self.inner.inner.colno)
}

pub fn filename(&self) -> Option<&::std::path::Path> {
use std::path::Path;
pub fn filename(&self) -> Option<&Path> {
Some(Path::new(
std::str::from_utf8(&self.inner.inner.filename).unwrap(),
core::str::from_utf8(&self.inner.inner.filename).unwrap(),
))
}
}

0 comments on commit f6a691f

Please sign in to comment.