Skip to content

Commit 39f8f36

Browse files
committed
Print omitted module names
1 parent 0f6416c commit 39f8f36

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

base/errorshow.jl

+30-6
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,19 @@ function show_compact_backtrace(io::IO, trace::Vector; print_linebreaks::Bool)
585585
modulecolordict = copy(STACKTRACE_FIXEDCOLORS)
586586
modulecolorcycler = Iterators.Stateful(Iterators.cycle(STACKTRACE_MODULECOLORS))
587587

588+
function print_omitted_modules(i, j)
589+
# Find modules involved in intermediate frames and print them
590+
modules = filter(!isnothing, unique(t[1] |> parentmodule for t @view trace[i:j]))
591+
length(modules) > 0 || return
592+
print(repeat(' ', ndigits_max + 2))
593+
for m modules
594+
modulecolor = get_modulecolor!(modulecolordict, m, modulecolorcycler)
595+
printstyled(io, m, color = modulecolor)
596+
print(" ")
597+
end
598+
println()
599+
end
600+
588601
# find all frames that aren't in Julia base, stdlib, or an added package
589602
is = findall(trace) do frame
590603
file = String(frame[1].file)
@@ -599,12 +612,19 @@ function show_compact_backtrace(io::IO, trace::Vector; print_linebreaks::Bool)
599612
if length(is) > 0
600613
println(io, "\nStacktrace:")
601614

602-
is[1] == 0 || println(repeat(' ', ndigits_max + 2) * "")
615+
if is[1] > 0
616+
print_omitted_modules(1, is[1])
617+
println(repeat(' ', ndigits_max + 2) * "")
618+
end
603619

604620
lasti = first(is)
605-
for i is
621+
@views for i is
606622
i == 0 && continue
607-
i == lasti + 1 || println(repeat(' ', ndigits_max + 2) * "")
623+
if i > lasti + 1
624+
println(repeat(' ', ndigits_max + 2) * "")
625+
print_omitted_modules(lasti + 1, i - 1)
626+
println(repeat(' ', ndigits_max + 2) * "")
627+
end
608628
print_stackframe(io, i, trace[i][1], trace[i][2], ndigits_max, modulecolordict, modulecolorcycler)
609629
if i < num_frames
610630
println(io)
@@ -709,6 +729,11 @@ end
709729
# from `modulecolorcycler`.
710730
function print_stackframe(io, i, frame::StackFrame, n::Int, digit_align_width, modulecolordict, modulecolorcycler)
711731
m = Base.parentmodule(frame)
732+
modulecolor = get_modulecolor!(modulecolordict, m, modulecolorcycler)
733+
print_stackframe(io, i, frame, n, digit_align_width, modulecolor)
734+
end
735+
736+
function get_modulecolor!(modulecolordict, m, modulecolorcycler)
712737
if m !== nothing
713738
while parentmodule(m) !== m
714739
pm = parentmodule(m)
@@ -718,11 +743,10 @@ function print_stackframe(io, i, frame::StackFrame, n::Int, digit_align_width, m
718743
if !haskey(modulecolordict, m)
719744
modulecolordict[m] = popfirst!(modulecolorcycler)
720745
end
721-
modulecolor = modulecolordict[m]
746+
return modulecolordict[m]
722747
else
723-
modulecolor = :default
748+
return :default
724749
end
725-
print_stackframe(io, i, frame, n, digit_align_width, modulecolor)
726750
end
727751

728752

0 commit comments

Comments
 (0)