julia-vscode icon indicating copy to clipboard operation
julia-vscode copied to clipboard

Debugger does not respect breakpoints Do-Block syntax

Open julior-ox opened this issue 2 years ago • 3 comments

What works

json_file = "/path/to/my/file.json"
f = open(json_file, "r")
fc = read(f, String) # breakpoint here
print(fc)
close(f)

Not working:

json_file = "/path/to/my/file.json"

open(json_file, "r") do f
    fc = read(f, String) # breakpoint here
    print(fc)
end

The debugger will ignore set breakpoint in line fc = read(f, String).

julior-ox avatar May 08 '22 14:05 julior-ox

This works fine when you clear the functions set as compiled/interpreted with e.g. Julia: Clear compiled modules/functions. Bit sad that the defaults don't work for this case though.

pfitzseb avatar May 09 '22 15:05 pfitzseb

Thanks again for you quick answer @pfitzseb .

Wow, this indeed works! The workaround deserves its explanation in the docs, I would say. Or is is possible to integrate this somewhere as pre-debug Hook?

julior-ox avatar May 09 '22 16:05 julior-ox

Disabling all compiled modules and functions will make the debugger very slow. A step in the right direction is to make Base.open as interpreted while keeping the existing stuff as compiled. By doing so, we can step inside open, like you can see bellow. The remaining problem is that the debugger does not advance into the try catch block. Probably I have to further enable some Base.xyz stuff as interpreted. Any hints?

image image

Here is my settings.json related config (julia-vscode minimum version 1.6.31)

"julia.debuggerDefaultCompiled": [        
        "ALL_MODULES_EXCEPT_MAIN",
        "-JpegTurbo.",                 
        "-FileIO.",
        "-Base.open",                                          
    ],

MariusDrulea avatar Aug 12 '22 19:08 MariusDrulea

I also just encountered this. Glad there was a workaround. Is there any update on improving this functionality, or are we stuck with this same workaround?

Edit: I spoke too soon and this doesn't work for me somehow. For now I am reverting to manually opening and closing the file to use the debugger.

graphitical avatar Dec 23 '22 18:12 graphitical