Skip to content
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

Step through preparation for kwarg calls #190

Merged
merged 1 commit into from Mar 19, 2019
Merged

Step through preparation for kwarg calls #190

merged 1 commit into from Mar 19, 2019

Conversation

timholy
Copy link
Member

@timholy timholy commented Mar 19, 2019

I am tired of stepping through NamedTuple, pairs, merge, and Core.kwfunc. This feels better.

@KristofferC
Copy link
Member

KristofferC commented Mar 19, 2019

Great! A related question, should we also step "out" of wrappers when exiting a frame, e.g.

julia> f(x; y =3) = x + y;

julia> fr = JuliaInterpreter.maybe_step_through_wrapper!(JuliaInterpreter.enter_call(f, 2; y=3))
Frame for #f#5(y, ::Any, x) in Main at REPL[2]:1
  1 1  1%1 = (+)(x, y)
  2 1  └──      return %1
#f#5 = #f#5
y = 3
 = f
x = 2
caller: (::getfield(Main, Symbol("#kw##f")))(::Any, ::typeof(f), x) in Main

julia> frame, pc = JuliaInterpreter.debug_command(fr, :finish)
(Frame for (::getfield(Main, Symbol("#kw##f")))(::Any, ::typeof(f), x) in Main

  14 0  6 ─       (Base.kwerr)(#temp#@_2, , x)
  15 0  7%15 = (#f#5)(y, , x)
  16 0  └──       return %15
#unused# = #kw##f()
#temp# = 3
 = f
x = 2
y = 3, 16)

Should the finish here step our of the kw wrapper and we then just end up returning completely to top level in this example.

@pfitzseb
Copy link
Member

Yes please :) Although there probably should be some way to inspect all wrappers etc.

@KristofferC
Copy link
Member

KristofferC commented Mar 19, 2019

I guess it can also be up to the frontend to call maybe_step_through_wrapper! and remember if it was a wrapper and in that case finish! the frame when it becomes active again.

Edit: Thinking about it, I think it is fine for the JuliaInterpreter to not do too much magic stepping through and just let the user of JuliaInterpreter (like Debugger.jl) decide how fine grained the stepping should be.

@timholy
Copy link
Member Author

timholy commented Mar 19, 2019

You can definitely do fine-grained stuff with se and si. Since this doesn't change frames at all, stepping out of wrappers is a bit orthogonal to this particular PR.

But I'd be fine with moving the magic out of debug_command. Is that the consensus? Vote thumbs-up or thumbs-down.

@KristofferC
Copy link
Member

KristofferC commented Mar 19, 2019

Personally, I don't mind since I would likely be using this myself. It is just in the situation where a frontend does not want the automatic wrapper stepping, one would have to reconstruct s and co based on si then?

@timholy
Copy link
Member Author

timholy commented Mar 19, 2019

Yes, si should avoid the wrapper-stepping. To me that seems like a reasonable solution.

@timholy
Copy link
Member Author

timholy commented Mar 19, 2019

Test failures seem spurious, so if we decide we like this we could merge. Want to make the call, @KristofferC?

@KristofferC
Copy link
Member

KristofferC commented Mar 19, 2019

Yes, si should avoid the wrapper-stepping.

Yes, but it also doesn't step to the next call. But sure, someone can do

function s_without_step_through(frame)
    while true
        ret = si(frame)
        ret = nothing && ...
        new_frame, pc = ret
        frame !== new_frame && return new_frame
    end
end

@timholy timholy merged commit 41c9900 into master Mar 19, 2019
@timholy timholy deleted the teh/step_kwfunc branch March 19, 2019 16:50
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.

None yet

3 participants