dotnet-dump analyze enable cross DAC lookup (#954)
authorSteve MacLean <Steve.MacLean@microsoft.com>
Wed, 25 Mar 2020 21:45:52 +0000 (17:45 -0400)
committerGitHub <noreply@github.com>
Wed, 25 Mar 2020 21:45:52 +0000 (17:45 -0400)
* Fix SOSHost.IsCoreClrRuntimeModule()

* Fix cross DAC LoadNativeSymbols()

This allows the SOSHost to find the cross DAC in the symbol cache

* Feedback

When creating a SymbolStoreKey semi-clone copy all the fields

src/SOS/SOS.Hosting/SOSHost.cs
src/SOS/SOS.NETCore/SymbolReader.cs
src/Tools/dotnet-dump/Analyzer.cs

index 115bdeb2363fe6102a468fbe637bc22a95aa9f86..b117953d57e77075e96097424c1e30288d869e0f 100644 (file)
@@ -154,8 +154,6 @@ namespace SOS
 
         const string DesktopRuntimeModuleName = "clr";
 
-        private static readonly string s_coreclrModuleName;
-
         internal readonly IDataReader DataReader;
         internal readonly AnalyzeContext AnalyzeContext;
 
@@ -174,16 +172,6 @@ namespace SOS
         static SOSHost()
         {
             AssemblyResolver.Enable();
-
-            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
-                s_coreclrModuleName = "coreclr";
-            }
-            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
-                s_coreclrModuleName = "libcoreclr.so";
-            }
-            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
-                s_coreclrModuleName = "libcoreclr.dylib";
-            }
         }
 
         /// <summary>
@@ -1110,7 +1098,19 @@ namespace SOS
 
         internal static bool IsCoreClrRuntimeModule(ModuleInfo module)
         {
-            return IsModuleEqual(module, s_coreclrModuleName);
+            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+            {
+                return IsModuleEqual(module, "coreclr") || IsModuleEqual(module, "libcoreclr");
+            }
+            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+            {
+                return IsModuleEqual(module, "libcoreclr.so");
+            }
+            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+            {
+                return IsModuleEqual(module, "libcoreclr.dylib");
+            }
+            return false;
         }
 
         internal static bool IsDesktopRuntimeModule(ModuleInfo module)
index 1ee6180939fc13c8c7c53f6e89906a3901dd8c73..b7af5278a4e52f70b1632cdfea93b4f20a27c1f2 100644 (file)
@@ -300,8 +300,18 @@ namespace SOS
                 try
                 {
                     IEnumerable<SymbolStoreKey> keys = generator.GetKeys(flags);
-                    foreach (SymbolStoreKey key in keys)
+                    foreach (SymbolStoreKey forKey in keys)
                     {
+                        SymbolStoreKey key = forKey;
+                        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && key.FullPathName.Equals("libmscordaccore.so"))
+                        {
+                            // We are opening a Linux dump on Windows
+                            // We need to use the Windows index and filename
+                            key = new SymbolStoreKey(key.Index.Replace("libmscordaccore.so", "mscordaccore.dll"),
+                                                     "mscordaccore.dll",
+                                                     key.IsClrSpecialFile,
+                                                     key.PdbChecksums);
+                        }
                         string moduleFileName = Path.GetFileName(key.FullPathName);
                         s_tracer.Verbose("{0} {1}", key.FullPathName, key.Index);
 
index ead2bad85dfeb509fbffaffeb924533378668aeb..ed93268e0cdf4e51d26a8afbce785906c6ebc505 100644 (file)
@@ -247,7 +247,9 @@ namespace Microsoft.Diagnostics.Tools.Dump
                                 // We are opening a Linux dump on Windows
                                 // We need to use the Windows index and filename
                                 key = new SymbolStoreKey(key.Index.Replace("libmscordaccore.so", "mscordaccore.dll"),
-                                                         key.FullPathName.Replace("libmscordaccore.so", "mscordaccore.dll"));
+                                                         key.FullPathName.Replace("libmscordaccore.so", "mscordaccore.dll"),
+                                                         key.IsClrSpecialFile,
+                                                         key.PdbChecksums);
                             }
                         }
                         else