Skip to content

Instantly share code, notes, and snippets.

@stassats
Created September 25, 2015 15:20
Show Gist options
  • Save stassats/2b06d6142b1e110b0686 to your computer and use it in GitHub Desktop.
Save stassats/2b06d6142b1e110b0686 to your computer and use it in GitHub Desktop.
cold-map.lisp
(defun %find-in-map (x &optional (map "/home/stas/sbcl-arm64/output/cold-sbcl.map"))
(when (symbolp x)
(setf x
(parse-integer (string x) :radix 16 :start 2)))
(with-open-file (stream map)
(loop until (char= (read-char stream) #\Page))
(read-line stream)
(read-line stream)
(read-line stream)
(loop with address
for previous = line
for previous-address = address
for line = (read-line stream)
while (plusp (length line))
do
(setf address (parse-integer line :radix 16 :start 2 :end (position #\: line)))
(when (> address x)
(return previous))
finally (write-line "Not found"))))
(defmacro fim (x)
`(%find-in-map ',x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment