Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qualify function when printing MethodInstance #38608

Merged
merged 2 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -984,18 +984,29 @@ function sourceinfo_slotnames(src::CodeInfo)
return printnames
end

function show(io::IO, l::Core.MethodInstance)
show(io::IO, l::Core.MethodInstance) = show_mi(io, l)

function show_mi(io::IO, l::Core.MethodInstance, from_stackframe::Bool=false)
def = l.def
if isa(def, Method)
if isdefined(def, :generator) && l === def.generator
print(io, "MethodInstance generator for ")
show(io, def)
else
print(io, "MethodInstance for ")
show_tuple_as_call(io, def.name, l.specTypes)
show_tuple_as_call(io, def.name, l.specTypes, false, nothing, nothing, true)
end
else
print(io, "Toplevel MethodInstance thunk")
# `thunk` is not very much information to go on. If this
# MethodInstance is part of a stacktrace, it gets location info
# added by other means. But if it isn't, then we should try
# to print a little more identifying information.
if !from_stackframe
linetable = l.uninferred.linetable
line = isempty(linetable) ? "unknown" : (lt = linetable[1]; string(lt.file) * ':' * string(lt.line))
print(io, " from ", def, " starting at ", line)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion base/stacktraces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function show_spec_linfo(io::IO, frame::StackFrame)
Base.show_tuple_as_call(io, def.name, sig, true, nothing, argnames)
end
else
Base.show(io, linfo)
Base.show_mi(io, linfo, true)
end
elseif linfo isa CodeInfo
print(io, "top-level scope")
Expand Down
2 changes: 1 addition & 1 deletion test/backtrace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ let code = """
"""

bt_str = read(`$(Base.julia_cmd()) --startup-file=no --compile=min -e $code`, String)
@test occursin("InterpreterIP in MethodInstance for foo", bt_str)
@test occursin(r"InterpreterIP in MethodInstance for .*A\.foo", bt_str)
@test occursin("InterpreterIP in top-level CodeInfo for Main.A", bt_str)
end