Single file fixes (#2210)
authorMike McLaughlin <mikem@microsoft.com>
Fri, 23 Apr 2021 23:05:02 +0000 (16:05 -0700)
committerGitHub <noreply@github.com>
Fri, 23 Apr 2021 23:05:02 +0000 (16:05 -0700)
* Fix single-file source/line # lookup

* Make index timestamp/file size hex

* Fix Windows single-file; use regular DAC file name

src/Microsoft.Diagnostics.DebugServices.Implementation/Runtime.cs
src/Microsoft.Diagnostics.ExtensionCommands/Host/ModulesCommand.cs
src/SOS/SOS.Hosting/SymbolServiceWrapper.cs
src/SOS/Strike/symbols.cpp
src/SOS/inc/symbolservice.h

index d6396c688ed4c0e00b0500ceae1f9676ff8256ed..9858a75b0d6ee8b1ca53878061a407ce0bb9eed1 100644 (file)
@@ -133,15 +133,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
 
         private string GetDacFileName()
         {
-            Debug.Assert(!string.IsNullOrEmpty(_clrInfo.DacInfo.PlatformSpecificFileName));
-            string name = _clrInfo.DacInfo.PlatformSpecificFileName;
-
-            // If this is the Linux runtime module name, but we are running on Windows return the cross-OS DAC name.
-            if (_target.OperatingSystem == OSPlatform.Linux && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
-            {
-                name = "mscordaccore.dll";
-            }
-            return name;
+            return ClrInfoProvider.GetDacFileName(_clrInfo.Flavor, _target.OperatingSystem);
         }
 
         private string GetLocalDacPath(string dacFileName)
index 2e260d549d39fe5d91d106134f93a96268b13c9e..3b14736730cdaba692354480b453f653eea82798 100644 (file)
@@ -30,8 +30,8 @@ namespace Microsoft.Diagnostics.ExtensionCommands
                     WriteLine("    IsPEImage:       {0}", module.IsPEImage);
                     WriteLine("    IsManaged:       {0}", module.IsManaged);
                     WriteLine("    IsFileLayout:    {0}", module.IsFileLayout?.ToString() ?? "<unknown>");
-                    WriteLine("    IndexFileSize:   {0:X8}", module.IndexFileSize?.ToString() ?? "<none>");
-                    WriteLine("    IndexTimeStamp:  {0:X8}", module.IndexTimeStamp?.ToString() ?? "<none>");
+                    WriteLine("    IndexFileSize:   {0}", module.IndexFileSize?.ToString("X8") ?? "<none>");
+                    WriteLine("    IndexTimeStamp:  {0}", module.IndexTimeStamp?.ToString("X8") ?? "<none>");
                     WriteLine("    Version:         {0}", module.Version?.ToString() ?? "<none>");
                     string versionString = module.VersionString;
                     if (!string.IsNullOrEmpty(versionString)) {
index 9dd207e5e089b61fa2ed0fd2257f69f317593fb1..9d0a10d423e057fa107223e102d794252e61f9ea 100644 (file)
@@ -318,7 +318,7 @@ namespace SOS.Hosting
         /// Checks availability of debugging information for given assembly.
         /// </summary>
         /// <param name="assemblyPath">
-        /// File path of the assembly or null if the module is in-memory or dynamic (generated by Reflection.Emit)
+        /// File path of the assembly or null
         /// </param>
         /// <param name="isFileLayout">type of in-memory PE layout, if true, file based layout otherwise, loaded layout</param>
         /// <param name="loadedPeAddress">
@@ -1061,7 +1061,7 @@ namespace SOS.Hosting
         [UnmanagedFunctionPointer(CallingConvention.Winapi)]
         private delegate IntPtr LoadSymbolsForModuleDelegate(
             [In] IntPtr self,
-            [In] string assemblyPath,
+            [In, MarshalAs(UnmanagedType.LPWStr)] string assemblyPath,
             [In] bool isFileLayout,
             [In] ulong loadedPeAddress,
             [In] uint loadedPeSize,
index 922ac45b774d4cc667a799066c287974250345a3..c0633d7d36fe68fdc0bc6467bf547bb62bce0fbf 100644 (file)
@@ -516,19 +516,8 @@ HRESULT SymbolReader::LoadSymbolsForPortablePDB(__in_z WCHAR* pModuleName, ___in
     HRESULT Status = S_OK;
     IfFailRet(InitializeSymbolService());
 
-    // The module name needs to be null for in-memory PE's.
-    ArrayHolder<char> szModuleName = nullptr;
-    if (!isInMemory && pModuleName != nullptr)
-    {
-        szModuleName = new char[MAX_LONGPATH];
-        if (WideCharToMultiByte(CP_ACP, 0, pModuleName, (int)(_wcslen(pModuleName) + 1), szModuleName, MAX_LONGPATH, NULL, NULL) == 0)
-        {
-            return E_FAIL;
-        }
-    }
-
     m_symbolReaderHandle = GetSymbolService()->LoadSymbolsForModule(
-        szModuleName, isFileLayout, peAddress, (int)peSize, inMemoryPdbAddress, (int)inMemoryPdbSize);
+        pModuleName, isFileLayout, peAddress, (int)peSize, inMemoryPdbAddress, (int)inMemoryPdbSize);
 
     if (m_symbolReaderHandle == 0)
     {
index b02b0e01b7634eaf8e65e228b215bce5857a95d7..9295f7db716ccf7d2fbee99246b9928f00cba5b1 100644 (file)
@@ -60,7 +60,7 @@ public:
         const unsigned char* moduleIndex) = 0;
 
     virtual PVOID STDMETHODCALLTYPE LoadSymbolsForModule(
-        const char*,
+        LPCWSTR,
         BOOL,
         ULONG64,
         int,