Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-lang/backtrace-rs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 21d5915bfb78e5764eb602d0902e8ad170d2fecd
Choose a base ref
..
head repository: rust-lang/backtrace-rs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fc334fe41548c4df43c60e41bf4bf82acb4bd0c9
Choose a head ref
Showing with 20 additions and 10 deletions.
  1. +14 −4 crates/without_debuginfo/tests/smoke.rs
  2. +3 −3 src/symbolize/dbghelp.rs
  3. +3 −3 src/symbolize/noop.rs
18 changes: 14 additions & 4 deletions crates/without_debuginfo/tests/smoke.rs
Original file line number Diff line number Diff line change
@@ -2,18 +2,28 @@
fn all_frames_have_symbols() {
println!("{:?}", backtrace::Backtrace::new());

let mut all_have_symbols = true;
let mut missing_symbols = 0;
let mut has_symbols = 0;
backtrace::trace(|frame| {
let mut any = false;
backtrace::resolve_frame(frame, |sym| {
if sym.name().is_some() {
any = true;
}
});
if !any && !frame.ip().is_null() {
all_have_symbols = false;
if any {
has_symbols += 1;
} else if !frame.ip().is_null() {
missing_symbols += 1;
}
true
});
assert!(all_have_symbols);

// FIXME(#346) currently on MinGW we can't symbolize kernel32.dll and other
// system libraries, which means we miss the last few symbols.
if cfg!(windows) && cfg!(target_env = "gnu") {
assert!(missing_symbols < 3 && has_symbols > 5);
} else {
assert_eq!(missing_symbols, 0);
}
}
6 changes: 3 additions & 3 deletions src/symbolize/dbghelp.rs
Original file line number Diff line number Diff line change
@@ -53,15 +53,15 @@ pub struct Symbol<'a> {
}

impl Symbol<'_> {
pub fn name(&self) -> Option<SymbolName> {
pub fn name(&self) -> Option<SymbolName<'_>> {
Some(SymbolName::new(unsafe { &*self.name }))
}

pub fn addr(&self) -> Option<*mut c_void> {
Some(self.addr as *mut _)
}

pub fn filename_raw(&self) -> Option<BytesOrWideString> {
pub fn filename_raw(&self) -> Option<BytesOrWideString<'_>> {
self.filename
.map(|slice| unsafe { BytesOrWideString::Wide(&*slice) })
}
@@ -81,7 +81,7 @@ impl Symbol<'_> {
#[repr(C, align(8))]
struct Aligned8<T>(T);

pub unsafe fn resolve(what: ResolveWhat, cb: &mut dyn FnMut(&super::Symbol)) {
pub unsafe fn resolve(what: ResolveWhat<'_>, cb: &mut dyn FnMut(&super::Symbol)) {
// Ensure this process's symbols are initialized
let dbghelp = match dbghelp::init() {
Ok(dbghelp) => dbghelp,
6 changes: 3 additions & 3 deletions src/symbolize/noop.rs
Original file line number Diff line number Diff line change
@@ -7,22 +7,22 @@ use crate::SymbolName;
use core::ffi::c_void;
use core::marker;

pub unsafe fn resolve(_addr: ResolveWhat, _cb: &mut dyn FnMut(&super::Symbol)) {}
pub unsafe fn resolve(_addr: ResolveWhat<'_>, _cb: &mut dyn FnMut(&super::Symbol)) {}

pub struct Symbol<'a> {
_marker: marker::PhantomData<&'a i32>,
}

impl Symbol<'_> {
pub fn name(&self) -> Option<SymbolName> {
pub fn name(&self) -> Option<SymbolName<'_>> {
None
}

pub fn addr(&self) -> Option<*mut c_void> {
None
}

pub fn filename_raw(&self) -> Option<BytesOrWideString> {
pub fn filename_raw(&self) -> Option<BytesOrWideString<'_>> {
None
}