mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
deprecate save-stack, stack-saved?
* module/Makefile.am: * module/ice-9/boot-9.scm: * module/ice-9/save-stack.scm (stack-saved?, save-stack): Move these bindings to their own module. * module/oop/goops.scm (goops-error): * module/ice-9/boot-9.scm (error, top-repl): Remove calls to save-stack. * module/ice-9/deprecated.scm (stack-saved?, save-stack): Add deprecated shims. * module/ice-9/emacs.scm: * module/ice-9/stack-catch.scm: * module/ice-9/debugger/command-loop.scm: * module/ice-9/scm-style-repl.scm: Import (ice-9 save-stack).
This commit is contained in:
parent
bfccdcd530
commit
d8158b837e
9 changed files with 86 additions and 26 deletions
|
@ -210,6 +210,7 @@ ICE_9_SOURCES = \
|
|||
ice-9/rw.scm \
|
||||
ice-9/safe-r5rs.scm \
|
||||
ice-9/safe.scm \
|
||||
ice-9/save-stack.scm \
|
||||
ice-9/scm-style-repl.scm \
|
||||
ice-9/session.scm \
|
||||
ice-9/slib.scm \
|
||||
|
|
|
@ -856,10 +856,8 @@ If there is no handler at all, Guile prints an error and then exits."
|
|||
(define error
|
||||
(case-lambda
|
||||
(()
|
||||
(save-stack)
|
||||
(scm-error 'misc-error #f "?" #f #f))
|
||||
((message . args)
|
||||
(save-stack)
|
||||
(let ((msg (string-join (cons "~A" (make-list (length args) "~S")))))
|
||||
(scm-error 'misc-error #f msg (cons message args) #f)))))
|
||||
|
||||
|
@ -2690,25 +2688,6 @@ module '(ice-9 q) '(make-q q-length))}."
|
|||
(restore-signals))
|
||||
|
||||
;;(define the-last-stack (make-fluid)) Defined by scm_init_backtrace ()
|
||||
;; FIXME: stack-saved? is broken in the presence of threads.
|
||||
(define stack-saved? #f)
|
||||
|
||||
(define (save-stack . narrowing)
|
||||
(if (not stack-saved?)
|
||||
(begin
|
||||
(let ((stacks (fluid-ref %stacks)))
|
||||
(fluid-set! the-last-stack
|
||||
;; (make-stack obj inner outer inner outer ...)
|
||||
;;
|
||||
;; In this case, cut away the make-stack frame, the
|
||||
;; save-stack frame, and then narrow as specified by the
|
||||
;; user, delimited by the nearest start-stack invocation,
|
||||
;; if any.
|
||||
(apply make-stack #t
|
||||
2
|
||||
(if (pair? stacks) (cdar stacks) 0)
|
||||
narrowing)))
|
||||
(set! stack-saved? #t))))
|
||||
|
||||
(define (quit . args)
|
||||
(apply throw 'quit args))
|
||||
|
@ -3438,7 +3417,6 @@ module '(ice-9 q) '(make-q q-length))}."
|
|||
(lambda ()
|
||||
(let ((make-handler (lambda (msg)
|
||||
(lambda (sig)
|
||||
(save-stack 2)
|
||||
(scm-error 'signal
|
||||
#f
|
||||
msg
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#:use-module (ice-9 debugger)
|
||||
#:use-module (ice-9 debugger state)
|
||||
#:use-module (ice-9 debugging traps)
|
||||
#:use-module (ice-9 save-stack)
|
||||
#:export (debugger-command-loop
|
||||
debugger-command-loop-error
|
||||
debugger-command-loop-quit)
|
||||
|
|
|
@ -59,7 +59,9 @@
|
|||
repl
|
||||
pre-unwind-handler-dispatch
|
||||
default-pre-unwind-handler
|
||||
handle-system-error)
|
||||
handle-system-error
|
||||
stack-saved?
|
||||
save-stack)
|
||||
|
||||
#:replace (module-ref-submodule module-define-submodule!))
|
||||
|
||||
|
@ -637,3 +639,23 @@ the `(system repl common)' module.")
|
|||
"`handle-system-error' is deprecated. Use it from
|
||||
`(ice-9 scm-style-repl)' if you need it.")
|
||||
(apply (@ (ice-9 scm-style-repl) handle-system-error) key args))
|
||||
|
||||
(define-syntax stack-saved?
|
||||
(make-variable-transformer
|
||||
(lambda (x)
|
||||
(issue-deprecation-warning
|
||||
"`stack-saved?' is deprecated. Use it from
|
||||
`(ice-9 save-stack)' if you need it.")
|
||||
(syntax-case x (set!)
|
||||
((set! id val)
|
||||
(identifier? #'id)
|
||||
#'(set! (@ (ice-9 save-stack) stack-saved?) val))
|
||||
(id
|
||||
(identifier? #'id)
|
||||
#'(@ (ice-9 save-stack) stack-saved?))))))
|
||||
|
||||
(define (save-stack . args)
|
||||
(issue-deprecation-warning
|
||||
"`save-stack' is deprecated. Use it from `(ice-9 save-stack)' if you need
|
||||
it.")
|
||||
(apply (@ (ice-9 save-stack) save-stack) args))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
;;;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2006, 2009 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2006, 2009, 2010 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -32,6 +32,7 @@
|
|||
:use-module (ice-9 debug)
|
||||
:use-module (ice-9 threads)
|
||||
:use-module (ice-9 session)
|
||||
:use-module (ice-9 save-stack)
|
||||
:no-backtrace)
|
||||
|
||||
(define emacs-escape-character #\sub)
|
||||
|
|
55
module/ice-9/save-stack.scm
Normal file
55
module/ice-9/save-stack.scm
Normal file
|
@ -0,0 +1,55 @@
|
|||
;;; -*- mode: scheme; coding: utf-8; -*-
|
||||
|
||||
;;;; Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010
|
||||
;;;; Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;;; License as published by the Free Software Foundation; either
|
||||
;;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;;
|
||||
;;;; This library is distributed in the hope that it will be useful,
|
||||
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;;;; Lesser General Public License for more details.
|
||||
;;;;
|
||||
;;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;;; License along with this library; if not, write to the Free Software
|
||||
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
;;;;
|
||||
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; An older approack to debugging, in which the user installs a pre-unwind
|
||||
;;; handler that saves the stack at the time of the error. The last stack can
|
||||
;;; then be debugged later.
|
||||
;;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define-module (ice-9 save-stack)
|
||||
;; Replace deprecated root-module bindings, if present.
|
||||
#:replace (stack-saved?
|
||||
save-stack))
|
||||
|
||||
;; FIXME: stack-saved? is broken in the presence of threads.
|
||||
(define stack-saved? #f)
|
||||
|
||||
(define (save-stack . narrowing)
|
||||
(if (not stack-saved?)
|
||||
(begin
|
||||
(let ((stacks (fluid-ref %stacks)))
|
||||
(fluid-set! the-last-stack
|
||||
;; (make-stack obj inner outer inner outer ...)
|
||||
;;
|
||||
;; In this case, cut away the make-stack frame, the
|
||||
;; save-stack frame, and then narrow as specified by the
|
||||
;; user, delimited by the nearest start-stack invocation,
|
||||
;; if any.
|
||||
(apply make-stack #t
|
||||
2
|
||||
(if (pair? stacks) (cdar stacks) 0)
|
||||
narrowing)))
|
||||
(set! stack-saved? #t))))
|
|
@ -17,6 +17,8 @@
|
|||
;;;;
|
||||
|
||||
(define-module (ice-9 scm-style-repl)
|
||||
#:use-module (ice-9 save-stack)
|
||||
|
||||
#:export (scm-repl-silent
|
||||
scm-repl-print-unspecified
|
||||
scm-repl-verbose
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
;;;;
|
||||
|
||||
(define-module (ice-9 stack-catch)
|
||||
#:use-module (ice-9 save-stack)
|
||||
#:export (stack-catch))
|
||||
|
||||
(define (stack-catch key thunk handler)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; installed-scm-file
|
||||
|
||||
;;;; Copyright (C) 1998,1999,2000,2001,2002, 2003, 2006, 2009 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 1998,1999,2000,2001,2002, 2003, 2006, 2009, 2010 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -105,7 +105,6 @@
|
|||
;; goops-error
|
||||
;;
|
||||
(define (goops-error format-string . args)
|
||||
(save-stack)
|
||||
(scm-error 'goops-error #f format-string args '()))
|
||||
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue