Fixes for some vendors issues for the stable release (#1785)
authorMike McLaughlin <mikem@microsoft.com>
Wed, 2 Dec 2020 21:48:12 +0000 (13:48 -0800)
committerGitHub <noreply@github.com>
Wed, 2 Dec 2020 21:48:12 +0000 (13:48 -0800)
* Fixes for some vendors issues for the stable release

1) Stop printing the "@(#)Version" prefix of the SOS version on Linux.
2) Change the default symbol cache for dotnet-dump on Windows to VS's.
3) Fix eeversion unhandled exception on Linux when hosted on 5.0.0.
4) Fix `dotnet-dump collect --help` ArgumentOutOfRangeException by reformatting the --type option description.

* Fix eeversion unhandled exception on Linux hosted on 5.0.0

This turned out to be that the dotnet-sos installed included runtime binaries
like System.Memory, System.Buffer, etc. that were wrong version for hosting on
5.0.0. This didn't get catch by the normal testing because only certain project
references were copied to the bin directory.

The main part of this fix was to be very explicit in which assemblies are added to
the TPA that are in the SOS directory instead of adding all of them.

Changed the SOS managed installed to copy all the managed assemblies in SOS.NETCore
to better match the dotnet-sos install layout.

Changed the SOS tests to explicitly test across all the host runtimes (2.1.x,
3.1.x, 5.0.x and desktop).

* Fix `dotnet-dump collect --help` ArgumentOutOfRangeException by reformatting the --type option description.

eng/CreateVersionFile.csproj
src/SOS/SOS.NETCore/CMakeLists.txt
src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt
src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt
src/SOS/Strike/hostcoreclr.cpp
src/SOS/Strike/strike.cpp
src/Tools/dotnet-dump/Analyzer.cs
src/Tools/dotnet-dump/Program.cs

index 1434d0aaee86cd5d5e55559cbdcf9bfd55704bd7..6916068e1b8fe8f7647b9e7e242f045aa4a6e804 100644 (file)
@@ -74,6 +74,7 @@
 
     <PropertyGroup>
       <NativeVersionLines>
+      <!-- SOS (strike.cpp) has a dependency on this variable being public and that it begins with the @(#)Version prefix -->
 <![CDATA[
 char sccsid[] __attribute__((used)) = "@(#)Version $(InformationalVersion)$(BuiltByString)";
  ]]>
index bc8caa12d0b356d2c5635d942577e2dd77944918..ace5a6933c567d1b464432a2c9ade2b02a06da0f 100644 (file)
@@ -2,13 +2,8 @@ project(SOS.NETCore)
 
 if(NOT ${CLR_MANAGED_BINARY_DIR} STREQUAL "")
     set(MANAGED_BINDIR ${CLR_MANAGED_BINARY_DIR}/SOS.NETCore/${CLR_BUILD_TYPE}/netstandard2.0/publish)
-
-    install(FILES ${MANAGED_BINDIR}/SOS.NETCore.dll DESTINATION . )
-    install(FILES ${MANAGED_BINDIR}/SOS.NETCore.pdb DESTINATION . )
-    install(FILES ${MANAGED_BINDIR}/Microsoft.FileFormats.dll DESTINATION . )
-    install(FILES ${MANAGED_BINDIR}/Microsoft.SymbolStore.dll DESTINATION . )
-    install(FILES ${MANAGED_BINDIR}/System.Reflection.Metadata.dll DESTINATION . )
-    install(FILES ${MANAGED_BINDIR}/System.Collections.Immutable.dll DESTINATION . )
+    file(GLOB installfiles ${MANAGED_BINDIR}/*.dll ${MANAGED_BINDIR}/*.pdb)
+    install(FILES ${installfiles} DESTINATION . )
 endif()
 
 if(NOT ${NUGET_PACKAGES} STREQUAL "")
index 7c7d8ca8f654a5ffa02cf1a106330dec52c3c3a8..a7397f7618bad32f953d235417111c1e145f18ce 100644 (file)
@@ -52,6 +52,7 @@
     <Option Condition="'$(RuntimeVersionLatest)' != ''">
       <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
       <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
+      <SetHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SetHostRuntime>
     </Option>
     <Option Condition="'$(RuntimeVersion50)' != ''">
       <BuildProjectFramework>net5.0</BuildProjectFramework>
@@ -60,6 +61,7 @@
     <Option Condition="'$(RuntimeVersion31)' != ''">
       <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
       <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
+      <SetHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SetHostRuntime>
     </Option>
     <Option Condition="'$(TestRuntime21)' == 'true'">
       <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
@@ -77,7 +79,6 @@
         <Option Condition="'$(RuntimeVersionLatest)' != ''">
           <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
           <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
-          <SetHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SetHostRuntime>
         </Option>
         <Option Condition="'$(RuntimeVersion50)' != ''">
           <BuildProjectFramework>net5.0</BuildProjectFramework>
index b1283dd811106a5883f375f4fdc9c1ae5e3676f0..8f669511ec5d1e7304897992e90e4666bc5a1415 100644 (file)
@@ -68,6 +68,7 @@
         <Option Condition="'$(RuntimeVersionLatest)' != ''">
           <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
           <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
+          <SetHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SetHostRuntime>
         </Option>
         <Option Condition="'$(RuntimeVersion50)' != ''">
           <BuildProjectFramework>net5.0</BuildProjectFramework>
         <Option Condition="'$(RuntimeVersion31)' != ''">
           <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
           <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
+          <SetHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SetHostRuntime>
         </Option>
         <Option Condition="'$(RuntimeVersion21)' != ''">
           <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
           <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
+          <SetHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SetHostRuntime>
         </Option>
         <!--
             SOS.StackAndOtherTests (cli because tested with full, embedded and portable PDBs)
       <BuildProjectRuntime>win-$(TargetArchitecture)</BuildProjectRuntime>
       <DebugType>full</DebugType>
       <RuntimeSymbolsPath>$(DesktopFrameworkPath)</RuntimeSymbolsPath>
+      <SetHostRuntime>-netfx</SetHostRuntime>
     </Option>
   </Options>
 
index a6f118f7b8e7248a7399eb7d0230e026316a3987..b6c2a3174ad82e02fbd6605c884caacf6b978e76 100644 (file)
@@ -63,6 +63,15 @@ SOSNetCoreCallbacks g_SOSNetCoreCallbacks;
 HMODULE g_hmoduleSymBinder = nullptr;
 ISymUnmanagedBinder3 *g_pSymBinder = nullptr;
 #endif
+
+static void AddFileToTpaList(const char* directory, const char* filename, std::string & tpaList)
+{
+    tpaList.append(directory);
+    tpaList.append(DIRECTORY_SEPARATOR_STR_A);
+    tpaList.append(filename);
+    tpaList.append(TPALIST_SEPARATOR_STR_A);
+}
+
 //
 // Build the TPA list of assemblies for the runtime hosting api.
 //
@@ -106,11 +115,7 @@ static void AddFilesFromDirectoryToTpaList(const char* directory, std::string& t
                     if (addedAssemblies.find(filenameWithoutExt) == addedAssemblies.end())
                     {
                         addedAssemblies.insert(filenameWithoutExt);
-
-                        tpaList.append(directory);
-                        tpaList.append(DIRECTORY_SEPARATOR_STR_A);
-                        tpaList.append(filename);
-                        tpaList.append(TPALIST_SEPARATOR_STR_A);
+                        AddFileToTpaList(directory, filename.c_str(), tpaList);
                     }
                 }
             } 
@@ -612,7 +617,11 @@ static HRESULT InitializeNetCoreHost()
 
     // Trust The SOS managed and dependent assemblies from the sos directory
     std::string tpaList;
-    AddFilesFromDirectoryToTpaList(sosModuleDirectory.c_str(), tpaList);
+    const char* directory = sosModuleDirectory.c_str();
+    AddFileToTpaList(directory, "System.Reflection.Metadata.dll", tpaList);
+    AddFileToTpaList(directory, "System.Collections.Immutable.dll", tpaList);
+    AddFileToTpaList(directory, "Microsoft.FileFormats.dll", tpaList);
+    AddFileToTpaList(directory, "Microsoft.SymbolStore.dll", tpaList);
 
     // Trust the runtime assemblies
     AddFilesFromDirectoryToTpaList(hostRuntimeDirectory.c_str(), tpaList);
index 9ad761fb0dc26f740d132e6d3b2bd97257926e34..20717e2f1e1dd84ee4a53bd5d421e6516707368f 100644 (file)
@@ -10895,7 +10895,7 @@ DECLARE_API(EEVersion)
 
     // Print SOS version
 #ifdef FEATURE_PAL
-    ExtOut("SOS Version: %s\n", sccsid);
+    ExtOut("SOS Version: %s\n", sccsid + sizeof("@(#)Version"));
 #else
     VS_FIXEDFILEINFO sosVersion;
     if (GetSOSVersion(&sosVersion))
index 9e25f0641913b065a22276f6fb906025d7dbf05d..22ba708782fc60af3f714db07747b0f581852d5b 100644 (file)
@@ -63,8 +63,10 @@ namespace Microsoft.Diagnostics.Tools.Dump
                     // Add all the services needed by commands and other services
                     AddServices(target);
 
-                    // Set the default symbol cache to match Visual Studio's
-                    SymbolReader.DefaultSymbolCache = Path.Combine(Path.GetTempPath(), "SymbolCache");
+                    // Set the default symbol cache to match Visual Studio's when running on Windows
+                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
+                        SymbolReader.DefaultSymbolCache = Path.Combine(Path.GetTempPath(), "SymbolCache");
+                    }
 
                     // Automatically enable symbol server support
                     SymbolReader.InitializeSymbolStore(
index 237df38150ca20ece95ed9efeae5f955fea1ed13..f3b2bafbc3219f69092157358043c085ebd667d7 100644 (file)
@@ -73,8 +73,7 @@ on Linux where YYYYMMDD is Year/Month/Day and HHMMSS is Hour/Minute/Second. Othe
         private static Option TypeOption() =>
             new Option(
                 alias: "--type",
-                description: @"The dump type determines the kinds of information that are collected from the process. There are several types: full - The largest dump containing all memory including the module images. heap - A large and relatively comprehensive dump containing module lists, thread lists, all stacks, exception information, handle information, and all memory except for mapped 
-images. mini - A small dump containing module lists, thread lists, exception information and all stacks. If not specified 'full' is the default.")
+                description: @"The dump type determines the kinds of information that are collected from the process. There are several types: Full - The largest dump containing all memory including the module images. Heap - A large and relatively comprehensive dump containing module lists, thread lists, all stacks, exception information, handle information, and all memory except for mapped images. Mini - A small dump containing module lists, thread lists, exception information and all stacks.")
             {
                 Argument = new Argument<Dumper.DumpTypeOption>(name: "dump_type", getDefaultValue: () => Dumper.DumpTypeOption.Full)
             };