zig调试

zig调试要配置三个文件

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Single Zig File",
            "type": "lldb",
            "request": "launch",
            "program": "${workspaceFolder}/BCompare",
            "args": [],
            "cwd": "${workspaceFolder}",
            "preLaunchTask": "build_single_debug",
            "console": "integratedTerminal",
            "env": {
                "LLDB_USE_NATIVE_PDB_READER": "yes"
            },
            
        }
    ]
}

\

settings.json

{
  // 手动指定 Zig 可执行文件路径
  "zig.executablePath": "D:\\zig-x86_64-windows-0.17.0-dev.813\\zig.exe",
  // 开启 ZLS 语言服务
  "zig.zls.enabled": "on",
  // 【必加】指定同版本 ZLS 路径(和 Zig 放在同一目录)
  //"zig.zls.path": "D:\\zig-x86_64-windows-0.17.0-dev.813\\zls.exe",
  // 保存自动格式化
  "[zig]": {
    "editor.formatOnSave": true
  },
  "zig.formatOnType": false,
  "zig.buildOnSaveProvider": false
}

\

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build_single_debug",
            "type": "shell",
            "command": "zig",
            "args": [
                "build-exe", 
                "main.zig", 
                "-Doptimize=Debug",
                "--name",
                "BCompare"
            ],
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

更多推荐