-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
An initial pass at tracking backtraces during execution. Currently, only `Arc::new` is tracked, but now that infrastructure is added, tracking additional events should be easier. Capturing a backtrace is a an expensive event. The failure case should be isolated before capturing backtraces.
- Loading branch information
1 parent
a89fef9
commit 977067f
Showing
6 changed files
with
91 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
pub(crate) use cfg::Backtrace; | ||
|
||
#[cfg(feature = "backtrace")] | ||
mod cfg { | ||
use std::fmt; | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct Backtrace(backtrace::Backtrace); | ||
|
||
impl Backtrace { | ||
pub(crate) fn capture() -> Backtrace { | ||
Backtrace(backtrace::Backtrace::new()) | ||
} | ||
} | ||
|
||
impl fmt::Display for Backtrace { | ||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
// TODO: Add some sort of filter to get rid of loom internals | ||
write!(fmt, "{:?}", self.0) | ||
} | ||
} | ||
} | ||
|
||
#[cfg(not(feature = "backtrace"))] | ||
mod cfg { | ||
use std::fmt; | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct Backtrace; | ||
|
||
impl Backtrace { | ||
pub(crate) fn capture() -> Backtrace { | ||
panic!("enable `backtrace` feature flag"); | ||
} | ||
} | ||
|
||
impl fmt::Display for Backtrace { | ||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(fmt, "[enable `backtrace` feature for backtrace capture]") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters