debugger icon indicating copy to clipboard operation
debugger copied to clipboard

Behavior of next / stepOver

Open jtpio opened this issue 6 years ago • 9 comments

We should check what it happening when the stepOver (next) command is being used.

In the screencast below we would expect to advance to the line 2, then 3 and then 4 when doing several calls to stepOver.

step-over-behavior

jtpio avatar Nov 04 '19 11:11 jtpio

One difference compared to VS code is that we always seem to have one more ~scope~ frame on line 2. Which would explain why the next command will add that "extra jump":

step-over-behavior-2

jtpio avatar Nov 07 '19 09:11 jtpio

As a side-effect, we can continue breaking and stepping even after removing the breakpoints:

step-over-behavior-3

jtpio avatar Nov 07 '19 09:11 jtpio

Which is most likely related to how the code is executed in xeus-python:

  • the <string> source coming from: https://github.com/QuantStack/xeus-python/blob/507786ce6e726ba3ea518f99fce5636e2e46d329/src/xinterpreter.cpp#L126
  • the execution: https://github.com/QuantStack/xeus-python/blob/507786ce6e726ba3ea518f99fce5636e2e46d329/src/xinterpreter.cpp#L150-L156

image

jtpio avatar Nov 07 '19 10:11 jtpio

I wonder if this behavior does not come from the way we initialize ptvsd. Indeed, I can observe the same behavior even if the last statement is not an expression to evaluate. I've also played a bit with the backend, the following change doe snot fix the issue:

    std::string filename = get_cell_tmp_file(code);
    register_filename_mapping(filename, execution_count);
    
    // Parse code to AST
    py::object code_ast = ast.attr("parse")(code, filename, "exec");
    py::list expressions = code_ast.attr("body");

JohanMabille avatar Nov 08 '19 07:11 JohanMabille

I wonder if this behavior does not come from the way we initialize ptvsd

That is also one possibility yes.

jtpio avatar Nov 08 '19 09:11 jtpio

This issue is definitely due to the backend implementation. It seems that ptvsd doe snot support interactive mode yet (see https://github.com/microsoft/ptvsd/issues/201).

The result is that we have too stackframes, one from the interactive mode and one from the code that hit the breakpoints. When we reach the end of the file containing the code of the cell, it comes back to the interactive frame. This is the same behavior when the code is stoppe don the last line of a funciton and we click the next button: it commes back to the call site.

JohanMabille avatar Nov 14 '19 09:11 JohanMabille

Related PR in xeus-python: https://github.com/QuantStack/xeus-python/pull/169

jtpio avatar Nov 18 '19 09:11 jtpio

https://github.com/QuantStack/xeus-python/pull/169 already is a good improvement for the behavior of next / stepOver. Thanks @JohanMabille for this!

However there seems to be something else related to the status of kernel (busy / idle) when the execute_request has completed:

step-over-behavior-4

Leaving the issue open so we can track this.

jtpio avatar Nov 18 '19 14:11 jtpio

Moving that one to the next release as this is not a blocker for 0.1.0.

jtpio avatar Dec 12 '19 15:12 jtpio