Created
September 25, 2015 15:20
-
-
Save stassats/2b06d6142b1e110b0686 to your computer and use it in GitHub Desktop.
cold-map.lisp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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