civodul pushed a commit to branch main in repository guile. commit 7f26021c241f17bd363f0e78ed40fb4f270b12b5 Author: Ludovic Courtès <l...@gnu.org> AuthorDate: Thu Dec 28 12:21:03 2023 +0100
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. --- module/system/repl/debug.scm | 14 ++++++++++++-- 1 file 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))