Skip to content

Commit 230ed3e

Browse files
committed
use debug_map and skip empty frames
1 parent 70c9133 commit 230ed3e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/libstd/backtrace.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ impl fmt::Debug for Backtrace {
173173
let mut dbg = fmt.debug_list();
174174

175175
for frame in &capture.frames {
176+
if frame.frame.ip().is_null() {
177+
continue;
178+
}
179+
176180
dbg.entries(&frame.symbols);
177181
}
178182

@@ -182,20 +186,20 @@ impl fmt::Debug for Backtrace {
182186

183187
impl fmt::Debug for BacktraceSymbol {
184188
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
185-
let mut dbg = fmt.debug_struct("");
189+
let mut dbg = fmt.debug_map();
186190

187191
if let Some(fn_name) = self.name.as_ref().map(|b| backtrace::SymbolName::new(b)) {
188-
dbg.field("fn", &format_args!("\"{}\"", fn_name));
192+
dbg.entry(&"fn", &format_args!("\"{}\"", fn_name));
189193
} else {
190-
dbg.field("fn", &"<unknown>");
194+
dbg.entry(&"fn", &"<unknown>");
191195
}
192196

193197
if let Some(fname) = self.filename.as_ref() {
194-
dbg.field("file", fname);
198+
dbg.entry(&"file", fname);
195199
}
196200

197201
if let Some(line) = self.lineno.as_ref() {
198-
dbg.field("line", line);
202+
dbg.entry(&"line", line);
199203
}
200204

201205
dbg.finish()
@@ -415,6 +419,7 @@ mod tests {
415419
eprintln!("captured: {:?}", bt);
416420
eprintln!("display print: {}", bt);
417421
eprintln!("resolved: {:?}", bt);
422+
eprintln!("resolved alt: {:#?}", bt);
418423
unimplemented!();
419424
}
420425
}

0 commit comments

Comments
 (0)