Make `procedure-execution-count' fail gracefully when no source info is available.
authorLudovic Courtès <ludo@gnu.org>
Fri, 24 Sep 2010 13:39:10 +0000 (15:39 +0200)
committerLudovic Courtès <ludo@gnu.org>
Fri, 24 Sep 2010 13:39:47 +0000 (15:39 +0200)
* module/system/vm/coverage.scm (procedure-execution-count): Handle the
  case where (null? (program-sources PROC)).

module/system/vm/coverage.scm

index 0f4c73e..17e2f40 100644 (file)
@@ -199,12 +199,14 @@ coverage data.  Return code coverage data and the values returned by THUNK."
 if PROC was not executed.  When PROC is a closure, the number of times its code
 was executed is returned, not the number of times this code associated with this
 particular closure was executed."
-  (and=> (hashx-ref hashq-proc assq-proc
-                    (data-procedure->ip-counts data) proc)
-         (let ((sources (program-sources* data proc)))
-           (lambda (ip-counts)
-             (let ((entry-ip (source:addr (car sources)))) ;; FIXME: broken with lambda*
-               (hashv-ref ip-counts entry-ip 0))))))
+  (let ((sources (program-sources* data proc)))
+    (and (pair? sources)
+         (and=> (hashx-ref hashq-proc assq-proc
+                           (data-procedure->ip-counts data) proc)
+                (lambda (ip-counts)
+                  ;; FIXME: broken with lambda*
+                  (let ((entry-ip (source:addr (car sources))))
+                    (hashv-ref ip-counts entry-ip 0)))))))
 
 (define (program-sources* data proc)
   ;; A memoizing version of `program-sources'.