From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Catonano Newsgroups: gmane.lisp.guile.user Subject: Re: Stack traces Date: Sat, 10 Jun 2017 11:58:23 +0200 Message-ID: References: <87h93wto3y.fsf_-_@gnu.org> <87mvdn4gam.fsf@dustycloud.org> <641f554a-3672-d71a-78cd-f32f5287f98d@hypermove.net> <34F40DF4-899A-4400-A2F6-820EFB3C66FD@gmail.com> <87efyjqt6c.fsf@pobox.com> <87vaoy709i.fsf@dustycloud.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1497088729 20420 195.159.176.226 (10 Jun 2017 09:58:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 10 Jun 2017 09:58:49 +0000 (UTC) Cc: Andy Wingo , guile-user@gnu.org, Matt Wette To: Christopher Allan Webber Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jun 10 11:58:45 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dJdAL-00053A-Mg for guile-user@m.gmane.org; Sat, 10 Jun 2017 11:58:45 +0200 Original-Received: from localhost ([::1]:57818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJdAP-0008FW-BU for guile-user@m.gmane.org; Sat, 10 Jun 2017 05:58:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJdA2-0008FQ-TV for guile-user@gnu.org; Sat, 10 Jun 2017 05:58:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJdA1-0008UJ-FY for guile-user@gnu.org; Sat, 10 Jun 2017 05:58:26 -0400 Original-Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:36325) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dJdA1-0008UC-4n for guile-user@gnu.org; Sat, 10 Jun 2017 05:58:25 -0400 Original-Received: by mail-wr0-x234.google.com with SMTP id v111so53657236wrc.3 for ; Sat, 10 Jun 2017 02:58:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=E8QUbBZmT96g0vMET+QEItlca0NpG3zgz88Fr/I0Xyk=; b=DDkeCi3vsGKp033X0UCY6b8U2VsXB1TIn1yN4SHkg7HYYyn2OJSursClz+O4T5gRoi FrlGWVHgh8wbGklT292t36tKshrc+I1vqB3mguKiqpAGwKA0778j6CD1Qx1xWishFqtk F7uZHVm9NtY3B7c4IZMiAvSBpmIWOhLrKSQb3Q0zuzDrSyrnuFYhICCNvJhLc+74x9tS GcFaar1FUFxXpRHZ4FOiRHbLFh3jeqJf0ItRFANPgA4sr/cRIw7WDRWueG5gfjlkbHlW rRGl2A4iqYdtYvMT0q362JxDYYzTr3XV6Eca14OY9cH6JEZFwmIij+whdAZaqAwKqYOY tJEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=E8QUbBZmT96g0vMET+QEItlca0NpG3zgz88Fr/I0Xyk=; b=ojUKiWqpy1/IUnux7Uh2sbVwXpg15xBubgysTpXUrU+R7l8OCIDLfehZStTx2OTEgO 0b6q4Jtd8nOdxH3HtgozzXJIPn9Os4d0D9HdT+rFY+Tv23Ac6Vktu7CcywgG4UMwmzM1 bJZ3xpRaauvK388LcyZo59wNEm6AJWA8IXrQwUAmAXd+RBUqoBSemaGgXzzuKb9dyGte osNbJiapzdEHGzz/ZUaHljsks/tVt/zeS7f3nzAjAezZYXzoJuq1gTgdl+76S3Jb6kSj hev1+N3a205mBBKj7OrpQZKwoUGVr1CvT7gQzbYLhyy3fj8FFzXy7cODVvTRZI/w2D0W ZedA== X-Gm-Message-State: AODbwcDOcKajqfNSQl8CoWl0Cj07BvDcQdVtcS3pUp4UAGjBTXO8Vx9I BWfqyFJWj5wrqTZTcevaz8k/QOo16w== X-Received: by 10.80.177.209 with SMTP id n17mr19389920edd.177.1497088704020; Sat, 10 Jun 2017 02:58:24 -0700 (PDT) Original-Received: by 10.80.131.4 with HTTP; Sat, 10 Jun 2017 02:58:23 -0700 (PDT) In-Reply-To: <87vaoy709i.fsf@dustycloud.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::234 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13798 Archived-At: 2017-05-18 15:38 GMT+02:00 Christopher Allan Webber : > Amirouche writes: > > > Le 27/02/2017 =C3=A0 21:23, Andy Wingo a =C3=A9crit : > >> On Sat 18 Feb 2017 20:59, Amirouche 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 =3D sum =3D 0 > $24 =3D vals =3D '(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