Visual Studio Code

From dreamcast.wiki
Revision as of 17:31, 6 January 2023 by Unknown user (talk) (Created page with "This is a guide to setup your Visual Studio Code project with debugging support on both real hardware using dcload-ip and with the lxdream-nitro emulator. == Setup Build...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a guide to setup your Visual Studio Code project with debugging support on both real hardware using dcload-ip and with the lxdream-nitro emulator.

Setup Build Tasks (Optional)

This is an option step as you are able to just specify and launch ELFs. Setting up a build task in VSCode will allow your code to rebuild before launching the debug session.

Use the following template to create your own .vscode/tasks.json file:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "type": "shell",
            "command": "make",
            "args": [
                "all"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
        },
    ]
}

Setup lxdream-nitro Launch Task

Setup a launch configuration for lxdream-nitro in your .vscode/launch.json file:

{
    "version": "0.2.0",
    "configurations": [
         {
            // display name
            "name": "LXDream",
            "type": "cppdbg",
            "request": "launch",
            // match build task name in tasks.json
            "preLaunchTask": "Build",
            "cwd": "${workspaceRoot}",
            // path to elf
            "program": "${workspaceRoot}/hello.elf",
            // path to gdb
            "miDebuggerPath": "PATH_TO_GDB",
            "setupCommands": [{
                "text": "set architecture sh",
                "description": "Set GDB Arch to SuperH",
                "ignoreFailures" : false,
            }],
            "miDebuggerServerAddress": ":9999",
            // path to lxdream-nitro
            "debugServerPath": "PATH_TO_LXDREAM",
            // lxdream-nitro flags
            "debugServerArgs": "--log=DEBUG --gdb-sh4=9999 -A null -e ${workspaceRoot}/hello.elf -n",
            "filterStdout": true,
            "filterStderr": true,
            "externalConsole": false,
            // run on connect
            "stopAtConnect": false,
            // stop at main
            "stopAtEntry": true,
            "launchCompleteCommand": "exec-run",
            "serverStarted": "SH4 GDB server running on port",
            "useExtendedRemote": true
        },
    ]
}