summaryrefslogtreecommitdiff
path: root/module/system/vm/traps.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-10-01 18:25:44 +0200
committerAndy Wingo <wingo@pobox.com>2010-10-01 18:25:44 +0200
commit2c5fc8d03420855301993bee6d8afa28d64503d6 (patch)
tree63cbefbbe7ce9741768c6b67056c9e95e3dc883d /module/system/vm/traps.scm
parente867d563a56a86533f998441dc8c48dfef38d017 (diff)
downloadguile-2c5fc8d03420855301993bee6d8afa28d64503d6.tar.gz
source breakpoints accept user line numbers
* module/system/vm/trap-state.scm (add-trap-at-source-location!): * module/system/vm/traps.scm (trap-at-source-location): Rename "line" argument to "user-line", indicating that the line is one-based instead of zero-based. Decrement the line before handing off to source-closures-or-procedures and source->ip-range.
Diffstat (limited to 'module/system/vm/traps.scm')
-rw-r--r--module/system/vm/traps.scm16
1 files changed, 10 insertions, 6 deletions
diff --git a/module/system/vm/traps.scm b/module/system/vm/traps.scm
index e31df855e..0e7a540ec 100644
--- a/module/system/vm/traps.scm
+++ b/module/system/vm/traps.scm
@@ -249,6 +249,9 @@
(define (non-negative-integer? x)
(and (number? x) (integer? x) (exact? x) (not (negative? x))))
+(define (positive-integer? x)
+ (and (number? x) (integer? x) (exact? x) (positive? x)))
+
(define (range? x)
(and (list? x)
(and-map (lambda (x)
@@ -345,16 +348,17 @@
(values (source-procedures file line) #f))))
;; Building on trap-on-instructions-in-procedure, we have
-;; trap-at-source-location.
+;; trap-at-source-location. The parameter `user-line' is one-indexed, as
+;; a user counts lines, instead of zero-indexed, as Guile counts lines.
;;
-(define* (trap-at-source-location file line handler
+(define* (trap-at-source-location file user-line handler
#:key current-frame (vm (the-vm)))
(arg-check file string?)
- (arg-check line non-negative-integer?)
+ (arg-check user-line positive-integer?)
(arg-check handler procedure?)
(let ((traps #f))
(call-with-values
- (lambda () (source-closures-or-procedures file line))
+ (lambda () (source-closures-or-procedures file (1- user-line)))
(lambda (procs closures?)
(new-enabled-trap
vm current-frame
@@ -362,14 +366,14 @@
(set! traps
(map
(lambda (proc)
- (let ((range (source->ip-range proc file line)))
+ (let ((range (source->ip-range proc file (1- user-line))))
(trap-at-procedure-ip-in-range proc range handler
#:current-frame current-frame
#:vm vm
#:closure? closures?)))
procs))
(if (null? traps)
- (error "No procedures found at ~a:~a." file line)))
+ (error "No procedures found at ~a:~a." file user-line)))
(lambda (frame)
(for-each (lambda (trap) (trap frame)) traps)
(set! traps #f)))))))