1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-12 06:41:13 +02:00

make backtraces prettier

* module/system/vm/debug.scm (print-frames): Clean up a bit, reverting
  part of the previous change. (The problem was that in the else branch
  of the conditional, it didn't consume an arg.)

  In the future I would like to preserve the clean look of the
  backtraces. It's easier to read that way.
This commit is contained in:
Andy Wingo 2010-01-09 20:21:37 +01:00
parent 0af34a3f83
commit 8217c9251a

View file

@ -109,13 +109,6 @@
out out
(lp (frame-previous frame) (cons frame out) (1- count))))))) (lp (frame-previous frame) (cons frame out) (1- count)))))))
(define (location-string file line)
(cond ((and file line)
(format #f "~:[~5_~;~5d~]" file line))
(file
(format #f "~:[~5_~" file))
(else "<unknown-location>")))
(define* (print-frames frames #:optional (port (current-output-port)) (define* (print-frames frames #:optional (port (current-output-port))
#:key (start-index (1- (length frames))) (width 72) #:key (start-index (1- (length frames))) (width 72)
(full? #f)) (full? #f))
@ -124,17 +117,17 @@
(let* ((frame (car frames)) (let* ((frame (car frames))
(source (frame-source frame)) (source (frame-source frame))
(file (and source (file (and source
(or (source:file source) "<stdin>"))) (or (source:file source)
(line (and=> source source:line)) "current input")))
(loc (location-string file line))) (line (and=> source source:line)))
(if (not (equal? file last-file)) (if (and file (not (equal? file last-file)))
(format port "~&In ~a:~&" (or file "current input"))) (format port "~&In ~a:~&" file))
(format port "~a:~3d ~v:@y~%" (format port "~:[~*~6_~;~5d:~]~3d ~v:@y~%" line line
loc i width (frame-call-representation frame)) i width (frame-call-representation frame))
(if full? (if full?
(print-locals frame #:width width (print-locals frame #:width width
#:per-line-prefix " ")) #:per-line-prefix " "))
(lp (cdr frames) (1- i) file))))) (lp (cdr frames) (1- i) (or file last-file))))))
;;; ;;;