1

I'm trying to do dump analysis using Visual Studio Professional 2017, but when entering the command .natvisreload in the watch-window I get syntax error and there is nothing in the output window. (This seems to mean that the command is not understood)

In order to get me on track of the real problem, I'd like to know an example of another command I can launch in the Watch window: does anybody know another command, starting with a dot, I can launch in the Watch window (in order to distinguish whether the issue is related to the specific command .natvisreload or to the general Watch window)?

Dominique
  • 16,450
  • 15
  • 56
  • 112
  • No, that is tough shopping. Commands like that are normally entered in the Immediate window, .natvisreload is the only exception I know of. Also very unlikely that this is actually what you want, it is only useful when you are busy editing visualizers while debugging and you want to see if it now does what you wanted. You probably need to get ahead by looking at the type of dump (managed vs native), verifying that the correct debugging engine is being used and double-checking that you entered the command correctly, it requires an argument. – Hans Passant Apr 09 '18 at 16:16
  • @HansPassant: you saved my life: by mentioning that I need to verify the kind of dump, I realised that I was debugging "Mixed", while `natvisreload` is only about native code, so by debugging "Native Only", natvis is working again. When you re-phrase your comment as an answer, I'll award you the bounty. – Dominique Apr 10 '18 at 07:05

1 Answers1

5

"natvis" is an abbreviation for "native visualizer". Used by the unmanaged debugging engine to provide a customized view of a native object. The .natvisreload command is one that only the unmanaged debugging engine can understand. From the comment it is somewhat obvious how this went wrong:

enter image description here

An example of the slug you see when you use File > Open > File to open a minidump for a process that uses managed code. Note the 3 options you have at the upper right to get the debugging started. "Managed Only" only enables the managed debugging engine, "Native Only" for the unmanaged engine, "Mixed" enables both.

You used "Mixed". While that enables both engines, there can be only one active at the same time. Unfortunately it is not always obvious which particular one is in control. Other than the debugger being able to display source code. And a side effect like you discovered here, the ".natvisreload" command goes "huh?" since that is not a command that the managed debugging engine understands.

So one workaround is to use "Native Only".

You can however switch between engines on-the-fly. This normally happens automagically when the debugger lands on a breakpoint. Not an option for dump debugging. The non-intuitive other way is to use the Debug > Windows > Call Stack debugger window. In mixed-mode debugging you see both managed and unmanaged stack frames in the stack, starting with RtlUserThreadStart at the bottom. Double-click one of these frames, like the bottom one, and the debugger switches engines. Note that you don't necessarily have something decent to look at, especially if this was a managed program, and you merely get a machine code dump for the native code. The ".natvisreload" command will however now work as intended.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536