使用 .natvis 文件在 VS Code 中可视化 C++ 对象

Using .natvis file to visualise C++ objects in VS Code(使用 .natvis 文件在 VS Code 中可视化 C++ 对象)

本文介绍了使用 .natvis 文件在 VS Code 中可视化 C++ 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据此链接,.natvis 文件可用于可视化原生对象.具体来说,我希望能够使用 Eigen::Matrix 对象.natvis?at=default&fileviewer=file-view-default%20eigen.natvis" rel="noreferrer">这个 .natvis 文件.

According to this link, .natvis files can be used to visualise native objects. Specifically, I would like to be able to inspect Eigen::Matrix objects using this .natvis file.

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

However, the link above does not contain any information on how to actually use a .natvis file in VS Code. Is it possible using a custom .natvis file?

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

Here is my launch.json file for reference:

{
    // 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"
        }
    ]
}

推荐答案

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

The launch.json file has has a visualizerFile option:

    {
        "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-properties

Some more documentation here (see the visualizerFile and showDisplayString table entries): https://docs.microsoft.com/en-us/cpp/build/launch-vs-schema-reference-cpp?view=vs-2019#c-linux-properties

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

You might also be interested in this issue: https://github.com/Microsoft/vscode-cpptools/issues/925

这篇关于使用 .natvis 文件在 VS Code 中可视化 C++ 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用 .natvis 文件在 VS Code 中可视化 C++ 对象

基础教程推荐