hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
294 stars 24 forks source link

Zig: debug with vscode #375

Open hhstore opened 2 years ago

hhstore commented 2 years ago

related:

hhstore commented 2 years ago

Zig + vscode 配置 debug 断点调试:

准备工作:

关于如何配置 zig+zls+vscode, 请看此篇: #361

Debug 示例:

示例:

zig build.zig 构建脚本修改:

image

dev@dev:~/D/i/b/ziglings-solutions|solutions✓
➤ zig build 15

Compiling 015_for.zig...
Checking 015_for.zig...
Zig Build Result: /xxx/ziglings-solutions/zig-cache/o/a9333ffcfddf7b471e7e17163202b638/015_for
PASSED:

vscode 配置:

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug ex002",
            // "program": "${workspaceFolder}/<executable file>",
            "program": "${workspaceFolder}/zig-cache/o/61ece68b736d12a98d44010040aab147/002_std",
            "args": [
                "exercises/002_std.zig"
            ],
            "cwd": "${workspaceFolder}"
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug ex015",
            // "program": "${workspaceFolder}/<executable file>",
            "program": "${workspaceFolder}/zig-cache/o/a9333ffcfddf7b471e7e17163202b638/015_for",
            "args": [
                "exercises/015_for.zig"
            ],
            "cwd": "${workspaceFolder}"
        }
    ]
}

截图效果:

image image image
hhstore commented 2 years ago

reference:

hhstore commented 2 years ago

1

hhstore commented 2 years ago

1

hhstore commented 2 years ago

1

hhstore commented 2 years ago

1

hhstore commented 2 years ago

1