diff options
| author | est31 <MTest31@outlook.com> | 2020-11-12 21:46:54 +0100 | 
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2020-11-15 13:09:56 +0100 | 
| commit | 43bfbb10bf52d1cf6bd90ae2e19bcd357d38be4d (patch) | |
| tree | a0898b0b9b77896d5ad05644a69e895ec38e66cd /library/std/src/backtrace.rs | |
| parent | 75042566d1c90d912f22e4db43b6d3af98447986 (diff) | |
| download | rust-43bfbb10bf52d1cf6bd90ae2e19bcd357d38be4d.tar.gz rust-43bfbb10bf52d1cf6bd90ae2e19bcd357d38be4d.zip | |
Add column number support to Backtrace
Backtrace frames might include column numbers. Print them if they are included.
Diffstat (limited to 'library/std/src/backtrace.rs')
| -rw-r--r-- | library/std/src/backtrace.rs | 11 | 
1 files changed, 9 insertions, 2 deletions
| diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index a9d8a4e2a81..7e8e0a621e3 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -161,6 +161,7 @@ struct BacktraceSymbol { name: Option<Vec<u8>>, filename: Option<BytesOrWide>, lineno: Option<u32>, + colno: Option<u32>, } enum BytesOrWide { @@ -197,6 +198,10 @@ impl fmt::Debug for Backtrace { impl fmt::Debug for BacktraceSymbol { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + // FIXME: improve formatting: https://github.com/rust-lang/rust/issues/65280 + // FIXME: Also, include column numbers into the debug format as Display already has them. + // Until there are stable per-frame accessors, the format shouldn't be changed: + // https://github.com/rust-lang/rust/issues/65280#issuecomment-638966585 write!(fmt, "{{ ")?; if let Some(fn_name) = self.name.as_ref().map(|b| backtrace_rs::SymbolName::new(b)) { @@ -209,7 +214,7 @@ impl fmt::Debug for BacktraceSymbol { write!(fmt, ", file: \"{:?}\"", fname)?; } - if let Some(line) = self.lineno.as_ref() { + if let Some(line) = self.lineno { write!(fmt, ", line: {:?}", line)?; } @@ -381,7 +386,7 @@ impl fmt::Display for Backtrace { f.print_raw(frame.frame.ip(), None, None, None)?; } else { for symbol in frame.symbols.iter() { - f.print_raw( + f.print_raw_with_column( frame.frame.ip(), symbol.name.as_ref().map(|b| backtrace_rs::SymbolName::new(b)), symbol.filename.as_ref().map(|b| match b { @@ -389,6 +394,7 @@ impl fmt::Display for Backtrace { BytesOrWide::Wide(w) => BytesOrWideString::Wide(w), }), symbol.lineno, + symbol.colno, )?; } } @@ -427,6 +433,7 @@ impl Capture { BytesOrWideString::Wide(b) => BytesOrWide::Wide(b.to_owned()), }), lineno: symbol.lineno(), + colno: symbol.colno(), }); }); } | 
