unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Neil Jerram <neil@ossau.uklinux.net>
Cc: guile-devel@gnu.org
Subject: Re: How can I enable tracing in a script?
Date: Wed, 09 Jun 2004 21:23:53 +0100	[thread overview]
Message-ID: <40C771D9.6090804@ossau.uklinux.net> (raw)
In-Reply-To: <87d64sif4f.fsf@offby1.atm01.sea.blarg.net>

[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

Eric Hanchrow wrote:

>(recent CVS guile)
>
>When I run the following script, I want to see something like 
>
>    [something 3]
>    |  [something 2]
>    |  |  [something 1]
>    |  |  |  [something 0]
>    |  |  |  0
>    |  |  1
>    |  3
>    6
>
>  
>
You're missing `with-traps'; see the attached script and output, which I 
produced with 1.6.4.

Neil


[-- Attachment #2: tr.scm --]
[-- Type: text/x-scheme, Size: 1106 bytes --]

#!/usr/bin/guile \
--debug -e main -s
!#

(use-modules (ice-9 debug))
(debug-enable 'trace)
(trace-stack #t)
;;(debug-enable 'backtrace)
;;(format #t "~s~%" (debug-options))
;;(format #t "~s~%" (traps))
;;(format #t "~s~%" (evaluator-traps-interface))
;;(format #t "~s~%" (list (@@(ice-9 debug)
;;                         trace-exit)
;;                        (@@(ice-9 debug) trace-entry)))
;;(evaluator-traps-interface `( exit-frame-handler ,(@@(ice-9 debug) trace-exit )))
;;(evaluator-traps-interface `(apply-frame-handler ,(@@(ice-9 debug) trace-entry)))
;;(format #t "~s~%" (evaluator-traps-interface))
;;
;;(format (current-error-port) "This message appears on the current error port.~%")
;;(format #t "traced-stack-ids: ~s~%" (@@(ice-9 debug) traced-stack-ids))
;;(format #t "trace-all-stacks? ~s~%" (@@(ice-9 debug) trace-all-stacks?))

(define (something arg)
  (if (not (positive? arg))
      0
    (+ arg (something (- arg 1)))))

(define (main . args)
;;  (trace something)
  (something (string->number (list-ref (car args) 1))))

(trace something)
(with-traps
 (lambda ()
   (something 9)))


[-- Attachment #3: output.txt --]
[-- Type: text/plain, Size: 782 bytes --]

[something 9]
|  [something 8]
|  |  [something 7]
|  |  |  [something 6]
|  |  |  |  [something 5]
|  |  |  |  |  [something 4]
|  |  |  |  |  |  [something 3]
|  |  |  |  |  |  |  [something 2]
|  |  |  |  |  |  |  |  [something 1]
|  |  |  |  |  |  |  |  |  [something 0]
|  |  |  |  |  |  |  |  |  0
|  |  |  |  |  |  |  |  1
|  |  |  |  |  |  |  3
|  |  |  |  |  |  6
|  |  |  |  |  10
|  |  |  |  15
|  |  |  21
|  |  28
|  36
45
Backtrace:
In unknown file:
   ?: 0* (begin (load "./tr.scm") (main (command-line)) (quit))
   ?: 1* [main ("./tr.scm")]
In ./tr.scm:
  30: 2  [something ...
  30: 3*  [string->number ...
  30: 4*   [list-ref ("./tr.scm") 1]

./tr.scm:30:30: In procedure list-ref in expression (list-ref (car args) 1):
./tr.scm:30:30: Argument 2 out of range: 1

[-- Attachment #4: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

      reply	other threads:[~2004-06-09 20:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-25 17:35 How can I enable tracing in a script? Eric Hanchrow
2004-06-09 20:23 ` Neil Jerram [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=40C771D9.6090804@ossau.uklinux.net \
    --to=neil@ossau.uklinux.net \
    --cc=guile-devel@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).