Open hkhk368 opened 6 months ago
This should be working in VS Code with 24.1 (make sure you have the 24.1 version of the extension, too).
This should be working in VS Code with 24.1 (make sure you have the 24.1 version of the extension, too).
@arthurevans Thank you for your reply, but I have already installed the latest version 24.1. However, I am still unable to perform step-by-step debugging, and breakpoints are not being successfully hit. Please refer to the screenshot at the top. As soon as I click 'debug' to run, it directly outputs the result without pausing at the breakpoint.
It works for me (VS Code):
It works for me (VS Code):
@RtyLiu Thank you for sharing. My environment is Ubuntu 22.04. I have installed the latest version of VS Code and the Mojo 24.1 plugin. Have I missed anything?
Is your VS Code Mojo extension v24.1.0?
Is your VS Code Mojo extension v24.1.0?
Yes. But not working.
Yes, you are right. I have tested and install it on another computer. The same Ubuntu, WSL 2, VS Code and Mojo extension for VS Code. It does not stop on breakpoint. The only difference is, that on the computer, where is working I have installed Mojo with Max . But I do not thing, that this the reason is.
Getting a parallel issue with debugging via vscode. I get personality set failed: Operation not permitted.
It does corectly detect the debugger since I see "Welcome to Mojo debugging" but vscode still fails.
Let me know if I should make a separate github issue. Posting it here as a comment since this is open still and generally related to vscode debugger support.
Mojo version is: mojo 24.2.1 (2f0dcf11) and the vscode extension is the same
Edit: Does not work for mojo 24.3.0 either
I see the same issue, not stopping at the right place, as well some crash messages on the debug console: sytem (Win 10, WSL 2, mojo 24.3)
i get this on a simple hello world program
error: JIT(0x7f98dfdd5000)(0x00007f98dfdd5000) The parsed MLIR structure type '!kgen.variant<struct<()>, scalar
I have the same experience (in WSL Ubuntu on Windows 11):
expression failed to parse (no further compiler diagnostics)
in the the graphical display for Variables or Watch, same in Debug Console.
Note for those interested. This might be an issue with "remote/docker" environments:
One of the last blocks in my docker does:
RUN echo 'settings set target.disable-aslr false' > '/home/fastrl_mojo_user/.lldbinit'
Note max-nightly.path should be mojo.path if you're just using mojo
RUN BASHRC=$( [ -f "$HOME/.bash_profile" ] && echo "$HOME/.bash_profile" || echo "$HOME/.bashrc" ) \
&& MOJO_PATH=$(modular config max-nightly.path) \
&& echo 'export MODULAR_HOME="'$HOME'/.modular"' >> "$BASHRC" \
&& echo 'export PATH="'$MOJO_PATH'/bin:$PATH"' >> "$BASHRC" \
&& echo 'export LLDBINIT=/home/fastrl_mojo_user/.lldbinit' >> "$BASHRC" \
&& source "$BASHRC"
I think the mojo nightly extension doesn't actually have a working debugger.
I suspect it is trying to do mojo-lldb tests/data/datapipes/base_test.mojo
which is wrong. It doesn't look
like its possible to make the launch.json
work correctly enough to make debugging via vscode possible. I don't think the vscode extension auto-gens the correct launch.json.
It should use mojo debug
not mojo-lldb
right?
Also there is no logging / errors in this situation.
This also still requires my above fix to make any of this possible.
Note the version mojo --version mojo 2024.8.305 (f99b2e40)
fastrl_mojo_user@josiah-laptop:~/fastrl_mojo$ mojo-lldb tests/data/datapipes/base_test.mojo
(lldb) target create "tests/data/datapipes/base_test.mojo"
error: '/home/fastrl_mojo_user/fastrl_mojo/tests/data/datapipes/base_test.mojo' is not a valid executable
(lldb) ^D
fastrl_mojo_user@josiah-laptop:~/fastrl_mojo$ mojo-lldb mojo tests/data/datapipes/base_test.mojo
(lldb) target create "mojo"
Current executable set to '/home/fastrl_mojo_user/.modular/pkg/packages.modular.com_nightly_max/bin/mojo' (x86_64).
(lldb) settings set -- target.run-args "tests/data/datapipes/base_test.mojo"
(lldb) r
Process 10797 launched: '/home/fastrl_mojo_user/.modular/pkg/packages.modular.com_nightly_max/bin/mojo' (x86_64)
Process 10797 stopped and restarted: thread 1 received signal: SIGCHLD
1
2
3
4
5
Process 10797 exited with status = 0 (0x00000000)
(lldb) ^D
fastrl_mojo_user@josiah-laptop:~/fastrl_mojo$ mojo debug tests/data/datapipes/base_test.mojo
Current executable set to '/home/fastrl_mojo_user/.modular/pkg/packages.modular.com_nightly_max/bin/mojo' (x86_64).
(lldb) r
Process 10941 launched: '/home/fastrl_mojo_user/.modular/pkg/packages.modular.com_nightly_max/bin/mojo' (x86_64)
Process 10941 stopped and restarted: thread 1 received signal: SIGCHLD
1
2
3
4
5
Review Mojo's priorities
What is your request?
I attempted to use breakpoints in VS Code for debugging, but the program did not pause at the breakpoint. I would like to inquire if it's possible to perform visual debugging with Mojo in either VS Code or PyCharm. If this feature is already available, could you please provide detailed instructions? I am a beginner in the Mojo language and have read through the following documentation, but it does not describe how to configure this: https://docs.modular.com/mojo/cli/debug.html. Thank you.
What is your motivation for this change?
This feature is very important for debugging.
Any other details?
I attempted to use breakpoints in VS Code for debugging, but the program did not pause at the breakpoint. I would like to inquire if it's possible to perform visual debugging with Mojo in either VS Code or PyCharm. If this feature is already available, could you please provide detailed instructions? I am a beginner in the Mojo language and have read through the following documentation, but it does not describe how to configure this: https://docs.modular.com/mojo/cli/debug.html. Thank you.