Skip to content

Commit 452e36e

Browse files
author
Vytautas Astrauskas
committed
Print the thread name in Debug.
1 parent 3bb1657 commit 452e36e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/thread.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,16 @@ impl<'mir, 'tcx> Thread<'mir, 'tcx> {
131131

132132
impl<'mir, 'tcx> std::fmt::Debug for Thread<'mir, 'tcx> {
133133
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
134-
write!(f, "{:?}", self.state)
134+
if let Some(ref name) = self.thread_name {
135+
if let Ok(name_str) = std::str::from_utf8(name) {
136+
write!(f, "{}", name_str)?;
137+
} else {
138+
write!(f, "<invalid thread name>")?;
139+
}
140+
} else {
141+
write!(f, "unnamed")?;
142+
}
143+
write!(f, "({:?}, {:?})", self.state, self.join_status)
135144
}
136145
}
137146

0 commit comments

Comments
 (0)