diff --git a/docs/environment-variables.md b/docs/environment-variables.md index 6c066bb6d1..cbe53ba821 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -111,7 +111,7 @@ This document lists all environment variables that are understood and handled by - **Values**: Set to any non-empty value to enable - **Example**: `VSTEST_DUMP_FORCEPROCDUMP=1` -### VSTEST_DUMP_FORCENETDUMP +### VSTEST_DUMP_FORCENETDUMP (Removed in 18.5, selection of dumper is automatic.) - **Description**: Forces the use of dotnet-dump for crash dump collection. - **Values**: Set to any non-empty value to enable - **Example**: `VSTEST_DUMP_FORCENETDUMP=1` diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/HangDumperFactory.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/HangDumperFactory.cs index 99d4ba1c0e..fe7593a64d 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/HangDumperFactory.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/HangDumperFactory.cs @@ -19,8 +19,7 @@ public IHangDumper Create(string targetFramework) EqtTrace.Info($"HangDumperFactory: Creating dumper for {RuntimeInformation.OSDescription} with target framework {targetFramework}."); var procdumpOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_FORCEPROCDUMP")?.Trim(); - var netdumpOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_FORCENETDUMP")?.Trim(); - EqtTrace.Verbose($"HangDumperFactory: Overrides for dumpers: VSTEST_DUMP_FORCEPROCDUMP={procdumpOverride};VSTEST_DUMP_FORCENETDUMP={netdumpOverride}"); + EqtTrace.Verbose($"HangDumperFactory: Overrides for dumpers: VSTEST_DUMP_FORCEPROCDUMP={procdumpOverride}"); var tfm = Framework.FromString(targetFramework); @@ -40,20 +39,10 @@ public IHangDumper Create(string targetFramework) return new ProcDumpDumper(); } - // On some system the interop dumper will thrown AccessViolationException, add an option to force procdump. - var forceUsingNetdump = !netdumpOverride.IsNullOrWhiteSpace() && netdumpOverride != "0"; - if (forceUsingNetdump) + if (tfm.FrameworkName == ".NETCoreApp") { - var isLessThan50 = tfm.FrameworkName == ".NETCoreApp" && Version.Parse(tfm.Version) < Version.Parse("5.0.0.0"); - if (!isLessThan50) - { - EqtTrace.Info($"HangDumperFactory: This is Windows on {tfm.FrameworkName} {tfm.Version}, VSTEST_DUMP_FORCENETDUMP={netdumpOverride} is active, forcing use of .NetClientHangDumper"); - return new NetClientHangDumper(); - } - else - { - EqtTrace.Info($"HangDumperFactory: This is Windows on {tfm.FrameworkName} {tfm.Version}, VSTEST_DUMP_FORCENETDUMP={netdumpOverride} is active, but only applies to .NET 5.0 and newer. Falling back to default hang dumper."); - } + EqtTrace.Info($"HangDumperFactory: This is Windows on {tfm.FrameworkName} {tfm.Version}, returning the standard NETClient library dumper."); + return new NetClientHangDumper(); } EqtTrace.Info($"HangDumperFactory: This is Windows, returning the default WindowsHangDumper that P/Invokes MiniDumpWriteDump."); @@ -62,29 +51,13 @@ public IHangDumper Create(string targetFramework) if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - var isLessThan31 = tfm.FrameworkName == ".NETCoreApp" && Version.Parse(tfm.Version) < Version.Parse("3.1.0.0"); - if (isLessThan31) - { - EqtTrace.Info($"HangDumperFactory: This is Linux on netcoreapp2.1, returning SigtrapDumper."); - - return new SigtrapDumper(); - } - - EqtTrace.Info($"HangDumperFactory: This is Linux net6.0 or newer, returning the standard NETClient library dumper."); + EqtTrace.Info($"HangDumperFactory: This is Linux returning the standard NETClient library dumper."); return new NetClientHangDumper(); } if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - var isLessThan50 = tfm.FrameworkName == ".NETCoreApp" && Version.Parse(tfm.Version) < Version.Parse("5.0.0.0"); - if (isLessThan50) - { - EqtTrace.Info($"HangDumperFactory: This is OSX on {targetFramework}, This combination of OS and framework is not supported."); - - throw new PlatformNotSupportedException($"Unsupported target framework {targetFramework} on OS {RuntimeInformation.OSDescription}"); - } - - EqtTrace.Info($"HangDumperFactory: This is OSX on net5.0 or newer, returning the standard NETClient library dumper."); + EqtTrace.Info($"HangDumperFactory: This is OSX returning the standard NETClient library dumper."); return new NetClientHangDumper(); } diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/SigtrapDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/SigtrapDumper.cs deleted file mode 100644 index 567a8f933c..0000000000 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/SigtrapDumper.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics; - -namespace Microsoft.TestPlatform.Extensions.BlameDataCollector; - -internal class SigtrapDumper : IHangDumper -{ - public void Dump(int processId, string outputDirectory, DumpTypeOption type) - { - Process.Start("kill", $"-s SIGTRAP {processId}"); - } -}