1

I am working with a solution that includes a .natvis in its tree. The workflow requires that I often start debug sessions of various solution's executables using devenv.exe's /DebugExe switch. But when started this way, the .natvis file isn't used by debugger.

I have tried to use /Command switch with Add Existing Item command, but it looks like since the debugged .exe isn't a proper solution or project, it's impossible to add anything to it (at least I have failed).

So the question is: is there a method to use the .natvis placed in an arbitrary path (not in user's profile where VisualStudio would automatically use it) in /DebugExe sessions?

Mike Kaganski
  • 701
  • 6
  • 18
  • like the title "Using Natvis files" and "Adding .natvis files to your projects" here: https://msdn.microsoft.com/en-us/library/jj620914.aspx, it showed the default path for .natvis. If you add it to your project, by default, Natvis files in our project are also inserted into the .pdb file built by the project. So if you debug your app, one issue is that whether it could load the pdb file. – Jack Zhai Nov 10 '17 at 01:50
  • Thanks @JackZhai-MSFT. However, this is not an option. The VS solution and projects aren't used for build. They are generated by the project's own build system for ease of developing and debugging. Possibly there's a command line option to include the natvis to generated PDBs... need to check. Still, this would increase the PDBs, and I'd prefer that standalone natvis could be used if possible. – Mike Kaganski Nov 10 '17 at 11:09
  • I will discuss with other members, if I get any update information, I will share it here. – Jack Zhai Nov 13 '17 at 02:50
  • What about this issue? Weiwei Cai shared the latest results after we discussed this issue, if you have any other issue, please feel free to let me know. – Jack Zhai Nov 17 '17 at 09:18

1 Answers1

2

You could use /NATVIS:filename to add your .native file to the .pdb file. It will embed the debugger visualizations defined in the Natvis file filename into the PDB file generated by LINK.

In addition, you could refer to the Deploying .natvis files part in the link Jack provided. We also could add the .natvis file to user directory or to a system directory. The order in which .natvis files are evaluated is as follows:

  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.
Weiwei
  • 3,674
  • 1
  • 10
  • 13
  • Thank you! I have implemented the /NATVIS solution in our project. Unfortunately, it's not the ideal solution. We keep expanding the natvis, and being unable to use the one in the solution, will have to use the one built-in at compile time. – Mike Kaganski Nov 17 '17 at 11:12
  • The specific pdb file was generated by your target.exe or dll: :https://blogs.msdn.microsoft.com/yash/2007/10/12/pdb-files-what-are-they-and-how-to-generate-them/, if your dll file was updated, it really has to be updated. Anyway, the Natvis really has these requirements. We also have to other better solution, but you could submit a feature request to the product team here: http://visualstudio.uservoice.com/forums/121579-visual-studio. The Visual Studio product team is listening to user voice there. – Jack Zhai Nov 20 '17 at 02:09