(events: &[MemtrackEvent])
| 38 | } |
| 39 | |
| 40 | fn format_events(events: &[MemtrackEvent]) -> Vec<String> { |
| 41 | const MARKER: u64 = 0xC0D5_9EED; |
| 42 | let has_markers = events.iter().any(|e| { |
| 43 | matches!( |
| 44 | e.kind, |
| 45 | MemtrackEventKind::Malloc { size, .. } if size == MARKER |
| 46 | ) |
| 47 | }); |
| 48 | |
| 49 | let filtered_events = if has_markers { |
| 50 | shared::between_markers(events) |
| 51 | } else { |
| 52 | events |
| 53 | .iter() |
| 54 | .filter(|e| { |
| 55 | matches!( |
| 56 | e.kind, |
| 57 | MemtrackEventKind::Malloc { .. } |
| 58 | | MemtrackEventKind::Free |
| 59 | | MemtrackEventKind::Calloc { .. } |
| 60 | | MemtrackEventKind::Realloc { .. } |
| 61 | | MemtrackEventKind::AlignedAlloc { .. } |
| 62 | ) |
| 63 | }) |
| 64 | .sorted_by_key(|e| e.timestamp) |
| 65 | .dedup_by(|a, b| a.addr == b.addr && discriminant(&a.kind) == discriminant(&b.kind)) |
| 66 | .cloned() |
| 67 | .collect() |
| 68 | }; |
| 69 | |
| 70 | filtered_events |
| 71 | .iter() |
| 72 | .filter_map(|e| describe_allocator_event(&e.kind)) |
| 73 | .collect() |
| 74 | } |
| 75 | |
| 76 | const STACK_TEST_CASES: &[AllocationTestCase] = &[ |
| 77 | AllocationTestCase { |
nothing calls this directly
no test coverage detected