unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Catonano <catonano@gmail.com>
To: Christopher Allan Webber <cwebber@dustycloud.org>
Cc: Andy Wingo <wingo@pobox.com>,
	guile-user@gnu.org, Matt Wette <matt.wette@gmail.com>
Subject: Re: Stack traces
Date: Sat, 10 Jun 2017 11:58:23 +0200	[thread overview]
Message-ID: <CAJ98PDxeoijjDtw_VW_gvrHLwX2oGJ+nHoMgzbET1vhZWO0pSw@mail.gmail.com> (raw)
In-Reply-To: <87vaoy709i.fsf@dustycloud.org>

2017-05-18 15:38 GMT+02:00 Christopher Allan Webber <cwebber@dustycloud.org>
:

> Amirouche writes:
>
> > Le 27/02/2017 à 21:23, Andy Wingo a écrit :
> >> On Sat 18 Feb 2017 20:59, Amirouche <amirouche@hypermove.net> writes:
> >>
> >>> How do you access variables in the REPL?
> >> ,locals
> >>
> >> Andy
> > It doesn't display something that I can use.
>
> (Returning to this few-months-old thread...)
>
> Yes, I frequently find that ,locals does not display much
> information... it seems to be a toss-up whether the variables I need
> will be contained in it, so I've reduced the amount I use the actual
> debugger system in Guile a lot.  A shame, because it seems really nice.
>
> Because of this, I think I do what a lot of Guile hackers do (which is
> totally undocumented in the manual, so only people who have been hanging
> around with someoen else who knows tend to know about it), which is to
> use (pk) everywhere.  It's not as nice as being able to play with local
> variables at the REPL though!
>
> Matt's example from earlier in the thread seems simple enough... as a
> recap:
>
> (use-modules (system repl repl))
> (use-modules (system repl debug))
>
> (define-syntax-rule (trap-here)
>   (start-repl
>    #:debug (make-debug (stack->vector (make-stack #t)) 0 "trap!" #t)))
>
> (define (foo)
>   (let iter ((sum 0) (vals '(1 2 3 5 8 2)))
>     (trap-here)
>     (if (null? vals) sum
>         (iter (+ sum (car vals)) (cdr vals)))))
>
> (foo)
>
> Looking at that, I would *think* that at minimum, sum and vals would be
> available when I run ,locals.  I couldn't understand why they weren't:
>
> scheme@(guile-user)> (foo)
> scheme@(guile-user) [1]> ,locals
>   No local variables.
>
> But then I ran ,optimize, and that made it obvious what's happening:
>
> (define (foo)
>   (start-repl
>     #:debug
>     (make-debug
>       (stack->vector (make-stack #t))
>       0
>       "trap!"
>       #t))
>   (start-repl
>     #:debug
>     (make-debug
>       (stack->vector (make-stack #t))
>       0
>       "trap!"
>       #t))
>   (start-repl
>     #:debug
>     (make-debug
>       (stack->vector (make-stack #t))
>       0
>       "trap!"
>       #t))
>   (start-repl
>     #:debug
>     (make-debug
>       (stack->vector (make-stack #t))
>       0
>       "trap!"
>       #t))
>   (start-repl
>     #:debug
>     (make-debug
>       (stack->vector (make-stack #t))
>       0
>       "trap!"
>       #t))
>   (start-repl
>     #:debug
>     (make-debug
>       (stack->vector (make-stack #t))
>       0
>       "trap!"
>       #t))
>   (start-repl
>     #:debug
>     (make-debug
>       (stack->vector (make-stack #t))
>       0
>       "trap!"
>       #t))
>   21)
>
> Ah... the compiler was being so smart that it did all the work up front
> already! ;) Pretty cool from a performance and optimization perspective
> (I'm still floored that Guile is able to do optimizations like that!),
> but it's not as helpful from a debugging perspective maybe?
>
> Maybe there could be a way to do something like this:
>
> scheme@(guile-user)> ,optimize-less
> ;;; * user re-evaluates code they want to debug *
> scheme@(guile-user)> (foo)
> scheme@(guile-user) [1]> ,locals
>   Local variables:
>   $23 = sum = 0
>   $24 = vals = '(1 2 3 5 8 2)
> scheme@(guile-user) [1]> ,q
> ;;; User has done debugging
> scheme@(guile-user)> ,optimize-more
> ;;; User can now re-evaluate their code with all the optimizations in
> ;;; place!
> scheme@(guile-user)>
>
> Thoughts?
>  - Chris
>
>

This is an extremely informative message, per se. Precious insights

Thanks


      parent reply	other threads:[~2017-06-10  9:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.52572.1487077879.22737.guile-user@gnu.org>
2017-02-14 17:24 ` guile-user Digest, Vol 171, Issue 14 Cecil McGregor
2017-02-14 19:19   ` Christopher Allan Webber
2017-02-14 22:00   ` Amirouche
2017-02-14 22:16   ` Stack traces Ludovic Courtès
2017-02-15 15:36     ` Christopher Allan Webber
2017-02-16  1:10       ` Matt Wette
2017-02-18  0:13       ` Matt Wette
2017-02-18 15:50         ` Amirouche
2017-02-18 15:53           ` Amirouche
2017-02-18 16:58             ` Matt Wette
2017-02-18 19:59               ` Amirouche
2017-02-18 20:31                 ` Matt Wette
2017-02-27 20:23                 ` Andy Wingo
2017-02-27 20:40                   ` Amirouche
2017-05-18 13:38                     ` Christopher Allan Webber
2017-05-19  3:05                       ` Matt Wette
2017-05-19  9:17                       ` Andy Wingo
2017-06-10  9:58                       ` Catonano [this message]

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=CAJ98PDxeoijjDtw_VW_gvrHLwX2oGJ+nHoMgzbET1vhZWO0pSw@mail.gmail.com \
    --to=catonano@gmail.com \
    --cc=cwebber@dustycloud.org \
    --cc=guile-user@gnu.org \
    --cc=matt.wette@gmail.com \
    --cc=wingo@pobox.com \
    /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).