From 963d95f1d92248d2689efc8b67a9de1f1c8204fb Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 6 Nov 2013 17:33:43 +0100 Subject: [PATCH] Fix first find-program-sources result * module/system/vm/debug.scm (find-program-sources): Manually set the pc of the first result in a function. --- module/system/vm/debug.scm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/module/system/vm/debug.scm b/module/system/vm/debug.scm index a0f11223b..e5eb9bead 100644 --- a/module/system/vm/debug.scm +++ b/module/system/vm/debug.scm @@ -530,8 +530,16 @@ section of the ELF image. Returns an ELF symbol, or @code{#f}." (line-prog-advance prog))) (lambda (pc file line col) (if (and pc (< pc high-pc)) - (lp (cons (make-source/dwarf (+ pc base) file line col) - sources)) + ;; For the first source, it's probable that the + ;; address of the line program is before the + ;; low-pc, since the line program is for the + ;; entire compilation unit, and there are no + ;; redundant "rows" in the line program. + ;; Therefore in that case use the addr of low-pc + ;; instead of the one we got back. + (let ((addr (+ (if (null? sources) low-pc pc) base))) + (lp (cons (make-source/dwarf addr file line col) + sources))) (reverse sources)))))) (else '()))))) (else '())))