From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Han-Wen Nienhuys Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] experimental lookupcar based coverage testing. Date: Fri, 19 Jan 2007 21:14:17 +0100 Message-ID: <45B12699.8080901@xs4all.nl> References: <45AFCEFD.5030203@xs4all.nl> <87lkjz40zc.fsf@laas.fr> <45B0CC62.7020705@xs4all.nl> <87lkjzypbn.fsf@laas.fr> Reply-To: hanwen@xs4all.nl NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1169237673 18949 80.91.229.12 (19 Jan 2007 20:14:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 19 Jan 2007 20:14:33 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Jan 19 21:14:30 2007 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1H8083-0001qD-QZ for guile-devel@m.gmane.org; Fri, 19 Jan 2007 21:14:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H8083-0004X0-0U for guile-devel@m.gmane.org; Fri, 19 Jan 2007 15:14:27 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H807z-0004S3-3D for guile-devel@gnu.org; Fri, 19 Jan 2007 15:14:23 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H807y-0004QX-B2 for guile-devel@gnu.org; Fri, 19 Jan 2007 15:14:22 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H807y-0004QJ-6x for guile-devel@gnu.org; Fri, 19 Jan 2007 15:14:22 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1H807x-0005jH-OJ for guile-devel@gnu.org; Fri, 19 Jan 2007 15:14:22 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1H807u-0002Lk-FX for guile-devel@gnu.org; Fri, 19 Jan 2007 21:14:18 +0100 Original-Received: from muurbloem.xs4all.nl ([213.84.26.127]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Jan 2007 21:14:18 +0100 Original-Received: from hanwen by muurbloem.xs4all.nl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Jan 2007 21:14:18 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: guile-devel@gnu.org Original-Lines: 84 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: muurbloem.xs4all.nl User-Agent: Thunderbird 1.5.0.9 (X11/20061219) In-Reply-To: <87lkjzypbn.fsf@laas.fr> X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:6460 Archived-At: Ludovic Courtès escreveu: >> Of course, the patch that I posted is ad-hoc, because it hardcodes the >> coverage analysis in eval.c. If it were to be included, I propose >> something like >> >> (trap-set! 'memoize-symbol >> record-coverage) >> (trap-enable 'memoize-symbol) >> >> which would be possible with a generic, and quite minimal extension to >> eval. > > Indeed, this looks less specific and more flexible. I'd personally > prefer this approach. This is now in CVS, along with a couple of other changes. The following code demonstrates the use of this interface. *** (define coverage-table (make-hash-table 57)) (use-modules (ice-9 rdelim) (ice-9 format)) (define (read-lines port) (string-split (read-delimited "" port) #\newline)) (define (display-coverage file vec) (let* ((lines (read-lines (open-file file "r")))) (do ((i 0 (1+ i)) (l lines (cdr l))) ((or (null? l) (>= i (vector-length vec)))) (display (format #f "~8a: ~a\n" (if (vector-ref vec i) "#t" "") (car l)))))) (define (show-coverage) (newline) (hash-fold (lambda (key val acc) (display-coverage key val) #t) #t coverage-table)) (define (record-coverage key cont exp env) (let* ((name (source-property exp 'filename)) (line (source-property exp 'line)) (vec (and name (hashv-ref coverage-table name #f))) (veclen (and vec (vector-length vec))) (veccopy (lambda (src dst) (vector-move-left! src 0 (vector-length src) dst 0) dst))) (if (and line name) (begin (if (or (not vec) (>= line (vector-length vec))) (set! vec (hashv-set! coverage-table name (if vec (veccopy vec (make-vector (1+ line) #f)) (make-vector (1+ line) #f))))) (display (vector-length vec)) (vector-set! vec line #t)) ))) (trap-set! memoize-symbol-handler record-coverage) (trap-enable 'memoize-symbol) *** -- Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel