From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: guile-debugging: how to access source properties from trap context Date: Mon, 02 Jan 2006 00:18:09 +0000 Message-ID: <87vex3pjni.fsf@ossau.uklinux.net> References: <20060101213351.GA5366@tosh> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1136161347 17234 80.91.229.2 (2 Jan 2006 00:22:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 2 Jan 2006 00:22:27 +0000 (UTC) Cc: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jan 02 01:22:22 2006 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EtDSs-0002B8-1J for guile-user@m.gmane.org; Mon, 02 Jan 2006 01:22:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EtDUP-0005Bk-KB for guile-user@m.gmane.org; Sun, 01 Jan 2006 19:23:53 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EtDSO-0004Rg-1J for guile-user@gnu.org; Sun, 01 Jan 2006 19:21:48 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EtDSL-0004Qu-PS for guile-user@gnu.org; Sun, 01 Jan 2006 19:21:46 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EtDSK-0004Qg-TL for guile-user@gnu.org; Sun, 01 Jan 2006 19:21:45 -0500 Original-Received: from [80.84.72.33] (helo=mail3.uklinux.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EtDTI-0002GY-50 for guile-user@gnu.org; Sun, 01 Jan 2006 19:22:44 -0500 Original-Received: from laruns (host86-129-132-201.range86-129.btcentralplus.com [86.129.132.201]) by mail3.uklinux.net (Postfix) with ESMTP id 5A8A440A03F; Mon, 2 Jan 2006 00:20:06 +0000 (UTC) Original-Received: from laruns (laruns [127.0.0.1]) by laruns (Postfix) with ESMTP id 7ECE16F658; Mon, 2 Jan 2006 00:18:10 +0000 (GMT) Original-To: Holger Blasum In-Reply-To: <20060101213351.GA5366@tosh> (Holger Blasum's message of "Sun, 1 Jan 2006 22:33:51 +0100") User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:5021 Archived-At: Holger Blasum writes: > Hello guile-user, Hi Holger, > in the "Guile Debugging Enhancements" tutorial > (http://download.gna.org/guile-debugging/guile-debugging.html) > there is encouragement to play with the source trap context > parameters. It's not important for the rest of my reply, but can you indicate exactly where in the doc you are referring to, so I can review whether this encouragement is worded as well as it could be? > What I want to look at are the source file names and > line numbers like eg in any gdb stepping session of a C program > say for matrix multiplication like: > > gdb -f a.out > (gdb) br main > Breakpoint 1 at 0x8048417: file matrix.c, line 11. > (gdb) run > Starting program: /home/blasum/a/comp/sema/sample/c/samples/a.out > /home/blasum/a/comp/sema/sample/c/samples/matrix.c:12 > (gdb) step > /home/blasum/a/comp/sema/sample/c/samples/matrix.c:13 > (gdb) step > /home/blasum/a/comp/sema/sample/c/samples/matrix.c:14 > (gdb) step > ... > > How can one access file name and line number of the source > properties in guile-debugging? In theory, the trace/source procedure exported from (ossau trace) should give you this. Here's an example which works up to a point for me: (use-modules (ice-9 debugger) (ossau ice-9-debugger-extensions) (ossau traps) (ossau trace)) (load "matrix.scm") (define (report-exp trap-context) (display "Expression: ") (display (trace/source trap-context)) (newline)) (install-trap (make #:procedure mkmatrix #:behaviour (list report-exp))) (do-main 4) which prints: Expression: matrix.scm:6:2 Note, though, that my dummy matrix.scm looks like this ... (define (mkmatrix) (let ((x 1)) 'this-is-a-matric)) (define (do-main n) (mkmatrix)) ... so 6:2 is the location of the call to mkmatrix, not of mkmatrix's own code. Is that what you wanted? I suspect not, because it doesn't map onto the GDB example that you gave. It sounds like what you might in fact want is a report of the evaluation of each subexpression within mkmatrix. In that case, the correct incantation would be something like this: (use-modules (ice-9 debugger) (ossau ice-9-debugger-extensions) (ossau traps) (ossau trace) (ossau steps)) (load "matrix.scm") (define (report-exp trap-context) (display "Expression: ") (display (trace/source trap-context)) (newline)) (define (report-subexps trap-context) (let ((step-trap (make #:file-name (frame-file-name (tc:frame trap-context)) #:behaviour report-exp))) (install-trap step-trap) (at-exit (tc:depth trap-context) (lambda (trap-context) (uninstall-trap step-trap))))) (install-trap (make #:procedure mkmatrix #:behaviour (list report-subexps))) For my dummy matrix.scm, this prints: Expression: matrix.scm:2:2 Expression: matrix.scm:3:20 Expression: matrix.scm:3:20 Does this help at all? (I suspect not completely, so please write more!) Neil _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user