Skip to content

Commit 17b06e6

Browse files
committed
Make all borrow tracker tracing spans have same name
... but the function name is specified in the arguments, see rust-lang#4452 (comment)
1 parent 1860f9f commit 17b06e6

File tree

1 file changed

+44
-19
lines changed

1 file changed

+44
-19
lines changed

src/borrow_tracker/mod.rs

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,11 @@ impl GlobalStateInner {
261261
machine: &MiriMachine<'_>,
262262
) -> AllocState {
263263
let _span = enter_trace_span!(
264-
"borrow_tracker::new_allocation",
265-
"id = {id:?}, size = {alloc_size:?}, kind = {kind:?}"
264+
"borrow_tracker",
265+
borrow_tracker_fun = %"new_allocation",
266+
?id,
267+
?alloc_size,
268+
?kind,
266269
);
267270
match self.borrow_tracker_method {
268271
BorrowTrackerMethod::StackedBorrows =>
@@ -285,9 +288,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
285288
val: &ImmTy<'tcx>,
286289
) -> InterpResult<'tcx, ImmTy<'tcx>> {
287290
let _span = enter_trace_span!(
288-
"borrow_tracker::retag_ptr_value",
289-
"kind = {kind:?}, val.layout = {:?}",
290-
val.layout
291+
"borrow_tracker",
292+
borrow_tracker_fun = %"retag_ptr_value",
293+
?kind,
294+
?val.layout,
291295
);
292296
let this = self.eval_context_mut();
293297
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
@@ -303,8 +307,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
303307
place: &PlaceTy<'tcx>,
304308
) -> InterpResult<'tcx> {
305309
let _span = enter_trace_span!(
306-
"borrow_tracker::retag_place_contents",
307-
"kind = {kind:?}, place = {place:?}"
310+
"borrow_tracker",
311+
borrow_tracker_fun = %"retag_place_contents",
312+
?kind,
313+
?place,
308314
);
309315
let this = self.eval_context_mut();
310316
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
@@ -315,7 +321,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
315321
}
316322

317323
fn protect_place(&mut self, place: &MPlaceTy<'tcx>) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
318-
let _span = enter_trace_span!("borrow_tracker::protect_place", "place = {place:?}");
324+
let _span =
325+
enter_trace_span!("borrow_tracker", borrow_tracker_fun = %"protect_place", ?place);
319326
let this = self.eval_context_mut();
320327
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
321328
match method {
@@ -326,10 +333,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
326333

327334
fn expose_tag(&self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> {
328335
let _span = enter_trace_span!(
329-
"borrow_tracker::expose_tag",
330-
"alloc_id = {}, tag = {}",
331-
alloc_id.0,
332-
tag.0
336+
"borrow_tracker",
337+
borrow_tracker_fun = %"expose_tag",
338+
alloc_id = alloc_id.0,
339+
tag = tag.0,
333340
);
334341
let this = self.eval_context_ref();
335342
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
@@ -374,7 +381,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
374381
&self,
375382
frame: &Frame<'tcx, Provenance, FrameExtra<'tcx>>,
376383
) -> InterpResult<'tcx> {
377-
let _span = enter_trace_span!("borrow_tracker::on_stack_pop");
384+
let _span = enter_trace_span!("borrow_tracker", borrow_tracker_fun = %"on_stack_pop");
378385
let this = self.eval_context_ref();
379386
let borrow_tracker = this.machine.borrow_tracker.as_ref().unwrap();
380387
// The body of this loop needs `borrow_tracker` immutably
@@ -452,7 +459,11 @@ impl AllocState {
452459
range: AllocRange,
453460
machine: &MiriMachine<'tcx>,
454461
) -> InterpResult<'tcx> {
455-
let _span = enter_trace_span!("borrow_tracker::before_memory_read");
462+
let _span = enter_trace_span!(
463+
"borrow_tracker",
464+
borrow_tracker_fun = %"before_memory_read",
465+
alloc_id = alloc_id.0
466+
);
456467
match self {
457468
AllocState::StackedBorrows(sb) =>
458469
sb.borrow_mut().before_memory_read(alloc_id, prov_extra, range, machine),
@@ -474,7 +485,11 @@ impl AllocState {
474485
range: AllocRange,
475486
machine: &MiriMachine<'tcx>,
476487
) -> InterpResult<'tcx> {
477-
let _span = enter_trace_span!("borrow_tracker::before_memory_write");
488+
let _span = enter_trace_span!(
489+
"borrow_tracker",
490+
borrow_tracker_fun = %"before_memory_write",
491+
alloc_id = alloc_id.0
492+
);
478493
match self {
479494
AllocState::StackedBorrows(sb) =>
480495
sb.get_mut().before_memory_write(alloc_id, prov_extra, range, machine),
@@ -496,7 +511,11 @@ impl AllocState {
496511
size: Size,
497512
machine: &MiriMachine<'tcx>,
498513
) -> InterpResult<'tcx> {
499-
let _span = enter_trace_span!("borrow_tracker::before_memory_deallocation");
514+
let _span = enter_trace_span!(
515+
"borrow_tracker",
516+
borrow_tracker_fun = %"before_memory_deallocation",
517+
alloc_id = alloc_id.0
518+
);
500519
match self {
501520
AllocState::StackedBorrows(sb) =>
502521
sb.get_mut().before_memory_deallocation(alloc_id, prov_extra, size, machine),
@@ -506,7 +525,8 @@ impl AllocState {
506525
}
507526

508527
pub fn remove_unreachable_tags(&self, tags: &FxHashSet<BorTag>) {
509-
let _span = enter_trace_span!("borrow_tracker::remove_unreachable_tags");
528+
let _span =
529+
enter_trace_span!("borrow_tracker", borrow_tracker_fun = %"remove_unreachable_tags");
510530
match self {
511531
AllocState::StackedBorrows(sb) => sb.borrow_mut().remove_unreachable_tags(tags),
512532
AllocState::TreeBorrows(tb) => tb.borrow_mut().remove_unreachable_tags(tags),
@@ -521,7 +541,12 @@ impl AllocState {
521541
tag: BorTag,
522542
alloc_id: AllocId, // diagnostics
523543
) -> InterpResult<'tcx> {
524-
let _span = enter_trace_span!("borrow_tracker::release_protector");
544+
let _span = enter_trace_span!(
545+
"borrow_tracker",
546+
borrow_tracker_fun = %"release_protector",
547+
alloc_id = alloc_id.0,
548+
tag = tag.0
549+
);
525550
match self {
526551
AllocState::StackedBorrows(_sb) => interp_ok(()),
527552
AllocState::TreeBorrows(tb) =>
@@ -532,7 +557,7 @@ impl AllocState {
532557

533558
impl VisitProvenance for AllocState {
534559
fn visit_provenance(&self, visit: &mut VisitWith<'_>) {
535-
let _span = enter_trace_span!("borrow_tracker::visit_provenance");
560+
let _span = enter_trace_span!("borrow_tracker", borrow_tracker_fun = %"visit_provenance");
536561
match self {
537562
AllocState::StackedBorrows(sb) => sb.visit_provenance(visit),
538563
AllocState::TreeBorrows(tb) => tb.visit_provenance(visit),

0 commit comments

Comments
 (0)