File: coreparse.pure.lisp

package info (click to toggle)
sbcl 2%3A2.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 52,008 kB
  • sloc: lisp: 535,135; ansic: 42,629; sh: 5,737; asm: 2,406; pascal: 717; makefile: 432; python: 56; cpp: 27
file content (32 lines) | stat: -rw-r--r-- 1,537 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(defun readprocmaps ()
  #+(and linux immobile-space) ; sb-vm: symbols may not exist?
  (let* ((space-start sb-vm:fixedobj-space-start)
         (space-end (+ sb-vm:fixedobj-space-size space-start))
         (state nil))
    (with-open-file (f "/proc/self/maps")
      (loop
       (let ((line (read-line f nil)))
         (assert line) ; better not run out of lines before passing the test
         (sb-int:binding*
             (((range-start dashpos) (parse-integer line :radix 16 :junk-allowed t))
              ((range-end spacepos)
               (progn (assert (char= (char line dashpos) #\-))
                      (parse-integer line :radix 16 :start (1+ dashpos) :junk-allowed t)))
              (perms
               (progn (assert (char= (char line spacepos) #\space))
                      (subseq line (incf spacepos) (+ spacepos 4)))))
           (case state
             ((nil)
              ;; look for a range that starts exactly at space-start
              (if (= range-start space-start)
                  (setq state :in-fixedobj-space)
                  ;; larger address means somehow we missed seeeing fixedobj space
                  (assert (< range-end space-start))))
             (:in-fixedobj-space
              (cond ((= range-end space-end)
                     (assert (string= perms "rwxp")) ; untouched pages must exist
                     (return))
                    (t
                     (assert (< range-end space-end))))))))))))

(with-test (:name :fixedobj-sized-correctly) (readprocmaps))