0x2c7 / ruby_jard

Just Another Ruby Debugger. Provide a rich Terminal UI that visualizes everything your need, navigates your program with pleasure, stops at matter places only, reduces manual and mental efforts. You can now focus on real debugging.
https://rubyjard.org/
MIT License
845 stars 28 forks source link

[BUG] Can not step into subsequent calls on the same line of code (only the call which is evaluated first by Ruby) #75

Open bjeanes opened 4 years ago

bjeanes commented 4 years ago

Describe the bug

Given code such as:

foo(bar.to_h)

it is not apparently possible to step into the foo call. When Jard stops on this line, Step will step into the #to_h call. Unlike something like byebug, Step Out does not take me back to the foo(bar.to_h) line but appears to step up/out past it or perhaps just steps over it (it's hard to tell).

To Reproduce

  1. Enter jard before a method call that contains arguments which need evaluation via a method call. For instance: image

  2. F7 will take you to the first evaluated method call (request.referrer or request, depending on whether request is a local var or a method) image image

  3. Shift+F7 will take you to line after the initial break point (or a frame higher, if the breakpoint was the last line. image

Expected behavior

There should be someway step into redirect_to (and any other calls on that break point). For instance, byebug (and pry-byebug) you could do step, up, step, up, step and you would be inside redirect_to. It's clumsy, but it works.

Ideally, jard would underline the call which it would next step into, but admittedly that may be impossible to do reliably. However, it would look something like:

redirect_to(r͟e͟q͟u͟e͟s͟t͟.referrer || request.fullpath)
redirect_to(request.r͟e͟f͟e͟r͟r͟e͟r͟ || request.fullpath)
redirect_to(request.referrer || r͟e͟q͟u͟e͟s͟t͟.fullpath) # in the case where `request.referrer` is `nil`
redirect_to(request.referrer || request.f͟u͟l͟l͟p͟a͟t͟h͟) # in the case where `request.referrer` is `nil`
r͟e͟d͟i͟r͟e͟c͟t͟_͟t͟o͟(request.referrer || request.fullpath)

I am pretty confident this is not possible without some pretty advanced static analysis, but it does at least illustrate the steps that are expected to be able to be taken manually.

Screenshots

(inline in reproduction steps)

Environment (please complete the following information):