Cthulhu.jl icon indicating copy to clipboard operation
Cthulhu.jl copied to clipboard

add descend string macro

Open vchuravy opened this issue 5 years ago • 8 comments

This allows for users to take a stacktrace like:

julia> wait(kernel!(a, b, c, ndrange=size(c)))ERROR: TaskFailedException:MethodError: no method matching __index_Global_Cartesian(::CartesianIndex{2})Stacktrace:
 [1] __index_Global_NTuple at /home/vchuravy/src/KernelAbstractions/src/KernelAbstractions.jl:291 [inlined]
 [2] cpu_matmul_kernel! at /home/vchuravy/src/KernelAbstractions/src/macros.jl:229 [inlined]
 [3] __thread_run(::Int64, ::Int64, ::Int64, ::KernelAbstractions.Kernel{CPU,KernelAbstractions.NDIteration.StaticSize{(4,)},KernelAbstractions.NDIteratio
n.DynamicSize,typeof(cpu_matmul_kernel!)}, ::Tuple{Int64,Int64}, ::KernelAbstractions.NDIteration.NDRange{2,KernelAbstractions.NDIteration.DynamicSize,Ker
nelAbstractions.NDIteration.StaticSize{(4, 1)},CartesianIndices{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}},Nothing}, ::Tuple{Array{Float64,2},Array{Flo
at64,2},Array{Float64,2}}, ::KernelAbstractions.NDIteration.NoDynamicCheck) at /home/vchuravy/src/KernelAbstractions/src/backends/cpu.jl:148
 [4] __run(::KernelAbstractions.Kernel{CPU,KernelAbstractions.NDIteration.StaticSize{(4,)},KernelAbstractions.NDIteration.DynamicSize,typeof(cpu_matmul_ke
rnel!)}, ::Tuple{Int64,Int64}, ::KernelAbstractions.NDIteration.NDRange{2,KernelAbstractions.NDIteration.DynamicSize,KernelAbstractions.NDIteration.Static
Size{(4, 1)},CartesianIndices{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}},Nothing}, ::Tuple{Array{Float64,2},Array{Float64,2},Array{Float64,2}}, ::Kerne
lAbstractions.NDIteration.NoDynamicCheck) at /home/vchuravy/src/KernelAbstractions/src/backends/cpu.jl:121
 [5] (::KernelAbstractions.var"#30#31"{Nothing,Nothing,typeof(KernelAbstractions.__run),Tuple{KernelAbstractions.Kernel{CPU,KernelAbstractions.NDIteration.StaticSize{(4,)},KernelAbstractions.NDIteration.DynamicSize,typeof(cpu_matmul_kernel!)},Tuple{Int64,Int64},KernelAbstractions.NDIteration.NDRange{2,KernelAbstractions.NDIteration.DynamicSize,KernelAbstractions.NDIteration.StaticSize{(4, 1)},CartesianIndices{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}},Nothing},Tuple{Array{Float64,2},Array{Float64,2},Array{Float64,2}},KernelAbstractions.NDIteration.NoDynamicCheck}})() at /home/vchuravy/src/KernelAbstractions/src/backends/cpu.jl:20
Stacktrace:
 [1] wait at ./task.jl:267 [inlined]
 [2] wait at /home/vchuravy/src/KernelAbstractions/src/backends/cpu.jl:63 [inlined]
 [3] wait at /home/vchuravy/src/KernelAbstractions/src/backends/cpu.jl:27 [inlined] (repeats 2 times)
 [4] top-level scope at REPL[30]:1

And invoke:

descend"KernelAbstractions.__thread_run(::Int64, ::Int64, ::Int64, ::KernelAbstractions.Kernel{CPU,KernelAbstractions.NDIteration.StaticSize{(4,)},KernelAbstractions.NDIteratio
n.DynamicSize,typeof(cpu_matmul_kernel!)}, ::Tuple{Int64,Int64}, ::KernelAbstractions.NDIteration.NDRange{2,KernelAbstractions.NDIteration.DynamicSize,Ker
nelAbstractions.NDIteration.StaticSize{(4, 1)},CartesianIndices{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}},Nothing}, ::Tuple{Array{Float64,2},Array{Flo
at64,2},Array{Float64,2}}, ::KernelAbstractions.NDIteration.NoDynamicCheck)"

vchuravy avatar Apr 20 '20 15:04 vchuravy

Idea: make decend(3) work to do the same thing. I.e. to decend into the method mentioned on the 3rd item in the last stacktrace.

Somewhere (in the REPL?) is stored the last numbered thing. with makes julia> 3 then ctrl+q work with methods(...) and stacktraces. @kristofferc set it up, i think?

oxinabox avatar Apr 21 '20 08:04 oxinabox

@KristofferC set it up, i think?

Yep,

https://github.com/JuliaLang/julia/blob/ba5cafba6a777be24846b1fdd4be4bd20e3551b5/base/errorshow.jl#L616-L619

https://github.com/JuliaLang/julia/blob/ba5cafba6a777be24846b1fdd4be4bd20e3551b5/stdlib/REPL/src/REPL.jl#L1095-L1109

KristofferC avatar Apr 21 '20 10:04 KristofferC

How does that work with exception stacks?

In the above I have two stacked exceptions.

vchuravy avatar Apr 21 '20 14:04 vchuravy

How does that work with exception stacks?

No idea :D (probably the latest printed)

KristofferC avatar Apr 21 '20 15:04 KristofferC

Yeah and the location is not enough information for Cthulhu, so we would need to store the stackframe itself.

vchuravy avatar Apr 21 '20 16:04 vchuravy

Yeah and the location is not enough information for Cthulhu, so we would need to store the stackframe itself.

You can resolve locations into methods via CodeTracking.jl, which is already a dependency of Cthulu

oxinabox avatar Apr 21 '20 16:04 oxinabox

Methods are not sufficient I need MethodInstances.

vchuravy avatar Apr 21 '20 20:04 vchuravy

ah, trackign that down is much more annoying

oxinabox avatar Apr 22 '20 11:04 oxinabox