1 ;;; -*- mode: scheme; coding: utf-8; -*-
3 ;;;; Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010
4 ;;;; Free Software Foundation, Inc.
6 ;;;; This library is free software; you can redistribute it and/or
7 ;;;; modify it under the terms of the GNU Lesser General Public
8 ;;;; License as published by the Free Software Foundation; either
9 ;;;; version 3 of the License, or (at your option) any later version.
11 ;;;; This library is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;;;; Lesser General Public License for more details.
16 ;;;; You should have received a copy of the GNU Lesser General Public
17 ;;;; License along with this library; if not, write to the Free Software
18 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 ;;; An older approack to debugging, in which the user installs a pre-unwind
26 ;;; handler that saves the stack at the time of the error. The last stack can
27 ;;; then be debugged later.
32 (define-module (ice-9 save-stack)
33 ;; Replace deprecated root-module bindings, if present.
34 #:replace (stack-saved?
38 ;; FIXME: stack-saved? is broken in the presence of threads.
39 (define stack-saved? #f)
41 (define the-last-stack (make-fluid))
43 (define (save-stack . narrowing)
44 (if (not stack-saved?)
46 (let ((stacks (fluid-ref %stacks)))
47 (fluid-set! the-last-stack
48 ;; (make-stack obj inner outer inner outer ...)
50 ;; In this case, cut away the make-stack frame, the
51 ;; save-stack frame, and then narrow as specified by the
52 ;; user, delimited by the nearest start-stack invocation,
56 (if (pair? stacks) (cdar stacks) 0)
58 (set! stack-saved? #t))))