summaryrefslogtreecommitdiff
path: root/module/system
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2023-12-28 12:21:03 +0100
committerLudovic Courtès <ludo@gnu.org>2023-12-28 12:24:02 +0100
commit7f26021c241f17bd363f0e78ed40fb4f270b12b5 (patch)
treef35b627aa7315c19f36c714be9c8c8ae5fd5ed85 /module/system
parentd8df317bafcdd9fcfebb636433c4871f2fab28b2 (diff)
downloadguile-7f26021c241f17bd363f0e78ed40fb4f270b12b5.tar.gz
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.
Diffstat (limited to 'module/system')
-rw-r--r--module/system/repl/debug.scm14
1 files changed, 12 insertions, 2 deletions
diff --git a/module/system/repl/debug.scm b/module/system/repl/debug.scm
index c83241340..8109fdb1c 100644
--- a/module/system/repl/debug.scm
+++ b/module/system/repl/debug.scm
@@ -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))