4

In my company we are working with native visualisers (.natvis files) for debugging memory dumps in Visual Studio.

As we have equal class names for different projects, we are thinking of including .natvis files in the project definitions, and this seems to be working: the .natvis files get embedded in the symbol files (*.pdb) during the build, which is a good thing.

Unfortunately it now seems to be impossible to do any customisation: from both .natvis files (the file on PC and the one in the symbol file) the one in the symbol file gets priority, which makes it unchangeable, so no customisation seems to be possible anymore.

In order to have customisable .natvis files, we are thinking of altering the .natvisreload sequence. Is this possible or is there another approach for this (like adding parameters to the .natvisreload command)?

Dominique
  • 16,450
  • 15
  • 56
  • 112
  • Could you embed natvis file into a separate module instead of the main one? – KonstantinL Nov 20 '17 at 14:52
  • Yes, that is possible, but now I have the problem that, during linking, it gets embedded into the symbols file, making it impossible to modify afterwards. – Dominique Nov 20 '17 at 15:25
  • Then you will just replace one module with another (this will give you different pdb with different natvis). – KonstantinL Nov 21 '17 at 09:10
  • @KonstantinL: the situation is the following: a customer sends me a dump I want to investigate. Sometimes this means that I need to look for specific entries in the watch-window, which is the easiest if I can modify the *.natvis according to the contents of the dump (e.g. the customer has an issue with arrays while other customers have no issues with arrays). By modifying the *.natvis I can decide whether or not to get array related information, but if the .natvisreload doesn't take my manual changes into account (because of the *.natvis in the symbols file), this procedure can't be done. – Dominique Nov 21 '17 at 09:23
  • Maybe another approach is just to exclude the natvis from the PDB, and use the debugger with the project open. You can do this by setting the natvis file to “excluded from build”. – nneonneo Nov 22 '17 at 16:23

1 Answers1

3

My question seems to be impossible to answer, as mentioned in the natvis schema I just found on my PC:

natvis files that are part of a loaded project will always take precedence over files in the user natvis directory

It seems that it is possible to distinguish between different solutions (applications) within the same natvis file, as you can see here:

  <!-- Solution1 -->
  <Type Name="Class_Name">
    <Version Name="Solution1.exe" Min="1.0" Max="99.99"/>
    <DisplayString>Class_Name Solution1 {m_strName}, {m_iID} </DisplayString>
  </Type>

  <!-- Solution2 -->
  <Type Name="Class_Name"> // in Solution2 Class_Name has no strName
    <Version Name="Solution2.exe" Min="1.0" Max="99.99"/>
    <DisplayString>Class_Name Solution2 identifier {m_iID}</DisplayString>
  </Type>
Dominique
  • 16,450
  • 15
  • 56
  • 112