Skip to content

Commit 19a5eb1

Browse files
authored
Supply stacktrace to ascend (#214)
Given a suitably up-to-date Cthulhu, this exploits the stacktrace (rather than the backedges) to ensure an unbranched set of callers.
1 parent bdfde9d commit 19a5eb1

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ProfileView"
22
uuid = "c46f51b8-102a-5cf2-8d2c-8597cb0e0da7"
33
author = ["Tim Holy <[email protected]>"]
4-
version = "1.7.0"
4+
version = "1.7.1"
55

66
[deps]
77
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"

src/ProfileView.jl

+15-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export @profview, warntype_clicked, descend_clicked, ascend_clicked
2424
@deprecate warntype_last warntype_clicked
2525

2626
const clicked = Ref{Any}(nothing) # for getting access to the clicked bar
27+
const clicked_trace = Ref{Any}(nothing)
2728

2829
const _graphtype = Ref{Symbol}(Symbol(@load_preference("graphtype", "flame")))
2930
const _theme = Ref{Symbol}(Symbol(@load_preference("theme", "light")))
@@ -433,6 +434,15 @@ function viewprof_func(fcolor, c, g, fontsize, tb_items, graphtype)
433434
elseif btn.button == 3
434435
edit(string(sf.file), sf.line)
435436
end
437+
# Also collect the trace
438+
Y = size(tagimg, 2)
439+
trace = [sf]
440+
yu += 1
441+
while yu < Y
442+
push!(trace, gettag(tagimg, xu, yu))
443+
yu += 1
444+
end
445+
clicked_trace[] = trace
436446
end
437447
end
438448
end
@@ -550,7 +560,11 @@ function __init__()
550560
@warn "the bar you clicked on might have been inlined and unavailable for inspection. Click on a non-inlined bar to `descend`."
551561
return nothing
552562
end
553-
return Cthulhu.ascend(st.linfo; hide_type_stable, kwargs...)
563+
if hasmethod(Cthulhu.buildframes, Tuple{Vector{StackTraces.StackFrame}})
564+
return Cthulhu.ascend(clicked_trace[]; hide_type_stable, kwargs...)
565+
else
566+
return Cthulhu.ascend(st.linfo; hide_type_stable, kwargs...)
567+
end
554568
end
555569
end
556570
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs

0 commit comments

Comments
 (0)