From: Next Turn <45985406+NextTurn@users.noreply.github.com> Date: Thu, 6 Feb 2020 06:09:30 +0000 (+0800) Subject: Remove dead codes (#806) X-Git-Tag: submit/tizen_5.5/20200504.045052~11^2^2~127 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06f3cbfb426178850dd9245f2fcda679df89ead8;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Remove dead codes (#806) --- diff --git a/src/Tools/dotnet-dump/Dumper.Linux.cs b/src/Tools/dotnet-dump/Dumper.Linux.cs deleted file mode 100644 index beb521f88..000000000 --- a/src/Tools/dotnet-dump/Dumper.Linux.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Linq; -using System.Diagnostics; -using System.Threading.Tasks; -using System.IO; - -namespace Microsoft.Diagnostics.Tools.Dump -{ - public partial class Dumper - { - private static class Linux - { - internal static async Task CollectDumpAsync(Process process, string fileName, DumpTypeOption type) - { - // We don't work on WSL :( - string ostype = await File.ReadAllTextAsync("/proc/sys/kernel/osrelease"); - if (ostype.Contains("Microsoft")) - { - throw new PlatformNotSupportedException("Cannot collect memory dumps from Windows Subsystem for Linux."); - } - - // First step is to find the .NET runtime. To do this we look for coreclr.so - ProcessModule coreclr = process.Modules.Cast().FirstOrDefault(m => string.Equals(m.ModuleName, "libcoreclr.so")); - if (coreclr == null) - { - throw new NotSupportedException("Unable to locate .NET runtime associated with this process!"); - } - - // Find createdump next to that file - string runtimeDirectory = Path.GetDirectoryName(coreclr.FileName); - string createDumpPath = Path.Combine(runtimeDirectory, "createdump"); - if (!File.Exists(createDumpPath)) - { - throw new NotSupportedException($"Unable to locate 'createdump' tool in '{runtimeDirectory}'"); - } - - // Create the dump - int exitCode = await CreateDumpAsync(createDumpPath, fileName, process.Id, type); - if (exitCode != 0) - { - throw new InvalidOperationException($"createdump exited with non-zero exit code: {exitCode}"); - } - } - - private static Task CreateDumpAsync(string exePath, string fileName, int processId, DumpTypeOption type) - { - string dumpType = type == DumpTypeOption.Mini ? "--normal" : "--withheap"; - var tcs = new TaskCompletionSource(); - var createdump = new Process() - { - StartInfo = new ProcessStartInfo() - { - FileName = exePath, - Arguments = $"--name {fileName} {dumpType} {processId}", - }, - EnableRaisingEvents = true, - }; - createdump.Exited += (s, a) => tcs.TrySetResult(createdump.ExitCode); - createdump.Start(); - return tcs.Task; - } - } - } -}