about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-05-11 13:49:29 +0200
committerGitHub <noreply@github.com>2022-05-11 13:49:29 +0200
commitafb9171b64fdf50e483f4165f621e35dd9c92d27 (patch)
tree831c1419bb83525f461cec26d51d416964e273b9 /compiler
parent0c2cee2e9db93ddb54086239009f617e7d2db951 (diff)
parent831bd969674fd8afa751b13db543d58b2176c98c (diff)
downloadrust-afb9171b64fdf50e483f4165f621e35dd9c92d27.tar.gz
rust-afb9171b64fdf50e483f4165f621e35dd9c92d27.zip
Rollup merge of #96898 - RalfJung:interpret-pop-debug, r=oli-obk
logging: add env var to control verbose scope entry/exit logging

~~This got removed in https://github.com/rust-lang/rust/pull/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`
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_log/src/lib.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_log/src/lib.rs b/compiler/rustc_log/src/lib.rs
index f5e7435d36e..c152815eeca 100644
--- a/compiler/rustc_log/src/lib.rs
+++ b/compiler/rustc_log/src/lib.rs
@@ -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);