]> git.proxmox.com Git - rustc.git/blame - vendor/backtrace/src/symbolize/dladdr_resolve.rs
New upstream version 1.45.0+dfsg1
[rustc.git] / vendor / backtrace / src / symbolize / dladdr_resolve.rs
CommitLineData
dc9dc135
XL
1// Copyright 2014-2015 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//! Symbolication strategy using `dladdr`
12//!
13//! The `dladdr` API is available on most Unix implementations but it's quite
14//! basic, not handling inline frame information at all. Since it's so prevalent
15//! though we have an option to use it!
16
416331ca
XL
17use crate::symbolize::{dladdr, ResolveWhat, SymbolName};
18use crate::types::BytesOrWideString;
19use core::ffi::c_void;
dc9dc135 20
416331ca 21pub struct Symbol<'a>(dladdr::Symbol<'a>);
dc9dc135 22
416331ca 23impl Symbol<'_> {
dc9dc135
XL
24 pub fn name(&self) -> Option<SymbolName> {
25 self.0.name()
26 }
27
28 pub fn addr(&self) -> Option<*mut c_void> {
29 self.0.addr()
30 }
31
32 pub fn filename_raw(&self) -> Option<BytesOrWideString> {
33 self.0.filename_raw()
34 }
35
36 #[cfg(feature = "std")]
37 pub fn filename(&self) -> Option<&::std::path::Path> {
38 self.0.filename()
39 }
40
41 pub fn lineno(&self) -> Option<u32> {
42 self.0.lineno()
43 }
44}
45
46pub unsafe fn resolve(what: ResolveWhat, cb: &mut FnMut(&super::Symbol)) {
47 dladdr::resolve(what.address_or_ip(), &mut |sym| {
416331ca 48 cb(&super::Symbol { inner: Symbol(sym) })
dc9dc135
XL
49 });
50}