From 6edf58538f852102a80b0fce84e85ffca3c78c96 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 24 Sep 2010 15:39:10 +0200 Subject: Make `procedure-execution-count' fail gracefully when no source info is available. * module/system/vm/coverage.scm (procedure-execution-count): Handle the case where (null? (program-sources PROC)). --- module/system/vm/coverage.scm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'module/system/vm/coverage.scm') diff --git a/module/system/vm/coverage.scm b/module/system/vm/coverage.scm index 0f4c73ec9..17e2f40eb 100644 --- a/module/system/vm/coverage.scm +++ b/module/system/vm/coverage.scm @@ -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'. -- cgit v1.2.3