Skip to content

Commit 187a870

Browse files
authored
[trace-dump] Fix memory trace file writing for mem_profile (#1051)
- The trace-dump utility tool expects only a pointer when a free operation is reported. Signed-off-by: Doru Blânzeanu <[email protected]>
1 parent 262e5ef commit 187a870

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/hyperlight_host/src/sandbox/trace/mem_profile.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,22 @@ impl MemTraceInfo {
155155
let amt = regs.rax;
156156
let ptr = regs.rcx;
157157

158-
self.record_trace_frame(self.epoch, trace_identifier as u64, |f| {
159-
let _ = f.write_all(&ptr.to_ne_bytes());
160-
let _ = f.write_all(&amt.to_ne_bytes());
161-
self.write_stack(f, &stack);
162-
})
158+
match trace_identifier {
159+
TraceFrameType::MemAlloc => {
160+
self.record_trace_frame(self.epoch, trace_identifier as u64, |f| {
161+
let _ = f.write_all(&ptr.to_ne_bytes());
162+
let _ = f.write_all(&amt.to_ne_bytes());
163+
self.write_stack(f, &stack);
164+
})
165+
}
166+
// The MemFree case does not expect an amount, only a pointer
167+
TraceFrameType::MemFree => {
168+
self.record_trace_frame(self.epoch, trace_identifier as u64, |f| {
169+
let _ = f.write_all(&ptr.to_ne_bytes());
170+
self.write_stack(f, &stack);
171+
})
172+
}
173+
}
163174
}
164175

165176
#[inline(always)]

0 commit comments

Comments
 (0)