JuliaDebug / Debugger.jl

Julia debugger
MIT License
470 stars 43 forks source link

Setting breakpoint on function with kwargs causes break on every kwcall #327

Closed fredrikekre closed 2 months ago

fredrikekre commented 1 year ago
kw1(x; a=1, b=2) = kw2(; a=a, b=b)
kw2(; a=1, b=2) = a + b
function main()
    x = rand(3) # dummy call
    return kw1(x)
end
julia> @enter main()
In main() at REPL[2]:1
 1  function main()
>2      x = rand(3) # dummy call
 3      return kw1(x)
 4  end

About to run: (rand)(3)
1|debug> bp add kw1
[ Info: added breakpoint for function kw1
1] kw1

1|debug> c
Hit breakpoint:
In kw1(x) at REPL[1]:1
>1  1 ─ %1 = Main.:(var"#kw1#15")(1, 2, #self#, x)
 2  └──      return %1

About to run: (var"#kw1#15")(1, 2, kw1, [0.04154443090713811, 0.9738305759197099, 0.9342729568132503])
1|debug> c
Hit breakpoint:                                 # <----- ?????
In kw2(, ) at REPL[1]:1
>1  kw2(; a=1, b=2) = a + b

About to run: Core.NewvarNode(:(_4))
1|debug> c
3

Edit: Happens on both Julia 1.9.0-beta4 and master (even though the breakpoint looks slightly different), but not in Julia 1.8.5.

KristofferC commented 1 year ago

On 1.9:

julia> Core.kwfunc(kw1)
kwcall (generic function with 1514 methods)

On 1.8

julia> Core.kwfunc(kw1)
kw1##kw (generic function with 1 method)

This interacts badly with https://github.com/JuliaDebug/JuliaInterpreter.jl/pull/528.

staticfloat commented 1 year ago

I think I ran into this today; it's quite debilitating when trying to debug things in the DataFrames universe. Is there any reasonable workaround?