]> git.proxmox.com Git - rustc.git/blob - src/libstd/sys/unix/backtrace/printing/mod.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / libstd / sys / unix / backtrace / printing / mod.rs
1 // Copyright 2014-2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 mod dladdr;
12
13 use sys::backtrace::BacktraceContext;
14 use sys_common::backtrace::Frame;
15 use io;
16
17 #[cfg(target_os = "emscripten")]
18 pub use self::dladdr::resolve_symname;
19
20 #[cfg(target_os = "emscripten")]
21 pub fn foreach_symbol_fileline<F>(_: Frame, _: F, _: &BacktraceContext) -> io::Result<bool>
22 where
23 F: FnMut(&[u8], u32) -> io::Result<()>
24 {
25 Ok(false)
26 }
27
28 #[cfg(not(target_os = "emscripten"))]
29 pub use sys_common::gnu::libbacktrace::foreach_symbol_fileline;
30
31 #[cfg(not(target_os = "emscripten"))]
32 pub fn resolve_symname<F>(frame: Frame, callback: F, bc: &BacktraceContext) -> io::Result<()>
33 where
34 F: FnOnce(Option<&str>) -> io::Result<()>
35 {
36 ::sys_common::gnu::libbacktrace::resolve_symname(frame, |symname| {
37 if symname.is_some() {
38 callback(symname)
39 } else {
40 dladdr::resolve_symname(frame, callback, bc)
41 }
42 }, bc)
43 }