我已将gdbserver
附加到进程,并且可以在远程计算机的端口9999上正常工作。
$ gdb
(gdb) target remote localhost:9999
工作正常。我正在尝试配置Vs Code调试器,以便在这种情况下可以拥有GDB前端。这是我的启动JSON。
"version": "0.2.0",
"configurations": [
{
"name": "GDB",
"type": "cppdbg",
"request": "attach",
"miDebuggerServerAddress": "localhost:9999",
"program": "path-to-cross-compiled-binary-with-same-debug-symbols",
"linux": {
"MIMode": "gdb",
},
}
]
这里有几个问题。首先,为什么要“编程”?在这种情况下,gdb不需要任何程序名称即可启动。程序已在远程运行,gdbserver已连接到它。我只希望gdb客户端连接到端口9999。但是无论如何,继续前进。
它希望我提供一个processId。这也没有意义,我已经连接到远程了。有趣的部分是:
当然,如果我使用的是调试器服务器地址,则服务器已经连接到PID,在这种情况下不能使用processId是有意义的。但是,如果我忽略了它,VS Code将给出1.错误。这在某种程度上是循环的。
任何人都可以使用gdbserver地址将其附加到VS Code C ++调试器中的远程进程。我的启动文件怎么了?
答案 0 :(得分:0)
您需要使用“ 启动”请求,而不是“ 附加”。我还需要添加默认的“ cwd ”选项。
"request": "launch",
"cwd": "${workspaceFolder}",
您可能还需要定义“ additionalSOLibSearchPath ”。
我的启动配置现在看起来像这样:
{
// 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": [
{
// "processId": "${command:pickProcess}",
"name": "(gdb) Remote Attach",
"type": "cppdbg",
"request": "launch",
"program": ".\\src\\binaryfolder\\app.nostrip",
"additionalSOLibSearchPath": "arm-none-linux-gnueabi/libc/lib;./lib;C:\\DeviceSDK\\win-2.8.15\\sdk\\toolchains\\arm-4.4.1\\arm-none-linux-gnueabi\\libc\\lib;C:\\DeviceSDK\\win-2.8.15\\sdk\\platforms\\201205\\lib",
// "processId": "${command:pickProcess}",
"MIMode": "gdb",
"cwd": "${workspaceFolder}",
"miDebuggerPath": "C:\\DeviceSDK\\win-2.8.15\\sdk\\toolchains\\arm-4.4.1\\bin\\arm-none-linux-gnueabi-gdb.exe",
"miDebuggerServerAddress": "192.168.205.88:51000",
"miDebuggerArgs": " -ex 'handle all print nostop noignore'",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true,
}
]
},
]
}