trc.scm 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ;;;; (ice-9 debugger trc) -- tracing for Guile debugger code
  2. ;;; Copyright (C) 2002, 2006 Free Software Foundation, Inc.
  3. ;;;
  4. ;; This library is free software; you can redistribute it and/or
  5. ;; modify it under the terms of the GNU Lesser General Public
  6. ;; License as published by the Free Software Foundation; either
  7. ;; version 2.1 of the License, or (at your option) any later version.
  8. ;;
  9. ;; This library is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. ;; Lesser General Public License for more details.
  13. ;;
  14. ;; You should have received a copy of the GNU Lesser General Public
  15. ;; License along with this library; if not, write to the Free Software
  16. ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. (define-module (ice-9 debugger trc)
  18. #:export (trc trc-syms trc-all trc-none trc-add trc-remove trc-port))
  19. (define *syms* #f)
  20. (define (trc-set! syms)
  21. (set! *syms* syms))
  22. (define (trc-syms . syms)
  23. (trc-set! syms))
  24. (define (trc-all)
  25. (trc-set! #f))
  26. (define (trc-none)
  27. (trc-set! '()))
  28. (define (trc-add sym)
  29. (trc-set! (cons sym *syms*)))
  30. (define (trc-remove sym)
  31. (trc-set! (delq1! sym *syms*)))
  32. (define (trc sym . args)
  33. (if (or (not *syms*)
  34. (memq sym *syms*))
  35. (let ((port (trc-port)))
  36. (write sym port)
  37. (display ":" port)
  38. (for-each (lambda (arg)
  39. (display " " port)
  40. (write arg port))
  41. args)
  42. (newline port))))
  43. (define trc-port
  44. (let ((port (current-error-port)))
  45. (make-procedure-with-setter
  46. (lambda () port)
  47. (lambda (p) (set! port p)))))
  48. ;; Default to no tracing.
  49. (trc-none)
  50. ;;; (ice-9 debugger trc) ends here.