[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Entering the interactive debugger
From: |
Thompson, David |
Subject: |
Re: Entering the interactive debugger |
Date: |
Tue, 2 Sep 2014 15:57:03 -0400 |
On Tue, Sep 2, 2014 at 3:20 PM, Thompson, David
<address@hidden> wrote:
> On Tue, Sep 2, 2014 at 3:03 PM, Carlos Pita <address@hidden> wrote:
>> Hi all, although I have some experience with lisps, I'm still new to
>> guile and I'm having some trouble figuring out how to invoke the
>> interactive debugger at some arbitrary point in my code. Something like:
>>
>> ; code here
>> (debug)
>> ; more code here
>>
>> The closer solution I could find in the manual is:
>>
>> add-trap-at-source-location! file user-line
>>
>> Any suggestion?
>
> I don't know of any straightforward solution, but I would also like
> such a feature. I don't think it would be too difficult to write a
> 'debug' procedure using the 'debug-trap-handler' procedure in (system
> repl error-handling) as inspiration. Basically, you'd need to capture
> the current stack and spawn a new REPL in debug mode that uses that
> stack.
>
The stack isn't properly narrowed because I couldn't figure out how to
make narrow-stack->vector do what I wanted, but here's a 'debug'
procedure that worked for me.
(use-modules (system repl repl)
(system repl debug))
(define (debug)
(let ((stack (narrow-stack->vector (make-stack #t))))
(start-repl #:debug (make-debug stack 0 "Entered debugger" #f))))
- Dave