c++ - 有没有一种方法可以自动将 .natvis 附加到使用 -DebugExe 启动的调试 session ?

标签 c++ visual-studio-2015 visual-studio-2017 visual-studio-debugging natvis

我正在使用一个在其树中包含 .natvis 的解决方案。工作流程要求我经常使用 devenv.exe 的 /DebugExe switch 启动各种解决方案的可执行文件的调试 session 。 .但是当以这种方式启动时,.natvis 文件不会被调试器使用。

我试过使用/Command switchAdd Existing Item command , 但看起来因为调试的 .exe 不是一个合适的解决方案或项目,所以不可能向它添加任何东西(至少我失败了)。

所以问题是:是否有一种方法可以在/DebugExe session 中使用放置在任意路径(而不是 VisualStudio 会自动使用它的用户配置文件中)的 .natvis?

最佳答案

你可以使用 /NATVIS:filename将您的 .native 文件添加到 .pdb 文件。它将 Natvis 文件文件名中定义的调试器可视化嵌入到 由 LINK 生成的 PDB 文件中。

此外,您可以引用Deploying .natvis files jack 提供的链接的一部分。我们还可以将 .natvis 文件添加到用户目录或系统目录。评估 .natvis 文件的顺序如下:

  1. natvis files embedded in a .pdb you are debugging (unless a file of the same name exists in a loaded project)
  2. natvis files that are part of a loaded C++ projects or a top-level solution item. This includes all loaded C++ projects, including class libraries, but it does not include projects of other languages (e.g. you can’t load a .natvis file from a C# project). For executable projects, you should use the solution items to host any .natvis files that are not already present in a .pdb, since there is no C++ project available.
  3. The user-specific natvis directory (%USERPROFILE%\My Documents\Visual Studio 2015\Visualizers
  4. The system-wide Natvis directory (%VSINSTALLDIR%\Common7\Packages\Debugger\Visualizers). This is where .natvis files that are installed with Visual Studio are copied. You can add other files to this directory as well if you have administrator permissions.

关于c++ - 有没有一种方法可以自动将 .natvis 附加到使用 -DebugExe 启动的调试 session ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47203308/

相关文章:

c++ - 如何在基类构造函数中为每个子类执行特定任务

cordova - 运行 Visual Studio 2015 RC 和 MS Android 模拟器时定位 adb.exe 时出错

windows - Visual Studio Express 2015 - Windows 服务

visual-studio-2017 - 停留在 Visual Studio 2017 中创建项目

c++ - 在 C++ OpenMP 中为每个线程定义一个优先级队列

c++ - 字符串复制说缓冲区太小,strcpy_s源问题

typescript - 如何在 VS 2017 中调试 typescript 代码?

setup-project - 在 VS2017 中构建安装程序项目会导致 "Configuring VS2013"消息”

c++ - 如何将 typename 传递给我不想模板化的类?

c++ - 标准库中的 Visual Studio 编译错误