How to configure execution arguments for mojo-lldb in VSCode

Is there a way to pass command-line parameters to the Mojo debugger, so that the following code prints out: I'm looking for the launcher.json configuration that would be equivalent to:
$ mojo debug -D DEBUG ./debug_mode.mojo
$ mojo debug -D DEBUG ./debug_mode.mojo
So that I can get the code below: debug_mode.mojo
from sys import is_defined

alias DEBUG = is_defined["DEBUG"]()

fn main() raises:
@parameter
if DEBUG: print("\nIn debug ...")

print("\nDone.")
from sys import is_defined

alias DEBUG = is_defined["DEBUG"]()

fn main() raises:
@parameter
if DEBUG: print("\nIn debug ...")

print("\nDone.")
To print out the following, when I Start Debugging
text
In debug ...

Done.
text
In debug ...

Done.
I believe this is the correct json block to edit, but I cannot find the correct parameters to configure.
"configurations": [
{
"type": "mojo-lldb",
"request": "launch",
"name": "Mojo: Debug Current Mojo file",
"description": "Launch and debug a Mojo file given its path.",
"mojoFile": "${file}",
"args": ["-D", "DEBUG"],
"env": [],
"cwd": "${workspaceFolder}",
"runInTerminal": false
},
"configurations": [
{
"type": "mojo-lldb",
"request": "launch",
"name": "Mojo: Debug Current Mojo file",
"description": "Launch and debug a Mojo file given its path.",
"mojoFile": "${file}",
"args": ["-D", "DEBUG"],
"env": [],
"cwd": "${workspaceFolder}",
"runInTerminal": false
},
as you can see I've tried setting "args": ["-D", "DEBUG"],, but that sets the command line arguments for debug_mode.mojo. If this can only be done in another way, please can someone direct me to the path of enlightenment.
3 Replies
Darkmatter
Darkmatter2mo ago
You can invoke it by hand, mojo-lldb, and that opens up some features that vscode doesn't really expose properly, like disassembling functions.
Robert
Robert2mo ago
is lldb the default debugger for mojo? I ran into it as I’ve been brute forcing my way thru mojo 😂 idk what the best way to learn programming is but I learn best thru trial by fire pun intended
Darkmatter
Darkmatter2mo ago
mojo-lldb is the one you should start with. Occasionally mojo-lldb breaks and you have to go get gdb out since it often doesn't have the feature that is causing the crash.

Did you find this page helpful?