Skip to content

Commit 2b8c8ce

Browse files
authored
fix line info printing in bt (#124)
1 parent 20915e3 commit 2b8c8ce

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/commands.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function execute_command(state::DebuggerState, ::Val{:bt}, cmd)
5454
frame = state.frame
5555
while frame !== nothing
5656
num += 1
57-
print_frame(Base.pipe_writer(state.terminal), num, frame)
57+
print_frame(Base.pipe_writer(state.terminal), num, frame; current_line=true)
5858
frame = caller(frame)
5959
end
6060
println()

src/locationinfo.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,20 @@ end
6565
# Used for the tests
6666
const _print_full_path = Ref(true)
6767

68-
function locdesc(frame::Frame)
68+
function locdesc(frame::Frame; current_line=false)
6969
sprint() do io
7070
if frame.framecode.scope isa Method
71-
locdesc(io, frame.framecode)
71+
locdesc(io, frame; current_line=current_line)
7272
else
7373
println(io, "not yet implemented")
7474
end
7575
end
7676
end
7777

78-
function locdesc(io, framecode::FrameCode)
78+
function locdesc(io, frame::Frame; current_line=false)
79+
framecode = frame.framecode
7980
meth = framecode.scope
81+
@assert meth isa Method
8082
argnames = framecode.src.slotnames[2:meth.nargs]
8183
spectypes = Any[Any for i=1:length(argnames)]
8284
print(io, meth.name,'(')
@@ -87,7 +89,8 @@ function locdesc(io, framecode::FrameCode)
8789
print(io, argname)
8890
!(argT === Any) && print(io, "::", argT)
8991
end
90-
path = _print_full_path[] ? meth.file : string(basename(String(meth.file)), ":", meth.line)
92+
line = current_line ? JuliaInterpreter.linenumber(frame) : meth.line
93+
path = string(_print_full_path[] ? meth.file : basename(String(meth.file)), ":", line)
9194
path = CodeTracking.replace_buildbot_stdlibpath(String(path))
9295
print(io, ") at ", path)
9396
end

src/printing.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ function print_var(io::IO, var::JuliaInterpreter.Variable)
1919
println(io, highlight_code(string(var.name, "::", T, " = ", val); context=io))
2020
end
2121

22-
print_locdesc(io::IO, frame::Frame) = println(io, locdesc(frame))
23-
2422
function print_locals(io::IO, frame::Frame)
2523
vars = JuliaInterpreter.locals(frame)
2624
for var in vars
@@ -30,9 +28,9 @@ function print_locals(io::IO, frame::Frame)
3028
end
3129
end
3230

33-
function print_frame(io::IO, num::Integer, frame::Frame)
31+
function print_frame(io::IO, num::Integer, frame::Frame; current_line=false)
3432
print(io, "[$num] ")
35-
print_locdesc(io, frame)
33+
println(io, locdesc(frame; current_line=current_line))
3634
print_locals(io, frame)
3735
end
3836

test/ui/history_gcd.multiout

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@
14711471
| | x::Int64 = 20
14721472
| | y::Int64 = 0
14731473
| | T::DataType = Int64
1474-
|[2] my_gcd(a, b) at ui.jl:5
1474+
|[2] my_gcd(a, b) at ui.jl:6
14751475
| | a::Int64 = 10
14761476
| | b::Int64 = 20
14771477
| | T::DataType = Int64
@@ -1631,7 +1631,7 @@
16311631
| | x::Int64 = 20
16321632
| | y::Int64 = 0
16331633
| | T::DataType = Int64
1634-
|[2] my_gcd(a, b) at ui.jl:5
1634+
|[2] my_gcd(a, b) at ui.jl:6
16351635
| | a::Int64 = 10
16361636
| | b::Int64 = 20
16371637
| | T::DataType = Int64
@@ -1801,7 +1801,7 @@
18011801
| | x::Int64 = 20
18021802
| | y::Int64 = 0
18031803
| | T::DataType = Int64
1804-
|[2] my_gcd(a, b) at ui.jl:5
1804+
|[2] my_gcd(a, b) at ui.jl:6
18051805
| | a::Int64 = 10
18061806
| | b::Int64 = 20
18071807
| | T::DataType = Int64
@@ -1971,7 +1971,7 @@
19711971
| | x::Int64 = 20
19721972
| | y::Int64 = 0
19731973
| | T::DataType = Int64
1974-
|[2] my_gcd(a, b) at ui.jl:5
1974+
|[2] my_gcd(a, b) at ui.jl:6
19751975
| | a::Int64 = 10
19761976
| | b::Int64 = 20
19771977
| | T::DataType = Int64
@@ -2169,7 +2169,7 @@
21692169
| | x::Int64 = 20
21702170
| | y::Int64 = 0
21712171
| | T::DataType = Int64
2172-
|[2] my_gcd(a, b) at ui.jl:5
2172+
|[2] my_gcd(a, b) at ui.jl:6
21732173
| | a::Int64 = 10
21742174
| | b::Int64 = 20
21752175
| | T::DataType = Int64

0 commit comments

Comments
 (0)