Skip to content

Fix ascend, split out find_caller_of and test it #136

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

Merged
merged 1 commit into from
Mar 12, 2021
Merged

Conversation

timholy
Copy link
Member

@timholy timholy commented Mar 11, 2021

This updates ascend to work with the new internals. This also splits out a bit more of the internals to make them more testable (the UI code is a pain to write tests for).

@chriselrod, this should address a wish-list item of yours on discourse: not only does this fix ascend, but I took the opportunity to provide better support for inlining in stacktraces. With this setup:

julia> using Cthulhu

julia> bt = try
           [sqrt(x) for x in [1, -1]]
       catch
           catch_backtrace()
       end;

julia> ascend(bt)
Choose a call for analysis (q to quit):
     throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:33
 >     sqrt at ./math.jl:535 => sqrt at ./math.jl:1181 => #11 at ./none:0 => iterate at ./generator.jl:47 => collect_to! at ./array.jl:725 => collect_to_with_first!(::Vector{Float64}, ::Float64, ::Base.G
         collect(::Base.Generator{Vector{Int64}, var"#11#12"}) at ./array.jl:684
           eval at ./boot.jl:369 => eval_user_input(::Any, ::REPL.REPLBackend) at /home/tim/src/julia-master/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:139
             repl_backend_loop(::REPL.REPLBackend) at /home/tim/src/julia-master/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:200
               start_repl_backend(::REPL.REPLBackend, ::Any) at /home/tim/src/julia-master/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:185
                 #run_repl#42(::Bool, ::typeof(REPL.run_repl), ::REPL.AbstractREPL, ::Any) at /home/tim/src/julia-master/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:317
                   run_repl(::REPL.AbstractREPL, ::Any) at /home/tim/src/julia-master/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:305
                     (::Base.var"#916#918"{Bool, Bool, Bool})(::Module) at ./client.jl:394
v                      #invokelatest#2 at ./essentials.jl:734 => invokelatest at ./essentials.jl:732 => run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:379

now when you press enter when the > is positioned as above, you get this:

Choose caller of MethodInstance for Base.Math.throw_complex_domainerror(::Symbol, ::Float64) or proceed to typed code:
 > "array.jl", collect_to_with_first!: lines [703]
    "array.jl", collect_to!: lines [725]
     "generator.jl", iterate: lines [47]
       "math.jl", sqrt: lines [1181, 535]
   Browse typed code

The successive indentation shows the sequence of calls that led to throw_complex_domainerror and you can select any of them for opening in your editor.

@timholy
Copy link
Member Author

timholy commented Mar 11, 2021

Test failures are due to JuliaLang/julia#39305

@timholy timholy merged commit 845667c into master Mar 12, 2021
@timholy timholy deleted the teh/testability branch March 12, 2021 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant