# HG changeset patch # User Steve Losh # Date 1459117543 0 # Node ID 87afb11b9791d860b23d276903727b382d9aa1f7 # Parent d80af96eaf15dc468212f909a451154c13892a5e Add a function for extracting things from the heap diff -r d80af96eaf15 -r 87afb11b9791 src/wam/dump.lisp --- a/src/wam/dump.lisp Sun Mar 27 18:32:37 2016 +0000 +++ b/src/wam/dump.lisp Sun Mar 27 22:25:43 2016 +0000 @@ -71,3 +71,20 @@ (+ addr width 1)) addr)) + + +(defun extract-thing (wam address) + (let ((cell (wam-heap-cell wam (deref wam address)))) + (cond + ((cell-null-p cell) + "NULL!") + ((cell-reference-p cell) + (format nil "var-~D" (cell-value cell))) + ((cell-structure-p cell) + (extract-thing wam (cell-value cell))) + ((cell-functor-p cell) + (let ((functor (wam-functor-lookup wam (cell-functor-index cell))) + (arity (cell-functor-arity cell))) + (list* functor + (loop :for i :from (1+ address) :to (+ address arity) + :collect (extract-thing wam i))))))))