Skip to content

Commit 687101e

Browse files
authored
Merge pull request #416 from JuliaDebug/teh/nightly
Fix a couple of new breakages on nightly
2 parents f65e021 + 9aef639 commit 687101e

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

src/utils.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function whichtt(@nospecialize(tt))
3434
# TODO: provide explicit control over world age? In case we ever need to call "old" methods.
3535
m = ccall(:jl_gf_invoke_lookup, Any, (Any, UInt), tt, typemax(UInt))
3636
m === nothing && return nothing
37+
isa(m, Method) && return m
3738
return m.func::Method
3839
end
3940

@@ -653,9 +654,15 @@ function Base.show_backtrace(io::IO, frame::Frame)
653654
print(io, "\nStacktrace:")
654655
try invokelatest(Base.update_stackframes_callback[], stackframes) catch end
655656
frame_counter = 0
656-
for (last_frame, n) in stackframes
657+
nd = ndigits(length(stackframes))
658+
for (i, (last_frame, n)) in enumerate(stackframes)
657659
frame_counter += 1
658-
Base.show_trace_entry(IOContext(io, :backtrace => true), last_frame, n, prefix = string(" [", frame_counter, "] "))
660+
if isdefined(Base, :print_stackframe)
661+
println(io)
662+
Base.print_stackframe(io, i, last_frame, n, nd, Base.info_color())
663+
else
664+
Base.show_trace_entry(IOContext(io, :backtrace => true), last_frame, n, prefix = string(" [", frame_counter, "] "))
665+
end
659666
end
660667
end
661668

test/interpret.jl

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,21 @@ try
474474
frame, bp = @interpret g_1(2.0)
475475
stacktrace_lines = split(sprint(Base.display_error, bp.err, leaf(frame)), '\n')
476476
@test occursin(string("ERROR: ", sprint(showerror, ErrorException("foo"))), stacktrace_lines[1])
477-
@test occursin("[1] error(::String) at error.jl:", stacktrace_lines[3])
478-
@test occursin("[2] g_3(::Float64) at $(@__FILE__):$(line_g - 1)", stacktrace_lines[4])
479-
@test occursin("[3] g_2(::Float64) at $(@__FILE__):$(line_g - 2)", stacktrace_lines[5])
480-
@test occursin("[4] g_1(::Float64) at $(@__FILE__):$(line_g - 3)", stacktrace_lines[6])
477+
if isdefined(Base, :print_stackframe)
478+
@test occursin("[1] error(s::String)", stacktrace_lines[3])
479+
@test occursin("[2] g_3(x::Float64)", stacktrace_lines[5])
480+
thefile = Base.replaceuserpath(@__FILE__)
481+
@test occursin("$thefile:$(line_g - 1)", stacktrace_lines[6])
482+
@test occursin("[3] g_2(x::Float64)", stacktrace_lines[7])
483+
@test occursin("$thefile:$(line_g - 2)", stacktrace_lines[8])
484+
@test occursin("[4] g_1(x::Float64)", stacktrace_lines[9])
485+
@test occursin("$thefile:$(line_g - 3)", stacktrace_lines[10])
486+
else
487+
@test occursin("[1] error(::String) at error.jl:", stacktrace_lines[3])
488+
@test occursin("[2] g_3(::Float64) at $(@__FILE__):$(line_g - 1)", stacktrace_lines[4])
489+
@test occursin("[3] g_2(::Float64) at $(@__FILE__):$(line_g - 2)", stacktrace_lines[5])
490+
@test occursin("[4] g_1(::Float64) at $(@__FILE__):$(line_g - 3)", stacktrace_lines[6])
491+
end
481492
finally
482493
break_off(:error)
483494
end
@@ -492,11 +503,24 @@ try
492503
frame, bp = JuliaInterpreter.debug_command(frame, :c, true)
493504
stacktrace_lines = split(sprint(Base.display_error, bp.err, leaf(frame)), '\n')
494505
@test occursin(string("ERROR: ", sprint(showerror, ErrorException("foo"))), stacktrace_lines[1])
495-
@test occursin("[1] error(::String) at error.jl:", stacktrace_lines[3])
496-
@test occursin("[2] g_3(::Float64) at $(@__FILE__):$(line_g - 1)", stacktrace_lines[4])
497-
@test occursin("[3] g_2(::Float64) at $(@__FILE__):$(line_g - 2)", stacktrace_lines[5])
498-
@test occursin("[4] g_1(::Float64) at $(@__FILE__):$(line_g - 3)", stacktrace_lines[6])
499-
@test occursin("[5] top-level scope at $(@__FILE__):$(line2_g - 2)", stacktrace_lines[7])
506+
if isdefined(Base, :print_stackframe)
507+
@test occursin("[1] error(s::String)", stacktrace_lines[3])
508+
thefile = Base.replaceuserpath(@__FILE__)
509+
@test occursin("[2] g_3(x::Float64)", stacktrace_lines[5])
510+
@test occursin("$thefile:$(line_g - 1)", stacktrace_lines[6])
511+
@test occursin("[3] g_2(x::Float64)", stacktrace_lines[7])
512+
@test occursin("$thefile:$(line_g - 2)", stacktrace_lines[8])
513+
@test occursin("[4] g_1(x::Float64)", stacktrace_lines[9])
514+
@test occursin("$thefile:$(line_g - 3)", stacktrace_lines[10])
515+
@test occursin("[5] top-level scope", stacktrace_lines[11])
516+
@test occursin("$thefile:$(line2_g - 2)", stacktrace_lines[12])
517+
else
518+
@test occursin("[1] error(::String) at error.jl:", stacktrace_lines[3])
519+
@test occursin("[2] g_3(::Float64) at $(@__FILE__):$(line_g - 1)", stacktrace_lines[4])
520+
@test occursin("[3] g_2(::Float64) at $(@__FILE__):$(line_g - 2)", stacktrace_lines[5])
521+
@test occursin("[4] g_1(::Float64) at $(@__FILE__):$(line_g - 3)", stacktrace_lines[6])
522+
@test occursin("[5] top-level scope at $(@__FILE__):$(line2_g - 2)", stacktrace_lines[7])
523+
end
500524
finally
501525
break_off(:error)
502526
end

0 commit comments

Comments
 (0)