From 8217c9251acef6f09fa04e1ead5eaa69b6909284 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sat, 9 Jan 2010 20:21:37 +0100 Subject: [PATCH] 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. --- module/system/vm/debug.scm | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/module/system/vm/debug.scm b/module/system/vm/debug.scm index 1b8afe2d9..ffb54b729 100644 --- a/module/system/vm/debug.scm +++ b/module/system/vm/debug.scm @@ -109,13 +109,6 @@ out (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 ""))) - (define* (print-frames frames #:optional (port (current-output-port)) #:key (start-index (1- (length frames))) (width 72) (full? #f)) @@ -124,17 +117,17 @@ (let* ((frame (car frames)) (source (frame-source frame)) (file (and source - (or (source:file source) ""))) - (line (and=> source source:line)) - (loc (location-string file line))) - (if (not (equal? file last-file)) - (format port "~&In ~a:~&" (or file "current input"))) - (format port "~a:~3d ~v:@y~%" - loc i width (frame-call-representation frame)) + (or (source:file source) + "current input"))) + (line (and=> source source:line))) + (if (and file (not (equal? file last-file))) + (format port "~&In ~a:~&" file)) + (format port "~:[~*~6_~;~5d:~]~3d ~v:@y~%" line line + i width (frame-call-representation frame)) (if full? (print-locals frame #:width width #:per-line-prefix " ")) - (lp (cdr frames) (1- i) file))))) + (lp (cdr frames) (1- i) (or file last-file)))))) ;;;