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: frames / stacks / source? was Re: coverage/profiling Date: Tue, 09 Jan 2007 00:48:13 +0100 Message-ID: <45A2D83D.3060700@xs4all.nl> References: 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: 7bit X-Trace: sea.gmane.org 1168300139 28434 80.91.229.12 (8 Jan 2007 23:48:59 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 8 Jan 2007 23:48:59 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Jan 09 00:48:48 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 1H44EJ-0001Dn-1g for guile-devel@m.gmane.org; Tue, 09 Jan 2007 00:48:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H44EI-0001pY-I2 for guile-devel@m.gmane.org; Mon, 08 Jan 2007 18:48:38 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H44EF-0001p8-J9 for guile-devel@gnu.org; Mon, 08 Jan 2007 18:48:35 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H44ED-0001me-P3 for guile-devel@gnu.org; Mon, 08 Jan 2007 18:48:35 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H44ED-0001mQ-L6 for guile-devel@gnu.org; Mon, 08 Jan 2007 18:48:33 -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 1H44ED-0008OG-6K for guile-devel@gnu.org; Mon, 08 Jan 2007 18:48:33 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1H44E1-0002iw-UI for guile-devel@gnu.org; Tue, 09 Jan 2007 00:48:21 +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 ; Tue, 09 Jan 2007 00:48:21 +0100 Original-Received: from hanwen by muurbloem.xs4all.nl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 09 Jan 2007 00:48:21 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: guile-devel@gnu.org Original-Lines: 77 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: 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:6400 Archived-At: Han-Wen Nienhuys escreveu: > I'd like to run a coverage check on the lilypond source. > How do I do this in GUILE? Since noone responded, I decided to take a look myself. My overall idea was to do the following: - at the top of deval(), find out current source file and line - invoke some kind of callback that increments a counter for the source location - produce pretty pretty coverage graphs with the contents of the hash The last two steps are trivial, but I'm getting lost with the first step. I tried to follow what happens when an error backtrace is generated. My try is below. Unfortunately, I can't find much documentation on how frames/stacks/etc. interact. Can anyone gently nudge me in the right direction? diff -p -u -u -r1.408 eval.c --- eval.c 9 Oct 2006 23:10:31 -0000 1.408 +++ eval.c 8 Jan 2007 23:39:39 -0000 @@ -3230,6 +3230,13 @@ eval_letrec_inits (SCM env, SCM init_for * If, however, x represents some form that requires to evaluate a sequence of * expressions like (begin exp1 exp2 ...), then recursive calls to CEVAL are * performed for all but the last expression of that sequence. */ +#include "stacks.h" +#include + +void +read_frame (scm_t_debug_frame const *dframe, scm_t_ptrdiff offset, + scm_t_info_frame *iframe); +int scm_do_profiling; static SCM CEVAL (SCM x, SCM env) @@ -3263,6 +3270,34 @@ CEVAL (SCM x, SCM env) } #endif + +#ifdef DEVAL + if (scm_do_profiling) + { + struct scm_t_info_frame info_frame; + SCM source; + SCM file; + SCM line; + + read_frame (&debug, 0, &info_frame); + + source = info_frame.source; + file = SCM_MEMOIZEDP (source) ? scm_source_property (source, scm_sym_filename) : SCM_BOOL_F; + line = (SCM_MEMOIZEDP (source)) ? scm_source_property (source, scm_sym_line) : SCM_BOOL_F; + + if (scm_is_true (line) + && scm_is_true (file)) + { + printf ("%s %d - size %ld\n", scm_i_string_chars (file), scm_to_int (line), scm_debug_eframe _size); + } + else + { + scm_display (source, scm_current_output_port ()); + scm_puts ("\n", scm_current_output_port ()); + } + } +#endif -- 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