meg*_*uli 9 gdb visual-studio-code
我已经gdbserver附加到一个进程并且在远程机器上工作正常,端口 9999。在我的本地机器上,从命令行:
$ gdb
(gdb) target remote localhost:9999
Run Code Online (Sandbox Code Playgroud)
工作得很好。我正在尝试配置 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",
},
}
]
Run Code Online (Sandbox Code Playgroud)
这里有几个问题。首先,为什么是“程序”?在这种情况下,gdb 不需要任何程序名称来启动。程序已经在远程运行,gdbserver 已经连接到它。我只是想让 gdb 客户端连接到端口 9999。但无论如何,继续前进。
它要我提供一个 processId。这也没有意义,我已经在远程连接了。有趣的部分是:
当然,如果我使用调试器服务器地址,服务器已经附加到 PID 并且在这种情况下不能使用 processId 是有道理的。但是如果我忽略它,VS Code 会给出 1. 错误。这在某种程度上是循环的。
任何人都可以使用 gdbserver 地址附加到 VS Code C++ 调试器中的远程进程,这是我的问题。我的启动文件有什么问题?
您需要使用“ launch ”请求而不是“ attach ”。我还需要添加默认的“ cwd ”选项。
"request": "launch",
"cwd": "${workspaceFolder}",
Run Code Online (Sandbox Code Playgroud)
您可能还需要定义“ 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,
}
]
},
]
Run Code Online (Sandbox Code Playgroud)
}
| 归档时间: |
|
| 查看次数: |
6109 次 |
| 最近记录: |