1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 19:50:24 +02:00

debug: Print wider stack frames when not writing to a tty.

This satisfies a longstanding complaint that Guile backtraces were being
truncated too much by default (72 columns), often hindering debugging.

* module/system/repl/debug.scm (default-frame-width): New variable.
(print-frames): Change default #:width value depending on whether PORT
is a tty.
This commit is contained in:
Ludovic Courtès 2023-12-28 12:21:03 +01:00
parent d8df317baf
commit 7f26021c24
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -1,6 +1,6 @@
;;; Guile VM debugging facilities
;;; Copyright (C) 2001, 2009, 2010, 2011, 2013, 2014, 2015 Free Software Foundation, Inc.
;;; Copyright (C) 2001, 2009-2011, 2013-2015, 2023 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
@ -29,6 +29,7 @@
make-debug debug?
debug-frames debug-index debug-error-message
terminal-width
default-frame-width
print-registers print-locals print-frame print-frames
stack->vector narrow-stack->vector
frame->stack-vector))
@ -71,6 +72,11 @@
(fluid-set! set-width w)
(error "Expected a column number (a positive integer)" w))))))
(define default-frame-width
;; Maximum number of columns filled by 'print-frames' when writing to
;; a port that is not a terminal. This is a purposefully large value
;; to avoid losing important debugging info.
(make-fluid 500))
@ -139,7 +145,11 @@
(define* (print-frames frames
#:optional (port (current-output-port))
#:key (width (terminal-width)) (full? #f)
#:key
(width (if (isatty? port)
(terminal-width)
(fluid-ref default-frame-width)))
(full? #f)
(forward? #f) count)
(let* ((len (vector-length frames))
(lower-idx (if (or (not count) (positive? count))