Get vaguely working with a test for checking output
This commit is contained in:
parent
b637c0e84a
commit
49204563e1
1 changed files with 26 additions and 1 deletions
|
@ -152,7 +152,6 @@ struct BacktraceFrame {
|
|||
symbols: Vec<BacktraceSymbol>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct BacktraceSymbol {
|
||||
name: Option<Vec<u8>>,
|
||||
filename: Option<BytesOrWide>,
|
||||
|
@ -164,6 +163,16 @@ enum BytesOrWide {
|
|||
Wide(Vec<u16>),
|
||||
}
|
||||
|
||||
impl fmt::Debug for BacktraceSymbol {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("BacktraceSymbol")
|
||||
.field("name", &self.name.as_ref().map(|b| backtrace::SymbolName::new(b)))
|
||||
.field("filename", &self.filename)
|
||||
.field("lineno", &self.lineno)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for BytesOrWide {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
output_filename(
|
||||
|
@ -364,3 +373,19 @@ impl Capture {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn debug_backtrace_fmt() {
|
||||
let bt = Backtrace::capture();
|
||||
eprintln!("uncaptured: {:?}", bt);
|
||||
let bt = Backtrace::force_capture();
|
||||
eprintln!("captured: {:?}", bt);
|
||||
eprintln!("display print: {}", bt);
|
||||
eprintln!("resolved: {:?}", bt);
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue