Fix default PID value and add rollforward forgcdump (#614)
authorJohn Salem <josalem@microsoft.com>
Thu, 14 Nov 2019 18:57:27 +0000 (10:57 -0800)
committerGitHub <noreply@github.com>
Thu, 14 Nov 2019 18:57:27 +0000 (10:57 -0800)
* Prevent default value for pid
add roll forward runtimeconfig to dotnet-gcdump

* Change default to 0 and modify error message

* Change error message

src/Tools/dotnet-gcdump/CommandLine/CollectCommandHandler.cs
src/Tools/dotnet-gcdump/runtimeconfig.template.json [new file with mode: 0644]

index 3eecca44c985f3e5db2d63625b7595ff98edb2fd..5ad9bd92454df5a4c64337ff78b5fe1ebf1ebd94 100644 (file)
@@ -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<int> { Name = "pid" },
+                argument: new Argument<int>(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 (file)
index 0000000..f022b7f
--- /dev/null
@@ -0,0 +1,3 @@
+{
+  "rollForwardOnNoCandidateFx": 2
+}
\ No newline at end of file