Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bin/log/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn init_logger_once(early_dcx: &EarlyDiagCtxt) {
#[cfg(not(feature = "tracing"))]
{
crate::fatal_error!(
"fatal error: cannot enable MIRI_TRACING since Miri was not built with the \"tracing\" feature"
"Cannot enable MIRI_TRACING since Miri was not built with the \"tracing\" feature"
);
}

Expand Down
13 changes: 9 additions & 4 deletions src/bin/log/tracing_chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//! ```rust
//! tracing::info_span!("my_span", tracing_separate_thread = tracing::field::Empty, /* ... */)
//! ```
//! - use i64 instead of u64 for the "id" in [ChromeLayer::get_root_id] to be compatible with Perfetto
//!
//! Depending on the tracing-chrome crate from crates.io is unfortunately not possible, since it
//! depends on `tracing_core` which conflicts with rustc_private's `tracing_core` (meaning it would
Expand Down Expand Up @@ -285,9 +286,9 @@ struct Callsite {
}

enum Message {
Enter(f64, Callsite, Option<u64>),
Enter(f64, Callsite, Option<i64>),
Event(f64, Callsite),
Exit(f64, Callsite, Option<u64>),
Exit(f64, Callsite, Option<i64>),
NewThread(usize, String),
Flush,
Drop,
Expand Down Expand Up @@ -519,14 +520,17 @@ where
}
}

fn get_root_id(&self, span: SpanRef<S>) -> Option<u64> {
fn get_root_id(&self, span: SpanRef<S>) -> Option<i64> {
// Returns `Option<i64>` instead of `Option<u64>` because apparently Perfetto gives an
// error if an id does not fit in a 64-bit signed integer in 2's complement. We cast the
// span id from `u64` to `i64` with wraparound, since negative values are fine.
match self.trace_style {
TraceStyle::Threaded => {
if span.fields().field("tracing_separate_thread").is_some() {
// assign an independent "id" to spans with argument "tracing_separate_thread",
// so they appear a separate trace line in trace visualization tools, see
// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#heading=h.jh64i9l3vwa1
Some(span.id().into_u64())
Some(span.id().into_u64().cast_signed()) // the comment above explains the cast
} else {
None
}
Expand All @@ -539,6 +543,7 @@ where
.unwrap_or(span)
.id()
.into_u64()
.cast_signed() // the comment above explains the cast
),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ pub struct MaybeEnteredTraceSpan {
#[macro_export]
macro_rules! enter_trace_span {
($name:ident :: $subname:ident $($tt:tt)*) => {{
enter_trace_span!(stringify!($name), $name = %stringify!(subname) $($tt)*)
enter_trace_span!(stringify!($name), $name = %stringify!($subname) $($tt)*)
}};

($($tt:tt)*) => {
Expand Down
Loading