From 7c07fa33de6db2e8842393932cc08004d3f342d6 Mon Sep 17 00:00:00 2001 From: nohwnd Date: Thu, 20 Aug 2020 14:45:29 +0200 Subject: [PATCH 1/2] Optionally force usage of ProcDump --- .../CrashDumperFactory.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs index 867e9acb4f..aaa545dc62 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs @@ -31,6 +31,7 @@ public ICrashDumper Create(string targetFramework) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { +<<<<<<< Updated upstream EqtTrace.Info($"CrashDumperFactory: This is Windows, returning ProcDumpCrashDumper that uses ProcDump utility."); return new ProcDumpCrashDumper(); @@ -43,6 +44,39 @@ public ICrashDumper Create(string targetFramework) // EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework}, returning the .NETClient dumper which uses env variables to collect crashdumps of testhost and any child process."); // return new NetClientCrashDumper(); +||||||| constructed merge base + if (!isNet50OrNewer) + { + EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework} which is not net5.0 or newer, returning ProcDumpCrashDumper that uses ProcDump utility."); + return new ProcDumpCrashDumper(); + } + + EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework}, returning the .NETClient dumper which uses env variables to collect crashdumps of testhost and any child process."); + return new NetClientCrashDumper(); +======= + if (!isNet50OrNewer) + { + EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework} which is not net5.0 or newer, returning ProcDumpCrashDumper that uses ProcDump utility."); + return new ProcDumpCrashDumper(); + } + + // On net5.0 we don't have the capability to crash dump on exit, which is useful in rare cases + // like when user exits the testhost process with a random exit code, adding this evn variable + // to force using procdump. This relies on netclient dumper actualy doing all it's work in blame collector + // where it sets all the environment variables, so in effect we will have two crash dumpers active at the same time. + // This proven to be working okay while net5.0 could not create dumps from Task.Run, and I was using this same technique + // to get dump of testhost. This needs PROCDUMP_PATH set to directory with procdump.exe, or having it in path. + var procdumpOverride = Environment.GetEnvironmentVariable("VSTEST_DUMP_FORCEPROCDUMP")?.Trim(); + var forceUsingProcdump = string.IsNullOrWhiteSpace(procdumpOverride) && procdumpOverride != "0"; + if (forceUsingProcdump) + { + EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework}. Forcing the use of ProcDumpCrashDumper that uses ProcDump utility, via VSTEST_DUMP_FORCEPROCDUMP={procdumpOverride}."); + return new ProcDumpCrashDumper(); + } + + EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework}, returning the .NETClient dumper which uses env variables to collect crashdumps of testhost and any child process."); + return new NetClientCrashDumper(); +>>>>>>> Stashed changes } if (isNet50OrNewer) From 0a4ae8a0a978e5ba2459eb26e129a6787b8462a7 Mon Sep 17 00:00:00 2001 From: nohwnd Date: Thu, 20 Aug 2020 14:54:53 +0200 Subject: [PATCH 2/2] Merge --- .../CrashDumperFactory.cs | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs index aaa545dc62..2adb34df10 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/CrashDumperFactory.cs @@ -31,29 +31,6 @@ public ICrashDumper Create(string targetFramework) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { -<<<<<<< Updated upstream - EqtTrace.Info($"CrashDumperFactory: This is Windows, returning ProcDumpCrashDumper that uses ProcDump utility."); - return new ProcDumpCrashDumper(); - - // enable this once crashdump can trigger itself on exceptions that originate from task, then we can avoid using procdump - // if (!string.IsNullOrWhiteSpace(targetFramework) && !targetFramework.Contains("v5.0")) - // { - // EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework} which is not net5.0 or newer, returning ProcDumpCrashDumper that uses ProcDump utility."); - // return new ProcDumpCrashDumper(); - // } - - // EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework}, returning the .NETClient dumper which uses env variables to collect crashdumps of testhost and any child process."); - // return new NetClientCrashDumper(); -||||||| constructed merge base - if (!isNet50OrNewer) - { - EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework} which is not net5.0 or newer, returning ProcDumpCrashDumper that uses ProcDump utility."); - return new ProcDumpCrashDumper(); - } - - EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework}, returning the .NETClient dumper which uses env variables to collect crashdumps of testhost and any child process."); - return new NetClientCrashDumper(); -======= if (!isNet50OrNewer) { EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework} which is not net5.0 or newer, returning ProcDumpCrashDumper that uses ProcDump utility."); @@ -76,7 +53,6 @@ public ICrashDumper Create(string targetFramework) EqtTrace.Info($"CrashDumperFactory: This is Windows on {targetFramework}, returning the .NETClient dumper which uses env variables to collect crashdumps of testhost and any child process."); return new NetClientCrashDumper(); ->>>>>>> Stashed changes } if (isNet50OrNewer)