@@ -689,7 +689,7 @@ determined, `loc == nothing`. Otherwise `loc == (filepath, line)`.
689
689
When `frame` represents top-level code,
690
690
"""
691
691
function CodeTracking. whereis (framecode:: JuliaFrameCode , pc)
692
- codeloc = framecode. code. codelocs[ convert (Int, pc)]
692
+ codeloc = codelocation ( framecode. code, convert (Int, pc))
693
693
codeloc == 0 && return nothing
694
694
lineinfo = framecode. code. linetable[codeloc]
695
695
return framecode. scope isa Method ?
@@ -700,12 +700,21 @@ CodeTracking.whereis(frame::JuliaStackFrame, pc=frame.pc[]) = whereis(frame.code
700
700
# Note: linenumber is now an internal method for use by `next_line!`
701
701
# If you want to know the actual line number in a file, call `whereis`.
702
702
function linenumber (framecode:: JuliaFrameCode , pc)
703
- codeloc = framecode. code. codelocs[ convert (Int, pc)]
703
+ codeloc = codelocation ( framecode. code, convert (Int, pc))
704
704
codeloc == 0 && return nothing
705
705
return framecode. code. linetable[codeloc]. line
706
706
end
707
707
linenumber (frame:: JuliaStackFrame , pc= frame. pc[]) = linenumber (frame. code, pc)
708
708
709
+ function codelocation (code:: CodeInfo , idx)
710
+ codeloc = code. codelocs[idx]
711
+ while codeloc == 0 && code. code[idx] === nothing && idx < length (code. code)
712
+ idx += 1
713
+ codeloc = code. codelocs[idx]
714
+ end
715
+ return codeloc
716
+ end
717
+
709
718
"""
710
719
stmtidx = statementnumber(frame, line)
711
720
0 commit comments