guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tracepoints, source breakpoints


From: Andy Wingo
Subject: tracepoints, source breakpoints
Date: Fri, 24 Sep 2010 17:35:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hi,

I have (re-)implemented tracepoints in Guile, which print out when a
procedure is called.

    scheme@(guile-user)> ,tracepoint resolve-module
    Trap 0: Tracepoint at #<procedure b038e0 at ice-9/boot-9.scm:2234:4 (name 
#:optional autoload version #:key ensure)>.
    scheme@(guile-user)> (use-modules (ice-9 popen))
    Trap 0: (#<procedure b038e0 at ice-9/boot-9.scm:2234:4 (name #:optional...> 
#)
    Trap 0: #<module (guile) 9fde10>
    Trap 0: (#<procedure b038e0 at ice-9/boot-9.scm:2234:4 (name #:optional...> 
#)
    Trap 0: #<module (guile) 9fde10>
    Trap 0: (#<procedure b038e0 at ice-9/boot-9.scm:2234:4 (name #:optional...> 
...)
    Trap 0: #<directory (ice-9 popen) 12d8bd0>
    scheme@(guile-user)> (define (fibo n)
    ... (if (< n 2)
    ... 1
    ... (+ (fibo (- n 1))
    ... (fibo (- n 2)))))
    scheme@(guile-user)> ,tracepoint fibo
    Trap 1: Tracepoint at #<procedure fibo (n)>.
    scheme@(guile-user)> (fibo 4)
    Trap 1: (fibo 4)
    Trap 1: |(fibo 3)
    Trap 1: ||(fibo 2)
    Trap 1: |||(fibo 1)
    Trap 1: |||1
    Trap 1: |||(fibo 0)
    Trap 1: |||1
    Trap 1: ||2
    Trap 1: ||(fibo 1)
    Trap 1: ||1
    Trap 1: |3
    Trap 1: |(fibo 2)
    Trap 1: ||(fibo 1)
    Trap 1: ||1
    Trap 1: ||(fibo 0)
    Trap 1: ||1
    Trap 1: |2
    Trap 1: 5
    $1 = 5

Tracepoints and breakpoints are "traps", which can enabled and disabled
and listed with the "enable", "disable", "delete", and "traps" REPL
meta-commands.

I can also break at source locations now:

    scheme@(guile-user)> ,break-at-source "ice-9/boot-9.scm" 2242
    Trap 2: Breakpoint at ice-9/boot-9.scm:2242.
    scheme@(guile-user)> (resolve-module '(ice-9 popen))
    Trap 0: (#<procedure b038e0 at ice-9/boot-9.scm:2234:4 (name #:optional...> 
#)
    Trap 2: Breakpoint at ice-9/boot-9.scm:2242
    Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
    scheme@(guile-user) [1]> ,bt
    In ice-9/boot-9.scm:
      2242:14  0 (#<procedure b038e0 at ice-9/boot-9.scm:2234:4 (na...> ...)
    scheme@(guile-user) [1]> ,q
    Trap 0: #<directory (ice-9 popen) 12d8bd0>
    $2 = #<directory (ice-9 popen) 12d8bd0>

Here we see that tracepoints and breakpoints interoperate well.

The next step is to implement "step", "next", and "finish" commands, and
after that I'm going to stop work on the debugger, I think. There's
already a lot of documentation to update :P

Happy hacking,

Andy
-- 
http://wingolog.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]