1use core::ffi::c_void;
2use core::marker::PhantomData;
3
4use super::super::backtrace::miri::{resolve_addr, Frame};
5use super::BytesOrWideString;
6use super::{ResolveWhat, SymbolName};
7
8pub unsafe fn resolve(what: ResolveWhat<'_>, cb: &mut dyn FnMut(&super::Symbol)) {
9 let sym: Symbol<'_> = match what {
10 ResolveWhat::Address(addr: *mut c_void) => Symbol {
11 inner: resolve_addr(ptr:addr),
12 _unused: PhantomData,
13 },
14 ResolveWhat::Frame(frame: &Frame) => Symbol {
15 inner: frame.inner.clone(),
16 _unused: PhantomData,
17 },
18 };
19 cb(&super::Symbol { inner: sym })
20}
21
22pub struct Symbol<'a> {
23 inner: Frame,
24 _unused: PhantomData<&'a ()>,
25}
26
27impl<'a> Symbol<'a> {
28 pub fn name(&self) -> Option<SymbolName<'_>> {
29 Some(SymbolName::new(&self.inner.inner.name))
30 }
31
32 pub fn addr(&self) -> Option<*mut c_void> {
33 Some(self.inner.addr)
34 }
35
36 pub fn filename_raw(&self) -> Option<BytesOrWideString<'_>> {
37 Some(BytesOrWideString::Bytes(&self.inner.inner.filename))
38 }
39
40 pub fn lineno(&self) -> Option<u32> {
41 Some(self.inner.inner.lineno)
42 }
43
44 pub fn colno(&self) -> Option<u32> {
45 Some(self.inner.inner.colno)
46 }
47
48 #[cfg(feature = "std")]
49 pub fn filename(&self) -> Option<&std::path::Path> {
50 Some(std::path::Path::new(
51 core::str::from_utf8(&self.inner.inner.filename).unwrap(),
52 ))
53 }
54}
55
56pub unsafe fn clear_symbol_cache() {}
57