debugging - 使用 VS Code 进行调试不起作用。没有变量,调用堆栈等
问题描述
我想使用 VSCode 和 WSL 进行开发。我在调试 Go 应用程序时遇到问题,我不知道为什么。我没有看到调用堆栈中的东西,没有变量,而且从断点跳转到断点的按钮都是灰色的。我的调试控制台日志很干净,没有错误(请参阅下面的详细信息)我尝试按照这些文章来设置我的环境:
https://github.com/Microsoft/vscode-go/wiki/GOPATH-in-the-VS-Code-Go-extension https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code -使用-VS-代码
所以我做的详细:
首先,我告诉 VSCode 从当前工作区动态设置我的 GOPATH,并通过 go.toolsGopath 将 GooTools 安装与我的 GOPATH 分开。我的 settings.json 看起来像这样:
{
"go.inferGopath": true,
"go.toolsGopath": "/mnt/c/Users/cloudnaut/gospace/gotools",
}
所以我的 GoTools 安装到 /mnt/c/Users/cloudnaut/gospace/gotools。我还安装了 dlv 调试器。我的 go 工作目录也是/mnt/c/Users/cloudnaut/gospace/go
它具有常见的 go 项目结构:
.
├── bin
├── pkg
└── src
└── github.com
└── cloudnaut
└── project1
└── main.go
一切似乎都很好。Go:Install/Update Tools
安装在我的单独路径中。而且我的 GOPATH 结构也有效。我使用GO:Current GOPATH
它显示了我想要的正确 GOPATH,go install
还从 /bin 中的 main.go 创建了 go 二进制文件。完美的 ...
现在我想开始调试。我只是用一个简单的launch.json文件直接指向我的main.go
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"showLog": true,
"type": "go",
"request": "launch",
"mode": "auto",
"program": "/mnt/c/Users/cloudnaut/gospace/go/src/github.com/cloudnaut/project1/main.go",
"env": {},
"args": []
}
]
}
因此,当我现在开始调试(断点设置并显示在 BREAKPOINTS 下)时,他在文件夹 a 中创建__debug_bin
。但是在我的 vscode 调试器界面中,我看不到任何变量和堆栈跟踪。问题是,我现在也看到错误或其他东西。我的带有该选项的调试控制台showLog: true
几乎是干净的。它只包含以下几行:
API server listening at: 127.0.0.1:34477
2019-12-19T13:55:52+01:00 info layer=debugger launching process with args: [/mnt/c/Users/cloudnaut/gospace/go/src/github.com/cloudnaut/project1/__debug_bin]
没有其他的。调试器中的“step over/step info/Step out”按钮显示为灰色。我只能按暂停,重新启动和停止。
看:
解决方案
我为自己的问题带来了解决方案:
问题是 Go dlv 调试器不能与 WSL 1 一起使用,因为一些不受支持的系统调用。它仅适用于 WSL 2,它仅包含在 Microsoft 内部版本中。
推荐阅读
- c# - C#中封装对象的Json反序列化
- power-automate - 如何创建流以在 Microsoft Flow 中移动文件夹
- node.js - Microsoft bot 框架:上传时附件的数量是否有限制?
- amazon-web-services - 使用 AWS 实现 http 请求缓冲区
- rust - 如何将库中的源文件导入 build.rs?
- javafx - JavaFx,Scene Builder:如何在控制器类中自动获取 Scene Builder 中的元素声明?
- php - Dropzone 在桌面和安卓浏览器上运行良好,但在 iPhone 浏览器上无法上传视频
- spring-boot - Spring Controller Get REST API 被第三方服务认证的用户访问时被多次调用
- python - 如何在 Windows 命令行中使用 python 'input' 函数?
- python-3.x - 在 Django 中实现的建议