用gdb调试c++时如何在vscode中查看多态类型?

问题描述 投票:0回答:1

当使用 gdb 在 VS Code 中调试多态类型时,调试窗格仅将其显示为指向变量类型的指针,即抽象基类。但是,当使用 qtcreator 进行调试时,会显示正确的具体类型。如何才能让 vscode 有类似的调试体验?

c++ visual-studio-code gdb qt-creator
1个回答
0
投票

在 VS code 中,将以下内容添加到您正在使用的启动配置中(请参阅

launch.json
文件):

"setupCommands": [
    {
        "text": "set print object on",
        "description": "enables to identify the actual (derived) type of an object",
        "ignoreFailures": true
    }
]

背景: 在 VS Code 中启动调试会话时,这将启用 GDB 的

print object
设置。 GDB 中此设置的默认值为
off
。请参阅此处

© www.soinside.com 2019 - 2024. All rights reserved.