unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* How can I enable tracing in a script?
@ 2004-05-25 17:35 Eric Hanchrow
  2004-06-09 20:23 ` Neil Jerram
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Hanchrow @ 2004-05-25 17:35 UTC (permalink / raw)



(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

which is what I see when I use the REPL to define `something', and
invoke it.  But I don't.  Am I misunderstanding something?  (Note that
I don't really believe all the cruft in this script is necessary; I
was merely throwing in everything I could think of to get tracing to
work)

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

    (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))))
    ;(something 9)

-- 
But users will not now with glad cries glom on to a language that
gives them no more than what Scheme or Pascal gave them.

        -- Guy Steele, http://www.sun.com/research/jtech/pubs/98-oopsla-growing.ps



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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How can I enable tracing in a script?
  2004-05-25 17:35 How can I enable tracing in a script? Eric Hanchrow
@ 2004-06-09 20:23 ` Neil Jerram
  0 siblings, 0 replies; 2+ messages in thread
From: Neil Jerram @ 2004-06-09 20:23 UTC (permalink / raw)
  Cc: guile-devel

[-- 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-06-09 20:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-25 17:35 How can I enable tracing in a script? Eric Hanchrow
2004-06-09 20:23 ` Neil Jerram

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).