Skip to content

Commit a11de31

Browse files
authored
debuginfo: store location of loop boundary (#41857)
Since lowering always inserts gotos and other instructions after loop bodies, this allows debuggers to give a more useful location for these instructions. fixes JuliaDebug/JuliaInterpreter.jl#485
1 parent 6b5bc3b commit a11de31

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/julia-parser.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,14 +1376,14 @@
13761376
(if (eq? word 'quote)
13771377
(list 'quote blk)
13781378
blk))))
1379-
((while) (begin0 (list 'while (parse-cond s) (parse-block s))
1379+
((while) (begin0 (list 'while (parse-cond s) (append (parse-block s) (list (line-number-node s))))
13801380
(expect-end s word)))
13811381
((for)
13821382
(let* ((ranges (parse-comma-separated-iters s))
13831383
(body (parse-block s)))
13841384
(expect-end s word)
13851385
`(for ,(if (length= ranges 1) (car ranges) (cons 'block ranges))
1386-
,body)))
1386+
,(append body (list (line-number-node s))))))
13871387

13881388
((let)
13891389
(let ((binds (if (memv (peek-token s) '(#\newline #\;))

stdlib/Distributed/src/macros.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ macro distributed(args...)
347347
var = loop.args[1].args[1]
348348
r = loop.args[1].args[2]
349349
body = loop.args[2]
350+
if Meta.isexpr(body, :block) && body.args[end] isa LineNumberNode
351+
resize!(body.args, length(body.args) - 1)
352+
end
350353
if na==1
351354
syncvar = esc(Base.sync_varname)
352355
return quote

test/testhelpers/coverage_file.info

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ DA:4,1
44
DA:5,0
55
DA:7,1
66
DA:8,1
7-
DA:9,5
7+
DA:9,3
8+
DA:10,5
89
DA:11,1
910
DA:12,1
1011
DA:14,0

test/testhelpers/coverage_file.info.bad

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ DA:4,1
44
DA:5,0
55
DA:7,1
66
DA:8,1
7-
DA:9,5
7+
DA:9,3
8+
DA:10,5
89
DA:11,1
910
DA:12,1
1011
DA:14,0
@@ -14,6 +15,6 @@ DA:19,1
1415
DA:20,1
1516
DA:22,1
1617
DA:1234,0
17-
LH:11
18-
LF:15
18+
LH:12
19+
LF:16
1920
end_of_record

0 commit comments

Comments
 (0)