1 ;;;; (ice-9 debugging steps) -- stepping through code from the debugger
3 ;;; Copyright (C) 2002, 2004 Free Software Foundation, Inc.
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.
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.
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
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)
30 ;;; at-exit DEPTH BEHAVIOUR
32 ;;; Install a behaviour to run when we exit the current frame.
34 (define (at-exit depth behaviour)
35 (install-trap (make <exit-trap>
38 #:behaviour behaviour)))
40 ;;; at-entry BEHAVIOUR [COUNT]
42 ;;; Install a behaviour to run when we get to the COUNT'th next frame
43 ;;; entry. COUNT defaults to 1.
45 (define* (at-entry behaviour #:optional (count 1))
46 (install-trap (make <entry-trap>
47 #:skip-count (- count 1)
49 #:behaviour behaviour)))
51 ;;; at-apply BEHAVIOUR [COUNT]
53 ;;; Install a behaviour to run when we get to the COUNT'th next
54 ;;; application. COUNT defaults to 1.
56 (define* (at-apply behaviour #:optional (count 1))
57 (install-trap (make <apply-trap>
58 #:skip-count (- count 1)
60 #:behaviour behaviour)))
62 ;;; at-step BEHAVIOUR [COUNT [FILENAME [DEPTH]]
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
69 (define* (at-step behaviour #:optional (count 1) filename (depth 1000))
70 (install-trap (make <step-trap>
73 #:skip-count (- count 1)
75 #:behaviour behaviour)))
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))
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))
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)))
99 ;;; at-next BEHAVIOUR [COUNT]
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.
106 ;;; (ice-9 debugging steps) ends here.