【发布时间】:2020-05-24 15:32:22
【问题描述】:
在我的开发盒 (Windows) 上,我有一个 Visual Studio Code IoT Edge 工作区,其中包含我正在开发的 C++ IoT Edge 模块。我的开发盒运行 Windows,带有 Docker Desktop。
我在本地 IoT Edge 模拟器 (edgeHubDev) 中调试此模块时遇到问题。
我可以毫无问题地构建、部署和调试物理边缘设备,因此包含我的模块的容器已正确设置以进行调试。我可以设置和获取要命中的断点。
但是,当我“在模拟器中构建并运行解决方案”时,我无法设置断点。开始调试确实允许我选择模块进程,所以 VSCode 实际上是在与模块容器对话。
这是我正在使用的调试配置(launch.json):
{
"name": "edge simulator module",
"type": "cppdbg",
"request": "attach",
"program": "module",
"processId": "${command:pickRemoteProcess}",
"pipeTransport": {
"pipeCwd": "${workspaceFolder}",
"pipeProgram": "docker",
"pipeArgs": [
"exec",
"-i",
"module",
"sh",
"-c"
],
"debuggerPath": "/usr/bin/gdb"
},
"sourceFileMap": {
"/app": "${workspaceFolder}/modules/module"
},
"linux": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
},
VSCode 确实看到模块正在运行,因为我得到了调试输出窗口,当我终止 edgeHubDev 时该窗口消失了。
在容器运行时,我可以对映像运行 docker 命令(ps -ef、ls),因此我知道模块进程正在运行。
有什么想法为什么断点在“真正的”边缘设备中工作正常时不会命中?
【问题讨论】:
-
你看Debug in attach mode with IoT Edge Simulator (C#, Node.js, Java, Azure Functions)了吗?确认以下“C# 模块,包括用于 Azure Functions 的模块,支持在 Linux amd64 容器中调试”
-
是的,我做过 - 但不适用于我的 C++ 项目...
-
用VS2019调试的结果如何? docs.microsoft.com/en-us/azure/iot-edge/…
-
我没有VS2019....:P
-
它应该适用于 Visual Studio 2019 社区版。可以试试吗?
标签: visual-studio-code azure-iot-edge