From 23a984cfe81269c603b841d99a33f7d211bac6f9 Mon Sep 17 00:00:00 2001 From: Ethan Boos Date: Sun, 5 Apr 2026 09:01:59 +0000 Subject: [PATCH 1/2] lldb configuration added --- .devcontainer/devcontainer.json | 3 +- .gitignore | 1 - .vscode/launch.json | 81 ++++++++++++ .vscode/tasks.json | 120 ++++++++++++++++++ .../ubuntu-24.04-slim-dependency-only | 1 + development-docs/CONTAINERIZED_DEVELOPMENT.md | 64 ++++++++++ 6 files changed, 268 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 93da8ac535..a286c303ac 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -27,7 +27,8 @@ "extensions": [ "llvm-vs-code-extensions.vscode-clangd", "ms-vscode.cmake-tools", - "twxs.cmake" + "twxs.cmake", + "vadimcn.vscode-lldb" ], "settings": { "clangd.path": "/usr/bin/clangd", diff --git a/.gitignore b/.gitignore index 93e184b09f..fe8a6e38c9 100644 --- a/.gitignore +++ b/.gitignore @@ -36,7 +36,6 @@ tags* **.swp **.DS_Store **.ccls* -.vscode env .idea* python/scrimmage/bindings diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..206f772809 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,81 @@ +{ + // Debug configurations for SCRIMMAGE + // Requires: Debug build (cmake -DCMAKE_BUILD_TYPE=Debug ..) + "version": "0.2.0", + "configurations": [ + { + "name": "Debug: scrimmage", + "type": "lldb", + "request": "launch", + "program": "${workspaceFolder}/build/bin/scrimmage", + "args": ["${workspaceFolder}/missions/straight-no-gui.xml"], + "cwd": "${workspaceFolder}", + "env": { + "SCRIMMAGE_DATA_PATH": "${workspaceFolder}/data", + "SCRIMMAGE_MISSION_PATH": "${workspaceFolder}/missions", + "SCRIMMAGE_PLUGIN_PATH": "${workspaceFolder}/build/plugin_libs:${workspaceFolder}/include/scrimmage/plugins", + "SCRIMMAGE_CONFIG_PATH": "${workspaceFolder}/config", + "SCRIMMAGE_KERNEL_PATH": "${workspaceFolder}/src/gpu/kernels", + "LD_LIBRARY_PATH": "${workspaceFolder}/build/lib:${workspaceFolder}/build/plugin_libs", + "JSBSIM_ROOT": "${workspaceFolder}/data" + }, + "stopOnEntry": false + }, + { + "name": "Debug: scrimmage (pick mission)", + "type": "lldb", + "request": "launch", + "program": "${workspaceFolder}/build/bin/scrimmage", + "args": ["${input:missionFile}"], + "cwd": "${workspaceFolder}", + "env": { + "SCRIMMAGE_DATA_PATH": "${workspaceFolder}/data", + "SCRIMMAGE_MISSION_PATH": "${workspaceFolder}/missions", + "SCRIMMAGE_PLUGIN_PATH": "${workspaceFolder}/build/plugin_libs:${workspaceFolder}/include/scrimmage/plugins", + "SCRIMMAGE_CONFIG_PATH": "${workspaceFolder}/config", + "SCRIMMAGE_KERNEL_PATH": "${workspaceFolder}/src/gpu/kernels", + "LD_LIBRARY_PATH": "${workspaceFolder}/build/lib:${workspaceFolder}/build/plugin_libs", + "JSBSIM_ROOT": "${workspaceFolder}/data" + }, + "stopOnEntry": false + }, + { + "name": "Debug: Current Test File", + "type": "lldb", + "request": "launch", + "program": "${workspaceFolder}/build/test/${fileBasenameNoExtension}", + "args": [], + "cwd": "${workspaceFolder}", + "env": { + "SCRIMMAGE_DATA_PATH": "${workspaceFolder}/data", + "SCRIMMAGE_MISSION_PATH": "${workspaceFolder}/missions", + "SCRIMMAGE_PLUGIN_PATH": "${workspaceFolder}/build/plugin_libs:${workspaceFolder}/include/scrimmage/plugins", + "SCRIMMAGE_CONFIG_PATH": "${workspaceFolder}/config", + "LD_LIBRARY_PATH": "${workspaceFolder}/build/lib:${workspaceFolder}/build/plugin_libs" + }, + "preLaunchTask": "build-tests", + "stopOnEntry": false + }, + { + "name": "Debug: Attach to Process", + "type": "lldb", + "request": "attach", + "pid": "${command:pickProcess}" + } + ], + "inputs": [ + { + "id": "missionFile", + "type": "pickString", + "description": "Select a mission file", + "options": [ + "missions/straight-no-gui.xml", + "missions/straight.xml", + "missions/capture-the-flag.xml", + "missions/predator_prey_boids.xml", + "missions/cars.xml" + ], + "default": "missions/straight-no-gui.xml" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000..e2e42082a6 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,120 @@ +{ + // Build and test tasks for SCRIMMAGE + "version": "2.0.0", + "tasks": [ + { + "label": "cmake-configure", + "type": "shell", + "command": "cmake", + "args": [ + "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", + "-DCMAKE_BUILD_TYPE=${input:buildType}", + ".." + ], + "options": { + "cwd": "${workspaceFolder}/build" + }, + "group": "build", + "problemMatcher": [] + }, + { + "label": "cmake-configure-debug", + "type": "shell", + "command": "cmake", + "args": [ + "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", + "-DCMAKE_BUILD_TYPE=Debug", + ".." + ], + "options": { + "cwd": "${workspaceFolder}/build" + }, + "group": "build", + "problemMatcher": [] + }, + { + "label": "build", + "type": "shell", + "command": "make", + "args": ["-j${input:jobs}"], + "options": { + "cwd": "${workspaceFolder}/build" + }, + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": "$gcc" + }, + { + "label": "build-tests", + "type": "shell", + "command": "make", + "args": ["-j8"], + "options": { + "cwd": "${workspaceFolder}/build" + }, + "group": "build", + "problemMatcher": "$gcc" + }, + { + "label": "clean", + "type": "shell", + "command": "make", + "args": ["clean"], + "options": { + "cwd": "${workspaceFolder}/build" + }, + "group": "build", + "problemMatcher": [] + }, + { + "label": "rebuild", + "dependsOn": ["clean", "build"], + "dependsOrder": "sequence", + "group": "build", + "problemMatcher": [] + }, + { + "label": "test", + "type": "shell", + "command": "ctest", + "args": ["--output-on-failure"], + "options": { + "cwd": "${workspaceFolder}/build" + }, + "group": { + "kind": "test", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "test-verbose", + "type": "shell", + "command": "ctest", + "args": ["--output-on-failure", "-V"], + "options": { + "cwd": "${workspaceFolder}/build" + }, + "group": "test", + "problemMatcher": [] + } + ], + "inputs": [ + { + "id": "buildType", + "type": "pickString", + "description": "Select build type", + "options": ["Debug", "Release", "RelWithDebInfo"], + "default": "Debug" + }, + { + "id": "jobs", + "type": "pickString", + "description": "Number of parallel jobs", + "options": ["4", "8", "12", "16"], + "default": "8" + } + ] +} diff --git a/ci/dockerfiles/ubuntu-24.04-slim-dependency-only b/ci/dockerfiles/ubuntu-24.04-slim-dependency-only index e90f9cbc00..4229d7f274 100644 --- a/ci/dockerfiles/ubuntu-24.04-slim-dependency-only +++ b/ci/dockerfiles/ubuntu-24.04-slim-dependency-only @@ -12,6 +12,7 @@ RUN apt-get update && apt-get install -y \ qtbase5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev \ vim \ clangd \ + lldb \ && apt-get clean && rm -rf /var/lib/apt/lists/* # Set working directory to /root/scrimmage on container start diff --git a/development-docs/CONTAINERIZED_DEVELOPMENT.md b/development-docs/CONTAINERIZED_DEVELOPMENT.md index fe7ca8940d..7094ea5fc0 100644 --- a/development-docs/CONTAINERIZED_DEVELOPMENT.md +++ b/development-docs/CONTAINERIZED_DEVELOPMENT.md @@ -131,6 +131,70 @@ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. --- +## Debugging with LLDB (VS Code) + +The devcontainer includes LLDB and the CodeLLDB extension for integrated debugging. + +### Setup (one-time) + +Build with debug symbols: +```bash +cd /root/scrimmage/build +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. +make -j$(nproc) +``` + +Or use the VS Code task: `Ctrl+Shift+P` → "Tasks: Run Task" → "cmake-configure-debug" + +### Debug a Mission + +1. Set breakpoints in your code (click left gutter) +2. Press `F5` or go to Run → Start Debugging +3. Select "Debug: scrimmage" (uses `missions/straight-no-gui.xml`) + +For other missions: use "Debug: scrimmage (pick mission)" + +### Debug Tests + +1. Open a test file (e.g., `test/test_quaternion.cpp`) +2. Set breakpoints +3. Run "Debug: Current Test File" from the debug dropdown + +### Available Debug Configurations + +Found in the **debug dropdown** (top of Run and Debug panel, `Ctrl+Shift+D`): + +| Config | Description | +|--------|-------------| +| Debug: scrimmage | Run scrimmage with straight-no-gui.xml | +| Debug: scrimmage (pick mission) | Choose from common mission files | +| Debug: Current Test File | Debug test executable matching open file (e.g., `test_quaternion.cpp` → `build/test/test_quaternion`) | +| Debug: Attach to Process | Attach to a running scrimmage process | + +### Available Build Tasks + +Run via `Ctrl+Shift+P` → "Tasks: Run Task": + +| Task | Description | +|------|-------------| +| cmake-configure | Configure with selectable build type | +| cmake-configure-debug | Configure with Debug build type | +| build | Build with parallel jobs (default task) | +| test | Run all tests with ctest | +| clean | Clean build artifacts | +| rebuild | Clean then build | + +### Terminal Debugging (without VS Code) + +```bash +source ~/.scrimmage/setup.bash +cd /root/scrimmage +lldb build/bin/scrimmage -- missions/straight-no-gui.xml +# step through debug with keybindings +``` + +--- + ## Neovim LSP with Docker Configure clangd to exec into a running container: From 4e8be70cf81ad3a1d5522e445b34aea72490c235 Mon Sep 17 00:00:00 2001 From: Ethan Boos Date: Mon, 6 Apr 2026 22:46:15 +0000 Subject: [PATCH 2/2] .vscode whitelisting --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index fe8a6e38c9..b98c854545 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,6 @@ env .idea* python/scrimmage/bindings python/dist +.vscode/* +!.vscode/launch.json +!.vscode/tasks.json