Skip to content

Commit afb9171

Browse files
authored
Rollup merge of rust-lang#96898 - RalfJung:interpret-pop-debug, r=oli-obk
logging: add env var to control verbose scope entry/exit logging ~~This got removed in rust-lang#75143, and I find this makes long traces a lot harder to read, so I propose we add this back.~~ Example trace: ``` │ │ ├─0ms INFO rustc_const_eval::interpret::step return │ │ ├─0ms INFO rustc_const_eval::interpret::eval_context popping stack frame (returning from function) │ │┌┘rustc_const_eval::interpret::eval_context::frame std::ptr::mut_ptr::<impl *mut u8>::guaranteed_eq │ ├┘rustc_const_eval::interpret::eval_context::frame std::ptr::mut_ptr::<impl *mut u8>::is_null │ ├─1ms INFO rustc_const_eval::interpret::step // executing bb2 │ ├─1ms INFO rustc_const_eval::interpret::step StorageDead(_4) │ ├─1ms INFO rustc_const_eval::interpret::step StorageDead(_2) │ ├─1ms INFO rustc_const_eval::interpret::step return │ ├─1ms INFO rustc_const_eval::interpret::eval_context popping stack frame (returning from function) │┌┘rustc_const_eval::interpret::eval_context::frame std::ptr::mut_ptr::<impl *mut u8>::is_null ├┘rustc_const_eval::interpret::eval_context::frame std::sys_common::thread_local_dtor::register_dtor_fallback::run_dtors ├─178ms INFO rustc_const_eval::interpret::step // executing bb2 ├─178ms INFO rustc_const_eval::interpret::step StorageDead(_5) ``` r? `@oli-obk`
2 parents 0c2cee2 + 831bd96 commit afb9171

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

compiler/rustc_log/src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,24 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> {
6767
Err(VarError::NotUnicode(_value)) => return Err(Error::NonUnicodeColorValue),
6868
};
6969

70+
let verbose_entry_exit = match env::var_os(String::from(env) + "_ENTRY_EXIT") {
71+
None => false,
72+
Some(v) => {
73+
if &v == "0" {
74+
false
75+
} else {
76+
true
77+
}
78+
}
79+
};
80+
7081
let layer = tracing_tree::HierarchicalLayer::default()
7182
.with_writer(io::stderr)
7283
.with_indent_lines(true)
7384
.with_ansi(color_logs)
7485
.with_targets(true)
86+
.with_verbose_exit(verbose_entry_exit)
87+
.with_verbose_entry(verbose_entry_exit)
7588
.with_indent_amount(2);
7689
#[cfg(parallel_compiler)]
7790
let layer = layer.with_thread_ids(true).with_thread_names(true);

0 commit comments

Comments
 (0)