Skip to content

Commit

Permalink
Supply stacktrace to ascend (#214)
Browse files Browse the repository at this point in the history
Given a suitably up-to-date Cthulhu, this exploits the stacktrace
(rather than the backedges) to ensure an unbranched set of callers.
  • Loading branch information
timholy authored Mar 21, 2023
1 parent bdfde9d commit 19a5eb1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ProfileView"
uuid = "c46f51b8-102a-5cf2-8d2c-8597cb0e0da7"
author = ["Tim Holy <[email protected]>"]
version = "1.7.0"
version = "1.7.1"

[deps]
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Expand Down
16 changes: 15 additions & 1 deletion src/ProfileView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export @profview, warntype_clicked, descend_clicked, ascend_clicked
@deprecate warntype_last warntype_clicked

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

const _graphtype = Ref{Symbol}(Symbol(@load_preference("graphtype", "flame")))
const _theme = Ref{Symbol}(Symbol(@load_preference("theme", "light")))
Expand Down Expand Up @@ -433,6 +434,15 @@ function viewprof_func(fcolor, c, g, fontsize, tb_items, graphtype)
elseif btn.button == 3
edit(string(sf.file), sf.line)
end
# Also collect the trace
Y = size(tagimg, 2)
trace = [sf]
yu += 1
while yu < Y
push!(trace, gettag(tagimg, xu, yu))
yu += 1
end
clicked_trace[] = trace
end
end
end
Expand Down Expand Up @@ -550,7 +560,11 @@ function __init__()
@warn "the bar you clicked on might have been inlined and unavailable for inspection. Click on a non-inlined bar to `descend`."
return nothing
end
return Cthulhu.ascend(st.linfo; hide_type_stable, kwargs...)
if hasmethod(Cthulhu.buildframes, Tuple{Vector{StackTraces.StackFrame}})
return Cthulhu.ascend(clicked_trace[]; hide_type_stable, kwargs...)
else
return Cthulhu.ascend(st.linfo; hide_type_stable, kwargs...)
end
end
end
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs
Expand Down

2 comments on commit 19a5eb1

@timholy
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/80039

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.7.1 -m "<description of version>" 19a5eb103a1f7cdc101577b767fbd9ad494b446e
git push origin v1.7.1

Please sign in to comment.