Inspect dump files from UWP app

2019-07-14 14:19发布

问题:

First I enabled saving of dump files on a Windows 10 Mobile phone:

Settings > Update & Security > For developers > Save this many crash dumps: 3

Then I debugged an app which throwed an exception. I continued the debugging after stop. After disconnecting and connecting the mobile phone again, I was able to access the dump file stored under Windows phone\Phone\Documents\Debug directory. The file is called

FPCL.WIndows - a736c773-c105-4b30-a799-4bf317872f5e with exception C000027B on 5-03-2016 12.11.dmp

and has about 140 MB!

I copied the file to the bin directory of my UWP app. Afterwards I opened it as file in Visual Studio 2015 (in the same project). Now I can see the Dump Summary and I have the following buttons:

  • Debug with Managed Only
  • Debug with Mixed
  • Debug with Native Only
  • Set symbol paths
  • Copy all to clipboard

If I run Debug with Managed Only I get

A fatal exception was caught by the runtime. See $stowedexception in the Watch window to view the original exception information.

and on clicking Break I get

No compatible code running. The selected debug engine does not support any code executing on the current thread (e.g. only native runtime code is executing).

In the Watch 1 window I see the following

Name: {CLR}$stowedexception
Value: {"The method or operation is not implemented."}
Type: System.NotImplementedException

This should be the exception I have thrown in my app. When I open this node and look under StackTrace I can get a line number. On pressing Continue I get

The debugger cannot continue running the process. This operation is not supported when debugging dump files.

So I can only stop it.


If I run Debug with Mixed I get again

A fatal exception was caught by the runtime. See $stowedexception in the Watch window to view the original exception information.

and on clicking Break I get

kernelbase.pdb not loaded kernelbase.pdb contains the debug information required to find the source for the module KERNELBASE.dll Module Information: Version: 10.0.10586.218 (th2_release.160401-1800) Original Location: KERNELBASE.dll Try one of the following options: Change existing PDB and binary search paths and retry: Microsoft Symbol Servers

Here I can either press Load or New. So the kernelbase.pdb isn't found under the given location. Should it exists? Where should I find it?

In the Watch 1 window I see the same as above and I can only stop it.


If I run Debug with Native Only I get

Unhandled exception at 0x76ECDF95 (combase.dll) in FPCL.WIndows - f736c883-f105-4d30-a719-4bf328872f5e with exception C000027B on 5-03-2016 12.11.dmp: 0xC000027B: Anwendungsinterne Ausnahme (parameters: 0x075C6838, 0x00000002).

and on clicking Break I get the same missing kernelbase error as above, but here in the Watch 1 window the Value is Unable to evaluate the expression. So I can only stop it.


According to this post I should be able to inspect the source code and find the cause. But how is such a UWP dump file inspected correctly?

回答1:

You mention

[...] 0xC000027B [...]

[...] $stowedexception [...]

which are both indicators that there is a Stowed Exception inside the dump.

To analyze such exceptions, first watch Channel 9 Defrag Tools, episode 136 where Andrew Richards explains and then analyzes them (at 3:28). Then download the PDE extension from the Defrag Tools OnDrive and analyze your dump in windbg instead of Visual Studio.

Regarding the symbols of kernelbase, they should be downloaded from the Microsoft symbol server. To set that up in WinDbg, use .symfix;.reload. If you want to give it another try in Visual Studio, go to Debug / Options and choose Debugging / Symbols, then check "Microsoft Symbol Servers".

Regarding the button to press in Visual Studio, choose "Managed only" when debugging the debug build, because your app will run on CoreCLR and choose "Native Only" when debugging the release build, because your app will use .NET native runtime support. (This applies if you didn't change the default settings; otherwise choose according to your compilation settings)