]> git.donarmstrong.com Git - lilypond.git/blob - guile18/ice-9/debugging/steps.scm
Import guile-1.8 as multiple upstream tarball component
[lilypond.git] / guile18 / ice-9 / debugging / steps.scm
1 ;;;; (ice-9 debugging steps) -- stepping through code from the debugger
2
3 ;;; Copyright (C) 2002, 2004 Free Software Foundation, Inc.
4 ;;;
5 ;; This library is free software; you can redistribute it and/or
6 ;; modify it under the terms of the GNU Lesser General Public
7 ;; License as published by the Free Software Foundation; either
8 ;; version 2.1 of the License, or (at your option) any later version.
9 ;; 
10 ;; This library is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ;; Lesser General Public License for more details.
14 ;; 
15 ;; You should have received a copy of the GNU Lesser General Public
16 ;; License along with this library; if not, write to the Free Software
17 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 (define-module (ice-9 debugging steps)
20   #:use-module (ice-9 debugging traps)
21   #:use-module (ice-9 and-let-star)
22   #:use-module (ice-9 debugger)
23   #:use-module (ice-9 optargs)
24   #:export (at-exit
25             at-entry
26             at-apply
27             at-step
28             at-next))
29
30 ;;; at-exit DEPTH BEHAVIOUR
31 ;;;
32 ;;; Install a behaviour to run when we exit the current frame.
33
34 (define (at-exit depth behaviour)
35   (install-trap (make <exit-trap>
36                   #:depth depth
37                   #:single-shot #t
38                   #:behaviour behaviour)))
39
40 ;;; at-entry BEHAVIOUR [COUNT]
41 ;;;
42 ;;; Install a behaviour to run when we get to the COUNT'th next frame
43 ;;; entry.  COUNT defaults to 1.
44
45 (define* (at-entry behaviour #:optional (count 1))
46   (install-trap (make <entry-trap>
47                   #:skip-count (- count 1)
48                   #:single-shot #t
49                   #:behaviour behaviour)))
50
51 ;;; at-apply BEHAVIOUR [COUNT]
52 ;;;
53 ;;; Install a behaviour to run when we get to the COUNT'th next
54 ;;; application.  COUNT defaults to 1.
55
56 (define* (at-apply behaviour #:optional (count 1))
57   (install-trap (make <apply-trap>
58                   #:skip-count (- count 1)
59                   #:single-shot #t
60                   #:behaviour behaviour)))
61
62 ;;; at-step BEHAVIOUR [COUNT [FILENAME [DEPTH]]
63 ;;;
64 ;;; Install BEHAVIOUR to run on the COUNT'th next application, frame
65 ;;; entry or frame exit.  COUNT defaults to 1.  If FILENAME is
66 ;;; specified and not #f, only frames that begin in the named file are
67 ;;; counted.
68
69 (define* (at-step behaviour #:optional (count 1) filename (depth 1000))
70   (install-trap (make <step-trap>
71                   #:file-name filename
72                   #:exit-depth depth
73                   #:skip-count (- count 1)
74                   #:single-shot #t
75                   #:behaviour behaviour)))
76
77 ;;  (or count (set! count 1))
78 ;;  (letrec ((proc (lambda (trap-context)
79 ;;                 ;; Behaviour whenever we enter or exit a frame.
80 ;;                 (set! count (- count 1))
81 ;;                 (if (= count 0)
82 ;;                     (begin
83 ;;                       (remove-enter-frame-hook! step)
84 ;;                       (remove-apply-frame-hook! step)
85 ;;                       (behaviour trap-context)))))
86 ;;         (step (lambda (trap-context)
87 ;;                 ;; Behaviour on frame entry: both execute the above
88 ;;                 ;; and install it as an exit hook.
89 ;;                 (if (or (not filename)
90 ;;                         (equal? (frame-file-name (tc:frame trap-context))
91 ;;                                   filename))
92 ;;                     (begin
93 ;;                       (proc trap-context)
94 ;;                       (at-exit (tc:depth trap-context) proc))))))
95 ;;    (at-exit depth proc)
96 ;;    (add-enter-frame-hook! step)
97 ;;    (add-apply-frame-hook! step)))
98
99 ;;; at-next BEHAVIOUR [COUNT]
100 ;;;
101 ;;; Install a behaviour to run when we get to the COUNT'th next frame
102 ;;; entry in the same source file as the current location.  COUNT
103 ;;; defaults to 1.  If the current location has no filename, fall back
104 ;;; silently to `at-entry' behaviour.
105
106 ;;; (ice-9 debugging steps) ends here.