From: Neil Jerram <neil@ossau.uklinux.net>
Cc: guile-user@gnu.org
Subject: Re: guile-debugging: how to access source properties from trap context
Date: Mon, 02 Jan 2006 00:18:09 +0000 [thread overview]
Message-ID: <87vex3pjni.fsf@ossau.uklinux.net> (raw)
In-Reply-To: <20060101213351.GA5366@tosh> (Holger Blasum's message of "Sun, 1 Jan 2006 22:33:51 +0100")
Holger Blasum <holgerlists@blasum.net> 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-trap> #: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 <step-trap>
#: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-trap> #: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
next prev parent reply other threads:[~2006-01-02 0:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-01 21:33 guile-debugging: how to access source properties from trap context Holger Blasum
2006-01-02 0:18 ` Neil Jerram [this message]
2006-01-02 12:39 ` Neil Jerram
2006-01-02 22:33 ` Holger Blasum
2006-01-03 22:57 ` Neil Jerram
2006-01-07 16:54 ` Holger Blasum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vex3pjni.fsf@ossau.uklinux.net \
--to=neil@ossau.uklinux.net \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).