From 2fc71674ef400ee270657faee6b5762f6d4756e9 Mon Sep 17 00:00:00 2001 From: John Salem Date: Thu, 14 Nov 2019 10:57:27 -0800 Subject: [PATCH] Fix default PID value and add rollforward forgcdump (#614) * Prevent default value for pid add roll forward runtimeconfig to dotnet-gcdump * Change default to 0 and modify error message * Change error message --- .../CommandLine/CollectCommandHandler.cs | 14 +++++++++++++- .../dotnet-gcdump/runtimeconfig.template.json | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/Tools/dotnet-gcdump/runtimeconfig.template.json diff --git a/src/Tools/dotnet-gcdump/CommandLine/CollectCommandHandler.cs b/src/Tools/dotnet-gcdump/CommandLine/CollectCommandHandler.cs index 3eecca44c..5ad9bd924 100644 --- a/src/Tools/dotnet-gcdump/CommandLine/CollectCommandHandler.cs +++ b/src/Tools/dotnet-gcdump/CommandLine/CollectCommandHandler.cs @@ -32,6 +32,18 @@ namespace Microsoft.Diagnostics.Tools.GCDump { try { + if (processId < 0) + { + Console.Out.WriteLine($"The PID cannot be negative: {processId}"); + return -1; + } + + if (processId == 0) + { + Console.Out.WriteLine($"-p|--process-id is required"); + return -1; + } + output = string.IsNullOrEmpty(output) ? $"{DateTime.Now.ToString(@"yyyyMMdd\_hhmmss")}_{processId}.gcdump" : output; @@ -102,7 +114,7 @@ namespace Microsoft.Diagnostics.Tools.GCDump new Option( aliases: new[] { "-p", "--process-id" }, description: "The process to collect the trace from", - argument: new Argument { Name = "pid" }, + argument: new Argument(defaultValue: 0) { Name = "pid" }, isHidden: false); private static Option OutputPathOption() => diff --git a/src/Tools/dotnet-gcdump/runtimeconfig.template.json b/src/Tools/dotnet-gcdump/runtimeconfig.template.json new file mode 100644 index 000000000..f022b7ffc --- /dev/null +++ b/src/Tools/dotnet-gcdump/runtimeconfig.template.json @@ -0,0 +1,3 @@ +{ + "rollForwardOnNoCandidateFx": 2 +} \ No newline at end of file -- 2.34.1