unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Thompson, David" <dthompson2@worcester.edu>
To: Carlos Pita <carlosjosepita@gmail.com>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: Entering the interactive debugger
Date: Tue, 2 Sep 2014 15:57:03 -0400	[thread overview]
Message-ID: <CAJ=Rwfa1qnXQxXrLzYqMSYauN70STkPUEsBWpPDgnk4eqHxfoQ@mail.gmail.com> (raw)
In-Reply-To: <CAJ=RwfaBjssxqdO_Z2-oyQGJegn0FCrv8AK2NVQEg9HeoN9cUQ@mail.gmail.com>

On Tue, Sep 2, 2014 at 3:20 PM, Thompson, David
<dthompson2@worcester.edu> wrote:
> On Tue, Sep 2, 2014 at 3:03 PM, Carlos Pita <carlosjosepita@gmail.com> 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



  reply	other threads:[~2014-09-02 19:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-02 19:03 Entering the interactive debugger Carlos Pita
2014-09-02 19:20 ` Thompson, David
2014-09-02 19:57   ` Thompson, David [this message]
2014-09-02 20:14   ` Taylan Ulrich Bayirli/Kammer
2014-09-03  2:08     ` Carlos Pita
2014-09-05 13:57       ` mhw

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='CAJ=Rwfa1qnXQxXrLzYqMSYauN70STkPUEsBWpPDgnk4eqHxfoQ@mail.gmail.com' \
    --to=dthompson2@worcester.edu \
    --cc=carlosjosepita@gmail.com \
    --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).