Skip to content

Commit

Permalink
RTS tests: add a helper for printing heap in tests (#2802)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
osa1 and mergify[bot] authored Sep 22, 2021
1 parent 30aa6f9 commit 604c89d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions rts/motoko-rts-tests/src/gc/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ impl MotokoHeap {
pub fn heap(&self) -> Ref<Box<[u8]>> {
Ref::map(self.inner.borrow(), |heap| &heap.heap)
}

/// Print heap contents to stdout, for debugging purposes.
#[allow(unused)]
pub fn dump(&self) {
unsafe {
motoko_rts::debug::dump_heap(
self.heap_base_address() as u32,
self.heap_ptr_address() as u32,
Value::from_ptr(self.static_root_array_address()),
self.continuation_table_ptr_address() as *mut Value,
);
}
}
}

struct MotokoHeapInner {
Expand Down

0 comments on commit 604c89d

Please sign in to comment.