Skip to content

Commit

Permalink
Rollup merge of rust-lang#96898 - RalfJung:interpret-pop-debug, r=oli…
Browse files Browse the repository at this point in the history
…-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`
  • Loading branch information
Dylan-DPC authored May 11, 2022
2 parents 0c2cee2 + 831bd96 commit afb9171
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions compiler/rustc_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,24 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> {
Err(VarError::NotUnicode(_value)) => return Err(Error::NonUnicodeColorValue),
};

let verbose_entry_exit = match env::var_os(String::from(env) + "_ENTRY_EXIT") {
None => false,
Some(v) => {
if &v == "0" {
false
} else {
true
}
}
};

let layer = tracing_tree::HierarchicalLayer::default()
.with_writer(io::stderr)
.with_indent_lines(true)
.with_ansi(color_logs)
.with_targets(true)
.with_verbose_exit(verbose_entry_exit)
.with_verbose_entry(verbose_entry_exit)
.with_indent_amount(2);
#[cfg(parallel_compiler)]
let layer = layer.with_thread_ids(true).with_thread_names(true);
Expand Down

0 comments on commit afb9171

Please sign in to comment.