[dotnet-dump] Allow Linux core dumps to be loaded on WIndows (#927)
authorSteve MacLean <Steve.MacLean@microsoft.com>
Wed, 18 Mar 2020 19:01:38 +0000 (15:01 -0400)
committerGitHub <noreply@github.com>
Wed, 18 Mar 2020 19:01:38 +0000 (19:01 +0000)
* [dotnet-dump] Allow Linux core dumps to be loaded on WIndows

* Respond to feedback

src/Tools/dotnet-dump/Analyzer.cs

index 339901db5493ed0b6b189f3d5ba0c5ee87c2a7cd..500cfb965b4eb7bbca1f178254afa9ac719e0593 100644 (file)
@@ -56,7 +56,19 @@ namespace Microsoft.Diagnostics.Tools.Dump
                     target = DataTarget.LoadCoreDump(dump_path.FullName);
                 }
                 else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
-                    target = DataTarget.LoadCrashDump(dump_path.FullName, CrashDumpReader.ClrMD);
+                    try
+                    {
+                        target = DataTarget.LoadCoreDump(dump_path.FullName);
+                    }
+                    catch (InvalidDataException)
+                    {
+                        // This condition occurs when we try to load a Windows dump as a Elf core dump.
+                    }
+
+                    if (target == null)
+                    {
+                        target = DataTarget.LoadCrashDump(dump_path.FullName, CrashDumpReader.ClrMD);
+                    }
                 }
                 else {
                     throw new PlatformNotSupportedException($"Unsupported operating system: {RuntimeInformation.OSDescription}");