Skip to content

Commit ade1232

Browse files
authored
Rollup merge of #96697 - oli-obk:trace_queries, r=michaelwoerister
Enable tracing for all queries This allows you to log everything within a specific query, e.g. ``` env RUSTC_LOG=[mir_borrowck] ``` dumping all borrowck queries may be a bit verbose, so you can also restrict it to just an item of your choice: ``` env RUSTC_LOG=[mir_borrowck{key=\.\*name_of_item\.\*}] ``` the regex `.*` in the key name are because the key is a debug printed DefId, so you'd get all kinds of things like hashes in there. The tracing logs will show you the key, so you can restrict it further if you want.
2 parents e3ada27 + 0d5a738 commit ade1232

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4245,6 +4245,7 @@ dependencies = [
42454245
"rustc_serialize",
42464246
"rustc_session",
42474247
"rustc_span",
4248+
"tracing",
42484249
]
42494250

42504251
[[package]]

compiler/rustc_query_impl/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ rustc_query_system = { path = "../rustc_query_system" }
2020
rustc_serialize = { path = "../rustc_serialize" }
2121
rustc_session = { path = "../rustc_session" }
2222
rustc_span = { path = "../rustc_span" }
23+
tracing = "0.1"
2324

2425
[features]
2526
rustc_use_parallel_compiler = ["rustc-rayon-core", "rustc_query_system/rustc_use_parallel_compiler"]

compiler/rustc_query_impl/src/plumbing.rs

+3
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ macro_rules! define_queries {
435435

436436
fn force_from_dep_node(tcx: TyCtxt<'_>, dep_node: DepNode) -> bool {
437437
if let Some(key) = recover(tcx, dep_node) {
438+
#[cfg(debug_assertions)]
439+
let _guard = tracing::span!(tracing::Level::TRACE, stringify!($name), ?key).entered();
438440
let tcx = QueryCtxt::from_tcx(tcx);
439441
force_query::<queries::$name<'_>, _>(tcx, key, dep_node);
440442
true
@@ -532,6 +534,7 @@ macro_rules! define_queries_struct {
532534

533535
$($(#[$attr])*
534536
#[inline(always)]
537+
#[tracing::instrument(level = "trace", skip(self, tcx))]
535538
fn $name(
536539
&'tcx self,
537540
tcx: TyCtxt<$tcx>,

compiler/rustc_query_system/src/query/plumbing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ where
675675
}
676676
}
677677

678+
#[derive(Debug)]
678679
pub enum QueryMode {
679680
Get,
680681
Ensure,
@@ -697,7 +698,6 @@ where
697698
None
698699
};
699700

700-
debug!("ty::query::get_query<{}>(key={:?}, span={:?})", Q::NAME, key, span);
701701
let (result, dep_node_index) = try_execute_query(
702702
tcx,
703703
Q::query_state(tcx),

0 commit comments

Comments
 (0)