mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 05:50:26 +02:00
add source:line-for-user, returning a 1-indexed line number
* module/system/vm/program.scm (source:line-for-user): New exported procedure, returns a 1-indexed line, suitable for presentation to a user. (write-program): Use source:line-for-user when making fallback names. * module/system/vm/coverage.scm (coverage-data->lcov): * module/language/assembly/disassemble.scm (source->string): * module/system/repl/debug.scm (print-frame): Use source:line-for-user.
This commit is contained in:
parent
c005daf923
commit
e867d563a5
4 changed files with 13 additions and 6 deletions
|
@ -113,7 +113,7 @@
|
|||
|
||||
(define (source->string src)
|
||||
(format #f "~a:~a:~a" (or (source:file src) "(unknown file)")
|
||||
(source:line src) (source:column src)))
|
||||
(source:line-for-user src) (source:column src)))
|
||||
|
||||
(define (make-int16 byte1 byte2)
|
||||
(+ (* byte1 256) byte2))
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
"unknown file"))
|
||||
(let* ((source (frame-source frame))
|
||||
(file (source:pretty-file source))
|
||||
(line (and=> source source:line))
|
||||
(line (and=> source source:line-for-user))
|
||||
(col (and=> source source:column)))
|
||||
(if (and file (not (equal? file (source:pretty-file last-source))))
|
||||
(format port "~&In ~a:~&" file))
|
||||
|
|
|
@ -332,10 +332,10 @@ gathered, even if their code was not executed."
|
|||
(and (program? proc)
|
||||
(let ((sources (program-sources* data proc)))
|
||||
(and (pair? sources)
|
||||
(let* ((line (source:line (car sources)))
|
||||
(let* ((line (source:line-for-user (car sources)))
|
||||
(name (or (procedure-name proc)
|
||||
(format #f "anonymous-l~a" (+ 1 line)))))
|
||||
(format port "FN:~A,~A~%" (+ 1 line) name)
|
||||
(format #f "anonymous-l~a" line))))
|
||||
(format port "FN:~A,~A~%" line name)
|
||||
(and=> (procedure-execution-count data proc)
|
||||
(lambda (count)
|
||||
(format port "FNDA:~A,~A~%" count name))))))))
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
binding:start binding:end
|
||||
|
||||
source:addr source:line source:column source:file
|
||||
source:line-for-user
|
||||
program-sources program-source
|
||||
|
||||
program-bindings program-bindings-by-index program-bindings-for-ip
|
||||
|
@ -64,6 +65,12 @@
|
|||
(define (source:column source)
|
||||
(cdddr source))
|
||||
|
||||
;; Lines are zero-indexed inside Guile, but users expect them to be
|
||||
;; one-indexed. Columns, on the other hand, are zero-indexed to both. Go
|
||||
;; figure.
|
||||
(define (source:line-for-user source)
|
||||
(1+ (source:line source)))
|
||||
|
||||
(define (collapse-locals locs)
|
||||
(let lp ((ret '()) (locs locs))
|
||||
(if (null? locs)
|
||||
|
@ -209,7 +216,7 @@
|
|||
(number->string (object-address prog) 16)
|
||||
(or (source:file s)
|
||||
(if s "<current input>" "<unknown port>"))
|
||||
(source:line s) (source:column s))))
|
||||
(source:line-for-user s) (source:column s))))
|
||||
(number->string (object-address prog) 16))
|
||||
(let ((arities (program-arities prog)))
|
||||
(if (or (not arities) (null? arities))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue