From 1d72a83dea6af23913ea3fb36ac8edd220cf38ba Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Thu, 17 Sep 2020 23:20:16 -0700 Subject: [PATCH] Enable createdump/dotnet-dump testing on MacOS (#1533) Enable createdump/dotnet-dump testing on MacOS Add COMPlus_DbgEnableElfDumpOnMacOS env var to enable ELF MacOS dumps Install SDK and runtimes into ".dotnet-test" so the new SDKs can be used independent of what Arcade requires. Change SOS.UnitTests to netcoreapp3.1 Add error message about heap state to pe command Add net5.0 to SOS debuggees and change config files to use them Update SDK in global.json Fix WebApp3 debuggee on MacOS Use SDK version 5.0.100-rc.1.20454.5 Add --diag to dotnet-dump collect testing --- .gitignore | 1 + eng/CleanupPrivateBuild.csproj | 2 +- eng/CreateVersionFile.csproj | 2 +- eng/InstallRuntimes.proj | 27 ++++--- eng/dotnet-install.ps1 | 29 +++++++ eng/dotnet-install.sh | 75 ++++++++++++++++++ global.json | 2 +- .../DotNetBuildDebuggeeTestStep.cs | 2 + .../TestConfiguration.cs | 1 + .../Unix/Debugger.Tests.Config.txt | 15 ++-- .../Windows/Debugger.Tests.Config.txt | 12 +-- .../Debuggees/DesktopClrHost/CMakeLists.txt | 1 + .../Debuggees/DivZero/DivZero.csproj | 2 +- .../Debuggees/GCPOH/GCPOH.csproj | 2 +- .../Debuggees/GCWhere/GCWhere.csproj | 2 +- .../Debuggees/LineNums/LineNums.csproj | 2 +- .../NestedExceptionTest.csproj | 2 +- .../Debuggees/Overflow/Overflow.csproj | 2 +- .../ReflectionTest/ReflectionTest.csproj | 2 +- .../Debuggees/SimpleThrow/SimpleThrow.csproj | 2 +- .../SymbolTestApp/SymbolTestApp.csproj | 2 +- .../SymbolTestDll/SymbolTestDll.csproj | 4 +- .../RandomUserLibrary.csproj | 2 +- .../TaskNestedException.csproj | 2 +- .../Debuggees/WebApp3/Program.cs | 16 +++- .../Debuggees/WebApp3/WebApp3.csproj | 8 +- .../Debuggees/WebApp3/testCert.pfx | Bin 0 -> 2702 bytes src/SOS/SOS.UnitTests/SOS.UnitTests.csproj | 2 +- src/SOS/SOS.UnitTests/SOS.cs | 46 ++++++----- src/SOS/SOS.UnitTests/SOSRunner.cs | 10 +-- src/SOS/Strike/strike.cpp | 30 ++++--- 31 files changed, 227 insertions(+), 80 deletions(-) create mode 100644 eng/dotnet-install.ps1 create mode 100644 eng/dotnet-install.sh create mode 100644 src/SOS/SOS.UnitTests/Debuggees/WebApp3/testCert.pfx diff --git a/.gitignore b/.gitignore index 70a02e897..484c88f0d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ [Pp]ackages/ x64/ .dotnet/ +.dotnet-test/ .packages/ .tools/ diff --git a/eng/CleanupPrivateBuild.csproj b/eng/CleanupPrivateBuild.csproj index 83118ceba..5ef592ad8 100644 --- a/eng/CleanupPrivateBuild.csproj +++ b/eng/CleanupPrivateBuild.csproj @@ -1,6 +1,6 @@ - netcoreapp2.0 + netcoreapp2.1 diff --git a/eng/CreateVersionFile.csproj b/eng/CreateVersionFile.csproj index d25e93167..6866b66ad 100644 --- a/eng/CreateVersionFile.csproj +++ b/eng/CreateVersionFile.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + netcoreapp2.1 diff --git a/eng/InstallRuntimes.proj b/eng/InstallRuntimes.proj index a62f0c72d..33cc884e7 100644 --- a/eng/InstallRuntimes.proj +++ b/eng/InstallRuntimes.proj @@ -13,13 +13,15 @@ From Versions.props: + $(MicrosoftDotnetSdkInternalVersion) - .NET SDK to use for testing + $(MicrosoftNETCoreAppVersion) $(MicrosoftAspNetCoreAppRefVersion) - latest dotnet runtime/aspnetcore version to install/test $(MicrosoftNETCoreApp31Version) $(MicrosoftAspNetCoreApp31Version) - 3.1 version $(MicrosoftNETCoreApp21Version) $(MicrosoftAspNetCoreApp21Version) - 2.1 version From Arcade: - $(DotNetRoot) - the SDK/runtime installation root + $(RepoRoot) - the root of the diagnostics repo $(RepositoryEngineeringDir) - the "eng" directory $(VersionsPropsPath) - path of Versions.props --> @@ -35,17 +37,17 @@ - $(DotNetRoot) + $(RepoRoot).dotnet-test\ HKEY_LOCAL_MACHINE\SOFTWARE - $(DotNetRoot)x86\ + $(RepoRoot).dotnet-test\x86\ HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node - -architecture $(BuildArch) + -NoPath -SkipNonVersionedFiles -Architecture $(BuildArch) -InstallDir $(DotNetInstallRoot) $(DotNetInstallRoot.Replace("\", "\\"))shared\\Microsoft.NETCore.App\\$(MicrosoftNETCoreAppVersion)\\ $(DotNetInstallRoot)Debugger.Tests.Versions.txt $(DotNetInstallRoot)AddPrivateTesting.reg @@ -57,12 +59,12 @@ powershell -NonInteractive -ExecutionPolicy ByPass -NoProfile -command - '$(RepositoryEngineeringDir)common\dotnet-install.ps1' + '$(RepositoryEngineeringDir)\dotnet-install.ps1' - $(RepositoryEngineeringDir)common/dotnet-install.sh + $(RepositoryEngineeringDir)/dotnet-install.sh @@ -100,10 +102,12 @@ Condition="$([MSBuild]::IsOsPlatform(Windows))" Inputs="$(VersionsPropsPath)" Outputs="$(TestConfigFileName)"> - + + - @@ -115,11 +119,14 @@ Condition="!$([MSBuild]::IsOsPlatform(Windows))" Inputs="$(VersionsPropsPath)" Outputs="$(TestConfigFileName)"> - + + - diff --git a/eng/dotnet-install.ps1 b/eng/dotnet-install.ps1 new file mode 100644 index 000000000..7adde78d6 --- /dev/null +++ b/eng/dotnet-install.ps1 @@ -0,0 +1,29 @@ +[CmdletBinding(PositionalBinding=$false)] +Param( + [string] $InstallDir="", + [string] $Architecture="", + [string] $Version = "Latest", + [string] $Runtime, + [string] $RuntimeSourceFeed = "", + [string] $RuntimeSourceFeedKey = "", + [switch] $SkipNonVersionedFiles, + [switch] $NoPath +) + +. $PSScriptRoot\common\tools.ps1 + +try { + if ($Runtime) { + InstallDotNet $InstallDir $Version $Architecture $Runtime $SkipNonVersionedFiles -RuntimeSourceFeed $RuntimeSourceFeed -RuntimeSourceFeedKey $RuntimeSourceFeedKey + } + else { + InstallDotNetSdk $InstallDir $Version $Architecture + } +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_ + ExitWithExitCode 1 +} + +ExitWithExitCode 0 diff --git a/eng/dotnet-install.sh b/eng/dotnet-install.sh new file mode 100644 index 000000000..9ba628df7 --- /dev/null +++ b/eng/dotnet-install.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" +# resolve $source until the file is no longer a symlink +while [[ -h "$source" ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +. "$scriptroot/common/tools.sh" + +install_dir="" +architecture="" +version="Latest" +runtime="" +runtimeSourceFeed="" +runtimeSourceFeedKey="" +skip_non_versioned_files=false + +while [[ $# > 0 ]]; do + opt="$(echo "$1" | awk '{print tolower($0)}')" + case "$opt" in + -i|--install-dir|-[Ii]nstall[Dd]ir) + shift + install_dir="$1" + ;; + -v|--version|-[Vv]ersion) + shift + version="$1" + ;; + --arch|--architecture|-[Aa]rch|-[Aa]rchitecture) + shift + architecture="$1" + ;; + --runtime|-[Rr]untime) + shift + runtime="$1" + ;; + -runtimesourcefeed) + shift + runtimeSourceFeed="$1" + ;; + -runtimesourcefeedkey) + shift + runtimeSourceFeedKey="$1" + ;; + --skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles) + skip_non_versioned_files=true + ;; + --no-path|-[Nn]o[Pp]ath) + ;; + *) + Write-PipelineTelemetryError -Category 'Build' -Message "Invalid argument: $1" + exit 1 + ;; + esac + shift +done + +if [[ "$runtime" != "" ]]; then + InstallDotNet "$install_dir" "$version" "$architecture" $runtime $skip_non_versioned_files $runtimeSourceFeed $runtimeSourceFeedKey +else + InstallDotNetSdk "$install_dir" "$version" "$architecture" +fi + +if [[ $exit_code != 0 ]]; then + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "dotnet-install.sh failed (exit code '$exit_code')." >&2 + ExitWithExitCode $exit_code +fi + +ExitWithExitCode 0 diff --git a/global.json b/global.json index 49aaaea3c..66ee323fa 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "5.0.100-preview.6.20310.4", + "dotnet": "5.0.100-rc.1.20452.10", "runtimes": { "dotnet/x64": [ "$(MicrosoftNETCoreApp31Version)", diff --git a/src/Microsoft.Diagnostics.TestHelpers/DotNetBuildDebuggeeTestStep.cs b/src/Microsoft.Diagnostics.TestHelpers/DotNetBuildDebuggeeTestStep.cs index eba69c5c1..58f941e4c 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/DotNetBuildDebuggeeTestStep.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/DotNetBuildDebuggeeTestStep.cs @@ -186,6 +186,7 @@ namespace Microsoft.Diagnostics.TestHelpers { args += extraArgs; } + output.WriteLine("Launching {0} {1}", DotNetToolPath, args); ProcessRunner runner = new ProcessRunner(DotNetToolPath, args). WithWorkingDirectory(DebuggeeSolutionDirPath). WithLog(output). @@ -226,6 +227,7 @@ namespace Microsoft.Diagnostics.TestHelpers AssertDebuggeeProjectFileExists(output); AssertDebuggeeAssetsFileExists(output); + output.WriteLine("Launching {0} {1}", DotNetToolPath, dotnetArgs); ProcessRunner runner = new ProcessRunner(DotNetToolPath, dotnetArgs). WithWorkingDirectory(DebuggeeProjectDirPath). WithLog(output). diff --git a/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs b/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs index 4b03031df..f78930fe0 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs @@ -740,6 +740,7 @@ namespace Microsoft.Diagnostics.TestHelpers get { return OS.Kind == OSKind.Linux && IsNETCore && RuntimeFrameworkVersionMajor >= 2 || + OS.Kind == OSKind.OSX && IsNETCore && RuntimeFrameworkVersionMajor >= 5 || OS.Kind == OSKind.Windows && IsNETCore && RuntimeFrameworkVersionMajor >= 5; } } diff --git a/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt b/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt index 3017810ad..d5e5ec11c 100644 --- a/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt +++ b/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt @@ -9,7 +9,7 @@ ../../../../.. - $(RepoRootDir)/.dotnet + $(RepoRootDir)/.dotnet-test @@ -29,7 +29,8 @@ false - netcoreapp3.1 + net5.0 + net5.0 netcoreapp3.1 netcoreapp2.1 @@ -111,15 +112,15 @@ + $(DotNetRoot)/dotnet + $(RootBinDir)/bin/dotnet-dump/$(TargetConfiguration)/netcoreapp2.1/publish/dotnet-dump.dll + $(DumpDir)/$(TestProduct)/$(RuntimeFrameworkVersion)/$(BuildProjectFramework) + $(DebuggeeDumpOutputRootDir) + diff --git a/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt b/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt index 1e16f37d2..886f7ff8f 100644 --- a/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt +++ b/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt @@ -9,8 +9,8 @@ ..\..\..\..\.. - $(RepoRootDir)\.dotnet - $(RepoRootDir)\.dotnet\x86 + $(RepoRootDir)\.dotnet-test + $(RepoRootDir)\.dotnet-test\x86 @@ -20,7 +20,7 @@ $(RootBinDir)\bin\Windows_NT.$(TargetArchitecture).$(TargetConfiguration) $(RootBinDir)\TestResults\$(TargetConfiguration)\sos.unittests_$(Timestamp) $(RootBinDir)\tmp\$(TargetConfiguration)\dumps - $(RootBinDir)\bin\SOS.UnitTests\$(TargetConfiguration)\netcoreapp2.1\publish\runtimes\win-$(TargetArchitecture)\native\cdb.exe + $(RootBinDir)\bin\SOS.UnitTests\$(TargetConfiguration)\netcoreapp3.1\publish\runtimes\win-$(TargetArchitecture)\native\cdb.exe $(InstallDir)\runcommand.dll false @@ -38,7 +38,8 @@ false - netcoreapp3.1 + net5.0 + net5.0 netcoreapp3.1 netcoreapp2.1 @@ -49,8 +50,7 @@ $(RepoRootDir)\src\SOS\SOS.UnitTests\Debuggees sdk.prebuilt $(RootBinDir) - - $(RepoRootDir)\.dotnet\dotnet.exe + $(DotNetRoot)\dotnet.exe myget.org dotnet-core=https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; diff --git a/src/SOS/SOS.UnitTests/Debuggees/DesktopClrHost/CMakeLists.txt b/src/SOS/SOS.UnitTests/Debuggees/DesktopClrHost/CMakeLists.txt index 1be52fc97..e866539fd 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/DesktopClrHost/CMakeLists.txt +++ b/src/SOS/SOS.UnitTests/Debuggees/DesktopClrHost/CMakeLists.txt @@ -33,3 +33,4 @@ add_library_clr(DesktopClrHost SHARED ${DESKTOPCLRHOST_SOURCES}) target_link_libraries(DesktopClrHost ${DESKTOPCLRHOST_LIBRARY}) install(TARGETS DesktopClrHost DESTINATION ${CLR_MANAGED_BINARY_DIR}/WebApp3/${CLR_BUILD_TYPE}/netcoreapp3.1) +install(TARGETS DesktopClrHost DESTINATION ${CLR_MANAGED_BINARY_DIR}/WebApp3/${CLR_BUILD_TYPE}/net5.0) diff --git a/src/SOS/SOS.UnitTests/Debuggees/DivZero/DivZero.csproj b/src/SOS/SOS.UnitTests/Debuggees/DivZero/DivZero.csproj index 25ce9e1dd..bc1855771 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/DivZero/DivZero.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/DivZero/DivZero.csproj @@ -2,6 +2,6 @@ Exe $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 diff --git a/src/SOS/SOS.UnitTests/Debuggees/GCPOH/GCPOH.csproj b/src/SOS/SOS.UnitTests/Debuggees/GCPOH/GCPOH.csproj index 25ce9e1dd..bc1855771 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/GCPOH/GCPOH.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/GCPOH/GCPOH.csproj @@ -2,6 +2,6 @@ Exe $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 diff --git a/src/SOS/SOS.UnitTests/Debuggees/GCWhere/GCWhere.csproj b/src/SOS/SOS.UnitTests/Debuggees/GCWhere/GCWhere.csproj index 25ce9e1dd..bc1855771 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/GCWhere/GCWhere.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/GCWhere/GCWhere.csproj @@ -2,6 +2,6 @@ Exe $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 diff --git a/src/SOS/SOS.UnitTests/Debuggees/LineNums/LineNums.csproj b/src/SOS/SOS.UnitTests/Debuggees/LineNums/LineNums.csproj index 58f87ba98..1cefe2ae3 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/LineNums/LineNums.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/LineNums/LineNums.csproj @@ -3,6 +3,6 @@ Exe true $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 diff --git a/src/SOS/SOS.UnitTests/Debuggees/NestedExceptionTest/NestedExceptionTest.csproj b/src/SOS/SOS.UnitTests/Debuggees/NestedExceptionTest/NestedExceptionTest.csproj index 25ce9e1dd..bc1855771 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/NestedExceptionTest/NestedExceptionTest.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/NestedExceptionTest/NestedExceptionTest.csproj @@ -2,6 +2,6 @@ Exe $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 diff --git a/src/SOS/SOS.UnitTests/Debuggees/Overflow/Overflow.csproj b/src/SOS/SOS.UnitTests/Debuggees/Overflow/Overflow.csproj index 25ce9e1dd..bc1855771 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/Overflow/Overflow.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/Overflow/Overflow.csproj @@ -2,6 +2,6 @@ Exe $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 diff --git a/src/SOS/SOS.UnitTests/Debuggees/ReflectionTest/ReflectionTest.csproj b/src/SOS/SOS.UnitTests/Debuggees/ReflectionTest/ReflectionTest.csproj index 25ce9e1dd..bc1855771 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/ReflectionTest/ReflectionTest.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/ReflectionTest/ReflectionTest.csproj @@ -2,6 +2,6 @@ Exe $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 diff --git a/src/SOS/SOS.UnitTests/Debuggees/SimpleThrow/SimpleThrow.csproj b/src/SOS/SOS.UnitTests/Debuggees/SimpleThrow/SimpleThrow.csproj index 25ce9e1dd..bc1855771 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/SimpleThrow/SimpleThrow.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/SimpleThrow/SimpleThrow.csproj @@ -2,6 +2,6 @@ Exe $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 diff --git a/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestApp/SymbolTestApp.csproj b/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestApp/SymbolTestApp.csproj index 5938b896f..e3bda46d7 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestApp/SymbolTestApp.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestApp/SymbolTestApp.csproj @@ -2,7 +2,7 @@ Exe $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 $(DefineConstants);FULL_CLR diff --git a/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestDll/SymbolTestDll.csproj b/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestDll/SymbolTestDll.csproj index be593fc00..d9dae21d5 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestDll/SymbolTestDll.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestDll/SymbolTestDll.csproj @@ -2,7 +2,7 @@ Library $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 - net462;netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 + net462;netcoreapp2.1;netcoreapp3.1;net5.0 diff --git a/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/RandomUserLibrary/RandomUserLibrary.csproj b/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/RandomUserLibrary/RandomUserLibrary.csproj index c2082b51e..139b6f83f 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/RandomUserLibrary/RandomUserLibrary.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/RandomUserLibrary/RandomUserLibrary.csproj @@ -2,6 +2,6 @@ Library $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 diff --git a/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/TaskNestedException/TaskNestedException.csproj b/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/TaskNestedException/TaskNestedException.csproj index cea525eec..381e9a2eb 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/TaskNestedException/TaskNestedException.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/TaskNestedException/TaskNestedException.csproj @@ -2,7 +2,7 @@ Exe $(BuildProjectFramework) - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 diff --git a/src/SOS/SOS.UnitTests/Debuggees/WebApp3/Program.cs b/src/SOS/SOS.UnitTests/Debuggees/WebApp3/Program.cs index 01ec09e60..07df5bcd0 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/WebApp3/Program.cs +++ b/src/SOS/SOS.UnitTests/Debuggees/WebApp3/Program.cs @@ -1,8 +1,11 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; using System; +using System.IO; using System.Net.Http; +using System.Reflection; using System.Runtime.InteropServices; +using System.Security.Cryptography.X509Certificates; using System.Threading; namespace WebApp3 @@ -58,8 +61,15 @@ namespace WebApp3 } } - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => - webBuilder.UseStartup()); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => { + webBuilder.ConfigureKestrel(serverOptions => { + serverOptions.ConfigureHttpsDefaults(httpsOptions => { + string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + httpsOptions.ServerCertificate = new X509Certificate2(Path.Combine(directory, "testCert.pfx"), "testPassword"); + }); + }); + webBuilder.UseStartup(); + }); } } diff --git a/src/SOS/SOS.UnitTests/Debuggees/WebApp3/WebApp3.csproj b/src/SOS/SOS.UnitTests/Debuggees/WebApp3/WebApp3.csproj index 92605c5a1..6602bfa15 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/WebApp3/WebApp3.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/WebApp3/WebApp3.csproj @@ -1,7 +1,13 @@ - netcoreapp3.1 + netcoreapp3.1;net5.0 + + + Always + + + diff --git a/src/SOS/SOS.UnitTests/Debuggees/WebApp3/testCert.pfx b/src/SOS/SOS.UnitTests/Debuggees/WebApp3/testCert.pfx new file mode 100644 index 0000000000000000000000000000000000000000..94befa6e7fd465ccf0990165eefcb5230feef51f GIT binary patch literal 2702 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 AC;$Ke literal 0 HcmV?d00001 diff --git a/src/SOS/SOS.UnitTests/SOS.UnitTests.csproj b/src/SOS/SOS.UnitTests/SOS.UnitTests.csproj index aa071359c..80842426f 100644 --- a/src/SOS/SOS.UnitTests/SOS.UnitTests.csproj +++ b/src/SOS/SOS.UnitTests/SOS.UnitTests.csproj @@ -3,7 +3,7 @@ - netcoreapp2.1 + netcoreapp3.1 false ;1591;1701 $(DefineConstants);CORE_CLR diff --git a/src/SOS/SOS.UnitTests/SOS.cs b/src/SOS/SOS.UnitTests/SOS.cs index 261b41d59..e70250fe9 100644 --- a/src/SOS/SOS.UnitTests/SOS.cs +++ b/src/SOS/SOS.UnitTests/SOS.cs @@ -52,34 +52,42 @@ public class SOS if (testDump) { - // Generate a crash dump. - if (information.TestConfiguration.DebuggeeDumpOutputRootDir() != null) + // Create and test dumps on OSX only if the runtime is 5.0 or greater + if (OS.Kind != OSKind.OSX || information.TestConfiguration.RuntimeFrameworkVersionMajor >= 5) { - if (information.DumpGenerator == SOSRunner.DumpGenerator.NativeDebugger && SOSRunner.IsAlpine()) + // Generate a crash dump. + if (information.TestConfiguration.DebuggeeDumpOutputRootDir() != null) { - throw new SkipTestException("lldb tests not supported on Alpine"); + if (information.DumpGenerator == SOSRunner.DumpGenerator.NativeDebugger && SOSRunner.IsAlpine()) + { + throw new SkipTestException("lldb tests not supported on Alpine"); + } + await SOSRunner.CreateDump(information); } - await SOSRunner.CreateDump(information); - } - // Test against a crash dump. - if (information.TestConfiguration.DebuggeeDumpInputRootDir() != null) - { - if (!SOSRunner.IsAlpine()) + // Test against a crash dump. + if (information.TestConfiguration.DebuggeeDumpInputRootDir() != null) { - // With cdb (Windows) or lldb (Linux or OSX) - using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDump)) + if (!SOSRunner.IsAlpine() && OS.Kind != OSKind.OSX) { - await runner.RunScript(scriptName); + // With cdb (Windows) or lldb (Linux) + using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDump)) + { + await runner.RunScript(scriptName); + } } - } - // Using the dotnet-dump analyze tool if the path exists in the config file. Don't test dotnet-dump on triage dumps when running on desktop CLR. - if (information.TestConfiguration.DotNetDumpPath() != null && (information.TestConfiguration.IsNETCore || information.DumpType != SOSRunner.DumpType.Triage)) - { - using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDumpWithDotNetDump)) + // Using the dotnet-dump analyze tool if the path exists in the config file. + if (information.TestConfiguration.DotNetDumpPath() != null) { - await runner.RunScript(scriptName); + // Don't test dotnet-dump on triage dumps when running on desktop CLR. + if (information.TestConfiguration.IsNETCore || information.DumpType != SOSRunner.DumpType.Triage) + { + using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDumpWithDotNetDump)) + { + await runner.RunScript(scriptName); + } + } } } } diff --git a/src/SOS/SOS.UnitTests/SOSRunner.cs b/src/SOS/SOS.UnitTests/SOSRunner.cs index 933549b48..041859f40 100644 --- a/src/SOS/SOS.UnitTests/SOSRunner.cs +++ b/src/SOS/SOS.UnitTests/SOSRunner.cs @@ -218,6 +218,7 @@ public class SOSRunner : IDisposable // Get the full debuggee launch command line (includes the host if required) string exePath = debuggeeConfig.BinaryExePath; var arguments = new StringBuilder(); + if (!string.IsNullOrWhiteSpace(config.HostExe)) { exePath = config.HostExe; @@ -248,15 +249,12 @@ public class SOSRunner : IDisposable // Create the debuggee process runner ProcessRunner processRunner = new ProcessRunner(exePath, ReplaceVariables(variables, arguments.ToString())). + WithEnvironmentVariable("COMPlus_DbgEnableElfDumpOnMacOS", "1"). WithLog(new TestRunner.TestLogger(outputHelper.IndentedOutput)). WithTimeout(TimeSpan.FromMinutes(5)); if (dumpGeneration == DumpGenerator.CreateDump) { - if (OS.Kind == OSKind.OSX) - { - throw new SkipTestException("Createdump doesn't exists on MacOS"); - } // Run the debuggee with the createdump environment variables set to generate a coredump on unhandled exception processRunner. WithEnvironmentVariable("COMPlus_DbgEnableMiniDump", "1"). @@ -307,7 +305,7 @@ public class SOSRunner : IDisposable // Start dotnet-dump collect var dotnetDumpArguments = new StringBuilder(); dotnetDumpArguments.Append(config.DotNetDumpPath()); - dotnetDumpArguments.AppendFormat(" collect --process-id {0} --output %DUMP_NAME%", processRunner.ProcessId); + dotnetDumpArguments.AppendFormat(" collect --diag --process-id {0} --output %DUMP_NAME%", processRunner.ProcessId); ProcessRunner dotnetDumpRunner = new ProcessRunner(config.DotNetDumpHost(), ReplaceVariables(variables, dotnetDumpArguments.ToString())). WithLog(new TestRunner.TestLogger(dotnetDumpOutputHelper)). @@ -415,7 +413,7 @@ public class SOSRunner : IDisposable string debuggerPath = GetNativeDebuggerPath(debugger, config); if (string.IsNullOrWhiteSpace(debuggerPath) || !File.Exists(debuggerPath)) { - throw new FileNotFoundException($"Native debugger path not set or does not exist: {debuggerPath}"); + throw new FileNotFoundException($"Native debugger ({debugger}) path not set or does not exist: {debuggerPath}"); } // Get the debugger arguments and commands to run initially diff --git a/src/SOS/Strike/strike.cpp b/src/SOS/Strike/strike.cpp index fa91dfe36..4311ea900 100644 --- a/src/SOS/Strike/strike.cpp +++ b/src/SOS/Strike/strike.cpp @@ -1475,11 +1475,25 @@ void PrintRuntimeTypeInfo(TADDR p_rtObject, const DacpObjectData & rtObjectData) } } +void DisplayInvalidStructuresMessage() +{ + ExtOut("The garbage collector data structures are not in a valid state for traversal.\n"); + ExtOut("It is either in the \"plan phase,\" where objects are being moved around, or\n"); + ExtOut("we are at the initialization or shutdown of the gc heap. Commands related to \n"); + ExtOut("displaying, finding or traversing objects as well as gc heap segments may not \n"); + ExtOut("work properly. !dumpheap and !verifyheap may incorrectly complain of heap \n"); + ExtOut("consistency errors.\n"); +} + HRESULT PrintObj(TADDR taObj, BOOL bPrintFields = TRUE) { if (!sos::IsObject(taObj, true)) { ExtOut("\n"); + if (!GetGcStructuresValid()) + { + DisplayInvalidStructuresMessage(); + } } DacpObjectData objData; @@ -2641,7 +2655,11 @@ HRESULT FormatException(CLRDATA_ADDRESS taObj, BOOL bLineNumbers = FALSE) DacpObjectData objData; if ((Status=objData.Request(g_sos, taObj)) != S_OK) { - ExtOut("Invalid object\n"); + ExtOut("Invalid exception object: %016llx\n", taObj); + if (!GetGcStructuresValid()) + { + DisplayInvalidStructuresMessage(); + } return Status; } @@ -3458,16 +3476,6 @@ void GCPrintSegmentInfo(DacpGcHeapDetails &heap, DWORD_PTR &total_size); #endif // FEATURE_PAL -void DisplayInvalidStructuresMessage() -{ - ExtOut("The garbage collector data structures are not in a valid state for traversal.\n"); - ExtOut("It is either in the \"plan phase,\" where objects are being moved around, or\n"); - ExtOut("we are at the initialization or shutdown of the gc heap. Commands related to \n"); - ExtOut("displaying, finding or traversing objects as well as gc heap segments may not \n"); - ExtOut("work properly. !dumpheap and !verifyheap may incorrectly complain of heap \n"); - ExtOut("consistency errors.\n"); -} - /**********************************************************************\ * Routine Description: * * * -- 2.34.1