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

make next command less skipping #484

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bicycle1885
Copy link

@bicycle1885 bicycle1885 commented May 28, 2021

This PR makes the next command less skipping. The motivation is described here: JuliaDebug/Debugger.jl#291.

My approach is to add a keyword argument (sameline) to the maybe_next_call! function so that it tires to find a call or a return statement without stepping forward to the next lines. If it fails, it stops at the current program counter.

With this patch (and a minor modification to Debugger.jl), assignments and branches are no longer skipped and now it works like debuggers of other languages (such as Python's ipdb):

julia> function foo(x)
           #println(x)
           y = 0
           if x
               y = 1
           end
           return y
       end
foo (generic function with 1 method)

julia> @enter foo(true)
In foo(x) at REPL[1]:1
 1  function foo(x)
 2      #println(x)
>3      y = 0
 4      if x
 5          y = 1
 6      end
 7      return y
 8  end

About to run: 0
1|debug> n
In foo(x) at REPL[1]:1
 1  function foo(x)
 2      #println(x)
 3      y = 0
>4      if x
 5          y = 1
 6      end
 7      return y
 8  end

About to run: goto %4 if not _J2
1|debug>
In foo(x) at REPL[1]:1
 1  function foo(x)
 2      #println(x)
 3      y = 0
 4      if x
>5          y = 1
 6      end
 7      return y
 8  end

About to run: 1
1|debug>
In foo(x) at REPL[1]:1
 3      y = 0
 4      if x
 5          y = 1
 6      end
>7      return y
 8  end

About to run: return 1
1|debug>
1

@KristofferC
Copy link
Member

KristofferC commented May 28, 2021

About to run: goto %4 if not _J2

I don't think it is good to stop at these internal looking statements.

@pfitzseb
Copy link
Member

Although that seems to be more of a printing issue? Stopping at branch conditions makes sense to me.

@bicycle1885
Copy link
Author

How to print assignments and branch conditions is a separated problem, and it should be fixed in Debugger.jl.

NOTE: I found the current impl is completely broken. So, there is no need to check the patch at the moment.

@bicycle1885
Copy link
Author

bicycle1885 commented May 29, 2021

I've changed the design: next_line! continues to step forward until it finds a statement which is one of:

  • function calls
  • assignments (both local and global)
  • returns
  • goto nodes (both conditional and unconditional)

Here, "assignment" excludes assignments to compiler-generated variables. I'm not perfectly sure how it can be achieved, but it now checks if slotnames corresponding to the variable is Symbol("") or not. Any better ideas are welcomed.

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.

3 participants