在VSCODE中使用GDB调试时如何加载符号

发布于 2025-01-27 13:41:30 字数 1134 浏览 4 评论 0原文

环境:Windows 10上的WSL Ubuntu20.04

GDB:GDB-Multiarch(GNU GDB 9.2)

vscode版本:1.67.0

我正在尝试在VSCODE上使用GDB进行调试。 如果我在ubuntu中使用命令行与GDB服务器连接,并将Symboal加载到我的目标设备。它正常工作。

$gdb-multiarch main
$(gdb)target remote:2331
$(gdb)load
$(gdb)c

ubuntu command-line上的屏幕快照(正常工作)

但是,我想在vscode上做同样的事情。

修改我的启动。JSON文件后,VSCODE中的GDB调试器只能“附加” 到我的目标设备。 没有加载的符号。这是我的启动.json

"configurations": [
    {
        "name": "GDB Launch",
        "type": "cppdbg",
        "request": "launch",
        "cwd": "${workspaceFolder}",
        "program": "${workspaceFolder}/main",
        "stopAtEntry": true,
        "linux": {
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb-multiarch",
            "miDebuggerServerAddress": "localhost:2331"
        },
    }
]

我是否想念需要在配置中填写的任何属性?

感谢您的任何评论和帮助:)

Environment: WSL Ubuntu20.04 on Windows 10

GDB: gdb-multiarch (GNU gdb 9.2)

VSCODE version: 1.67.0

I'm trying to debug with GDB on VSCODE.
If I use command-line in Ubuntu to connect with GDB server and load symboal to my target device. It works normally.

$gdb-multiarch main
$(gdb)target remote:2331
$(gdb)load
$(gdb)c

Screenshot on Ubuntu command-line (Works normally)

However, I wanna do the same thing on VSCODE.

After modifying my launch.json file, the GDB debugger in VSCODE can only "attach" to my target device. There is no any symbol loaded. Here is my launch.json.

"configurations": [
    {
        "name": "GDB Launch",
        "type": "cppdbg",
        "request": "launch",
        "cwd": "${workspaceFolder}",
        "program": "${workspaceFolder}/main",
        "stopAtEntry": true,
        "linux": {
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb-multiarch",
            "miDebuggerServerAddress": "localhost:2331"
        },
    }
]

Did I miss any propertey which needs to be filled in the configurations?

Thanks for any comments and helping:)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷…雨湿花 2025-02-03 13:41:30

您可以打开日志以查看发生了什么:

"logging": {
    "moduleLoad": true,
    "engineLogging": true,
    "trace": true
},

可能会有一些影响符号负载的配置,例如solib-search-pathsysroot,您可以检查并添加setupCommands中的配置

"setupCommands": [
    {
         "description": "Set sysroot ",
         "text": "set sysroot <path_to_sysroot>"
    },
    {
         "description": "Set solib",
         "text": "set solib-search-path <path_to_solib_search_path>"
    }
]

You can open logs to see what happened:

"logging": {
    "moduleLoad": true,
    "engineLogging": true,
    "trace": true
},

There may be some configurations that affect the symbol load, such as solib-search-path, sysroot, you can check and add the configs in setupCommands

"setupCommands": [
    {
         "description": "Set sysroot ",
         "text": "set sysroot <path_to_sysroot>"
    },
    {
         "description": "Set solib",
         "text": "set solib-search-path <path_to_solib_search_path>"
    }
]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文