Skip to content
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: 8 additions & 7 deletions src/backedges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function buildframes(bt::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}})
sf = sfs[end]
sf.from_c && continue
mi = sf.linfo
isa(mi, Core.MethodInstance) || continue
isa(mi, Core.MethodInstance) || isa(mi, CodeInstance) || continue
push!(ipframes, IPFrames(sfs))
end
return ipframes
Expand All @@ -75,7 +75,7 @@ function buildframes(st::Vector{StackTraces.StackFrame})
ipframes = IPFrames[]
for sf in st
mi = sf.linfo
isa(mi, Core.MethodInstance) || continue
isa(mi, Core.MethodInstance) || isa(mi, CodeInstance) || continue
push!(ipframes, IPFrames([sf]))
end
return ipframes
Expand Down Expand Up @@ -135,16 +135,18 @@ function nextnode end


backedges(mi::MethodInstance) = isdefined(mi, :backedges) ? mi.backedges : _emptybackedges
backedges(ci::CodeInstance) = backedges(get_mi(ci))
method(mi::MethodInstance) = mi.def
method(edge::CodeInstance) = method(get_mi(edge))
specTypes(mi::MethodInstance) = mi.specTypes
specTypes(edge::CodeInstance) = specTypes(get_mi(edge))
instance(mi::MethodInstance) = mi
instance(ci::CodeInstance) = ci
nextnode(mi, edge) = edge

instance(@nospecialize(tt::Type)) = tt

instance(sfs::Vector{StackTraces.StackFrame}) = isempty(sfs) ? CC.Timings.ROOTmi : sfs[end].linfo::MethodInstance # we checked this type condition within `buildframes`
instance(sfs::Vector{StackTraces.StackFrame}) = isempty(sfs) ? CC.Timings.ROOTmi : get_mi(sfs[end].linfo) # we checked this type condition within `buildframes`
method(sfs::Vector{StackTraces.StackFrame}) = method(instance(sfs))
backedges(sframes::Vector{StackTraces.StackFrame}) = (ret = sframes[2:end]; isempty(ret) ? () : (ret,))

Expand All @@ -171,6 +173,7 @@ struct Data{T}
callstr::String
nd::T
end
Data{MethodInstance}(callstr, nd::CodeInstance) = Data{MethodInstance}(callstr, get_mi(nd))

function treelist(mi)
io = IOBuffer()
Expand All @@ -184,11 +187,9 @@ function treelist!(parent::Node, io::IO, mi, indent::AbstractString, visited::Ba
push!(visited, imi)
indent *= " "
for edge in backedges(mi)
isa(edge, MethodInstance) || isa(edge, CodeInstance) || continue
str = indent * callstring(io, edge)
edge_mi = get_mi(edge)
child = Node(typeof(parent.data)(str, instance(edge_mi)), parent)
treelist!(child, io, nextnode(mi, edge_mi), indent, visited)
child = Node(typeof(parent.data)(str, instance(edge)), parent)
treelist!(child, io, nextnode(mi, edge), indent, visited)
end
return parent
end
Expand Down
6 changes: 3 additions & 3 deletions test/test_terminal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ end
displayed, text = read_from(terminal)
@test occursin("Choose a call for analysis (q to quit):", text)
@test occursin("mapreduce_empty", text)
@test occursin("reduce_empty(op::Function, T::Type)", text)
@test occursin("reduce_empty(op::Function, T::Type)", text) || occursin("reduce_empty(::typeof(+), ::Type{Any})", text)
@test occursin("Select a call to descend into or ↩ to ascend.", text)
write(terminal, 'q')
write(terminal, 'q')
Expand All @@ -338,7 +338,7 @@ end
displayed, text = read_from(terminal)
@test occursin("Choose a call for analysis (q to quit):", text)
@test occursin("mapreduce_empty", text)
@test occursin("reduce_empty(op::Function, T::Type)", text)
@test occursin("reduce_empty(op::Function, T::Type)", text) || occursin("reduce_empty(::typeof(+), ::Type{Any})", text)
@test occursin("Select a call to descend into or ↩ to ascend.", text)
write(terminal, 'q')
write(terminal, 'q')
Expand All @@ -353,7 +353,7 @@ end
displayed, text = read_from(terminal)
@test occursin("Choose a call for analysis (q to quit):", text)
@test occursin("mapreduce_empty", text)
@test occursin("reduce_empty(op::Function, T::Type)", text)
@test occursin("reduce_empty(op::Function, T::Type)", text) || occursin("reduce_empty(::typeof(+), ::Type{Any})", text)
@test occursin("Select a call to descend into or ↩ to ascend.", text)
write(terminal, 'q')
write(terminal, 'q')
Expand Down
Loading