14

根据此链接,.natvis 文件可用于可视化本机对象。具体来说,我希望能够使用这个 .natvis 文件Eigen::Matrix来检查对象。

但是,上面的链接不包含有关如何在 VS Code 中实际使用 .natvis 文件的任何信息。是否可以使用自定义 .natvis 文件?

这是我的launch.json文件供参考:

{
    // 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": [
        {
            "name": "g++-8 build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "g++-8 build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}
4

1 回答 1

9

launch.json 文件有一个 VisualizerFile 选项:

    {
        "name": "g++-8 build and debug active file",
        "visualizerFile": "${workspaceFolder}/path/to/file.natvis",
        "showDisplayString": true,
        ...
    },

此处提供更多文档(请参阅 VisualizerFile 和 showDisplayString 表条目): https ://docs.microsoft.com/en-us/cpp/build/launch-vs-schema-reference-cpp?view=vs-2019#c- linux-属性

您可能也对此问题感兴趣: https ://github.com/Microsoft/vscode-cpptools/issues/925

于 2020-03-02T22:37:23.887 回答