Scheme/Guile Debugging

the manual says “GDB support”

What’s interesting here is, that the GDB support goes both ways. You can utilize GDB to debug guile, but also use guile to extend GDB since v7.8 with guile by utilizing it for scripting or by starting a guile REPL from inside GDB. But be aware that most distributions that aren’t Guix disable guile support for GDB (at least Debian and Fedora do so).

the manual says “GDB support” and “sometimes you may need to debug at the C level”, whatever that means.

The manual is pretty sparse in these regards/I rarely use GDB support as in for debugging guile, not as in for extending GDB, as guiles breakpoint handling is enough for me in most situations.

In short, you could always:

(define (myunusefulfunction n)
  (display n)
  (myunusefulfunction (1+ n)))

set a breakpoint and get a backtrace:

scheme@(guile-user)> ,break myunusefulfunction 
Trap 0: Breakpoint at #<procedure myunusefulfunction (n)>.
scheme@(guile-user)> (myunusefulfunction 1)
Trap 0: Breakpoint at #<procedure myunusefulfunction (n)>
Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In current input:
      1:0  0 (myunusefulfunction 1)
scheme@(guile-user) [1]> ,q
1Trap 0: Breakpoint at #<procedure myunusefulfunction (n)>
Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In current input:
      1:0  0 (myunusefulfunction 2)

and all the other things one would expect from a debugger as well, e.g.:

scheme@(guile-user) [1]> ,up
Already at outermost frame.
scheme@(guile-user) [1]> ,down
Already at innermost frame.
scheme@(guile-user) [1]> ,frame
In current input:
      1:0  0 (myunusefulfunction 13)

frame navigation, accessing local variables with ,locals and so on.

1 Like