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

Break point on line stops at an awkward place #569

Open
KristofferC opened this issue Apr 3, 2023 · 2 comments
Open

Break point on line stops at an awkward place #569

KristofferC opened this issue Apr 3, 2023 · 2 comments

Comments

@KristofferC
Copy link
Member

function f_debug(x)
    out = []
    for i in x
        push!(out, 2i)
    end
    out
end
julia> @enter f_debug(rand(10))
In f_debug(x) at /home/kc/demo.jl:14
 14  function f_debug(x)
>15      out = []
 16      for i in x
 17          push!(out, 2i)
 18      end
 19      out
 20  end

About to run: (Base.vect)()
1|debug> bp add 17
1] /home/kc/demo.jl:17

1|debug> c
Hit breakpoint:
In f_debug(x) at /home/kc/demo.jl:14
 14  function f_debug(x)
 15      out = []
 16      for i in x
>17          push!(out, 2i)
 18      end
 19      out
 20  end

About to run: _J4

The "About to run: _J4" is probably a bad place to stop at.

@KristofferC
Copy link
Member Author

KristofferC commented Apr 24, 2023

What happens here is that the first statement on the given line nr is an assignment:

In f_debug(x) at /Users/kristoffercarlsson/JuliaPkgs/JuliaInterpreter.jl/test.jl:1
  7  2 ┄ %7  = @_3
  8  │         i = Core.getfield(%7, 1)
  9  │   %9  = Core.getfield(%7, 2)
●10  │   %10 = out
 11  │   %11 = 2 * i
 12  │         Base.push!(%10, %11)

We could skip ahead to the next call via:

diff --git a/src/commands.jl b/src/commands.jl
index b1f68ad..c4e094a 100644
--- a/src/commands.jl
+++ b/src/commands.jl
@@ -514,7 +514,13 @@ function debug_command(@nospecialize(recurse), frame::Frame, cmd::Symbol, rootis
         if cmd === :c
             r = root(frame)
             ret = finish_stack!(recurse, r, rootistoplevel)
-            return isa(ret, BreakpointRef) ? (leaf(r), ret) : nothing
+            if isa(ret, BreakpointRef)
+                newframe = leaf(frame)
+                maybe_next_call!(recurse, newframe, istoplevel)
+                return newframe, ret
+            else
+                return nothing
+            end
         end
         cmd === :finish && return maybe_reset_frame!(recurse, frame, finish!(recurse, 
frame, istoplevel), rootistoplevel)
     catch err

Is that the best solution? Any opinions?

@timholy
Copy link
Member

timholy commented Apr 24, 2023

Yeah, that seems like a sensible solution to me. Agreed the current situation is not ideal.

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

No branches or pull requests

2 participants