Skip to content

Commit 514ef65

Browse files
authored
Rollup merge of rust-lang#56718 - RalfJung:use-libbacktrace-printing, r=alexcrichton
Use libbacktrace pretty-printing r? @alexcrichton
2 parents f17c5ac + 8e994a2 commit 514ef65

File tree

2 files changed

+10
-46
lines changed

2 files changed

+10
-46
lines changed

Cargo.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ dependencies = [
8181

8282
[[package]]
8383
name = "backtrace"
84-
version = "0.3.9"
84+
version = "0.3.11"
8585
source = "registry+https://github.com/rust-lang/crates.io-index"
8686
dependencies = [
8787
"backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -728,15 +728,15 @@ name = "error-chain"
728728
version = "0.11.0"
729729
source = "registry+https://github.com/rust-lang/crates.io-index"
730730
dependencies = [
731-
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
731+
"backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
732732
]
733733

734734
[[package]]
735735
name = "error-chain"
736736
version = "0.12.0"
737737
source = "registry+https://github.com/rust-lang/crates.io-index"
738738
dependencies = [
739-
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
739+
"backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
740740
]
741741

742742
[[package]]
@@ -751,7 +751,7 @@ name = "failure"
751751
version = "0.1.3"
752752
source = "registry+https://github.com/rust-lang/crates.io-index"
753753
dependencies = [
754-
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
754+
"backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
755755
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
756756
]
757757

@@ -2060,7 +2060,7 @@ name = "rustc"
20602060
version = "0.0.0"
20612061
dependencies = [
20622062
"arena 0.0.0",
2063-
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
2063+
"backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
20642064
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
20652065
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
20662066
"chalk-engine 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3380,7 +3380,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
33803380
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
33813381
"checksum assert_cli 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98589b0e465a6c510d95fceebd365bb79bedece7f6e18a480897f2015f85ec51"
33823382
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
3383-
"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a"
3383+
"checksum backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "18b65ea1161bfb2dd6da6fade5edd4dbd08fba85012123dd333d2fd1b90b2782"
33843384
"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0"
33853385
"checksum bit-set 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f1efcc46c18245a69c38fcc5cc650f16d3a59d034f3106e9ed63748f695730a"
33863386
"checksum bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440d5cb623bb7390ae27fec0bb6c61111969860f8e3ae198bfa0663645e67cf"

src/librustc/mir/interpret/error.rs

+4-40
Original file line numberDiff line numberDiff line change
@@ -183,50 +183,14 @@ pub struct EvalError<'tcx> {
183183
impl<'tcx> EvalError<'tcx> {
184184
pub fn print_backtrace(&mut self) {
185185
if let Some(ref mut backtrace) = self.backtrace {
186-
eprintln!("{}", print_backtrace(&mut *backtrace));
186+
print_backtrace(&mut *backtrace);
187187
}
188188
}
189189
}
190190

191-
fn print_backtrace(backtrace: &mut Backtrace) -> String {
192-
use std::fmt::Write;
193-
191+
fn print_backtrace(backtrace: &mut Backtrace) {
194192
backtrace.resolve();
195-
196-
let mut trace_text = "\n\nAn error occurred in miri:\n".to_string();
197-
write!(trace_text, "backtrace frames: {}\n", backtrace.frames().len()).unwrap();
198-
'frames: for (i, frame) in backtrace.frames().iter().enumerate() {
199-
if frame.symbols().is_empty() {
200-
write!(trace_text, " {}: no symbols\n", i).unwrap();
201-
}
202-
let mut first = true;
203-
for symbol in frame.symbols() {
204-
if first {
205-
write!(trace_text, " {}: ", i).unwrap();
206-
first = false;
207-
} else {
208-
let len = i.to_string().len();
209-
write!(trace_text, " {} ", " ".repeat(len)).unwrap();
210-
}
211-
if let Some(name) = symbol.name() {
212-
write!(trace_text, "{}\n", name).unwrap();
213-
} else {
214-
write!(trace_text, "<unknown>\n").unwrap();
215-
}
216-
write!(trace_text, " at ").unwrap();
217-
if let Some(file_path) = symbol.filename() {
218-
write!(trace_text, "{}", file_path.display()).unwrap();
219-
} else {
220-
write!(trace_text, "<unknown_file>").unwrap();
221-
}
222-
if let Some(line) = symbol.lineno() {
223-
write!(trace_text, ":{}\n", line).unwrap();
224-
} else {
225-
write!(trace_text, "\n").unwrap();
226-
}
227-
}
228-
}
229-
trace_text
193+
eprintln!("\n\nAn error occurred in miri:\n{:?}", backtrace);
230194
}
231195

232196
impl<'tcx> From<EvalErrorKind<'tcx, u64>> for EvalError<'tcx> {
@@ -238,7 +202,7 @@ impl<'tcx> From<EvalErrorKind<'tcx, u64>> for EvalError<'tcx> {
238202

239203
if val == "immediate" {
240204
// Print it now
241-
eprintln!("{}", print_backtrace(&mut backtrace));
205+
print_backtrace(&mut backtrace);
242206
None
243207
} else {
244208
Some(Box::new(backtrace))

0 commit comments

Comments
 (0)