summaryrefslogtreecommitdiff
path: root/module/system/repl/debug.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-10-12 13:24:46 +0200
committerAndy Wingo <wingo@pobox.com>2010-10-12 13:24:46 +0200
commit5aa12c699c126e5880649223dba94e6b0ef730b9 (patch)
tree78b0da92470f5066dc1e2e4e2a957f357eff354d /module/system/repl/debug.scm
parent5414d33376e7759dfc5e4e35d32b5c8cf2452930 (diff)
downloadguile-5aa12c699c126e5880649223dba94e6b0ef730b9.tar.gz
,frame and related commands handle for-trap? appropriately
* module/system/repl/debug.scm (print-frame): Add #:next-source? arg, for when print-frame should use frame-next-source instead of frame-source. (print-frames): Add #:for-trap? arg. If true, the 0th frame should be printed with frame-next-source. * module/system/repl/command.scm (define-stack-command): Introduce for-trap? into the lexical env. (backtrace, up, down, frame): Update to do the right thing regarding #:for-trap?.
Diffstat (limited to 'module/system/repl/debug.scm')
-rw-r--r--module/system/repl/debug.scm16
1 files changed, 11 insertions, 5 deletions
diff --git a/module/system/repl/debug.scm b/module/system/repl/debug.scm
index 61ecf84bb..46ea6b4db 100644
--- a/module/system/repl/debug.scm
+++ b/module/system/repl/debug.scm
@@ -99,12 +99,13 @@
(frame-bindings frame))))))
(define* (print-frame frame #:optional (port (current-output-port))
- #:key index (width 72) (full? #f) (last-source #f))
+ #:key index (width 72) (full? #f) (last-source #f)
+ next-source?)
(define (source:pretty-file source)
(if source
(or (source:file source) "current input")
"unknown file"))
- (let* ((source (frame-source frame))
+ (let* ((source ((if next-source? frame-next-source frame-source) frame))
(file (source:pretty-file source))
(line (and=> source source:line-for-user))
(col (and=> source source:column)))
@@ -119,7 +120,8 @@
(define* (print-frames frames
#:optional (port (current-output-port))
- #:key (width 72) (full? #f) (forward? #f) count)
+ #:key (width 72) (full? #f) (forward? #f) count
+ for-trap?)
(let* ((len (vector-length frames))
(lower-idx (if (or (not count) (positive? count))
0
@@ -133,8 +135,12 @@
(if (<= lower-idx i upper-idx)
(let* ((frame (vector-ref frames i)))
(print-frame frame port #:index i #:width width #:full? full?
- #:last-source last-source)
- (lp (+ i inc) (frame-source frame)))))))
+ #:last-source last-source
+ #:next-source? (and (zero? i) for-trap?))
+ (lp (+ i inc)
+ (if (and (zero? i) for-trap?)
+ (frame-next-source frame)
+ (frame-source frame))))))))
;; Ideally here we would have something much more syntactic, in that a set! to a
;; local var that is not settable would raise an error, and export etc forms