From: mikelle-rogers <45022607+mikelle-rogers@users.noreply.github.com> Date: Tue, 22 Feb 2022 19:32:31 +0000 (-0700) Subject: Adding Commandline args to dotnet-tool ps (#2831) X-Git-Tag: accepted/tizen/unified/20221103.165810~28^2^2~63 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d9efaf4793482d6896c6abe3873e8417f552b8a9;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Adding Commandline args to dotnet-tool ps (#2831) * added ability to view the command line arguemnts to dotnet-count tool. * checking on Windows * cleaning up the addition of commandline arguments * cleaning up commandline argument code * Structure and style fixes * modify to ensure dotnet-tool ps works for each tool * finishing up details for commandline argument * Update Third Party Notice accuracy * dotnet-tool ps has commandline arguments * added ability to view the command line arguemnts to dotnet-count tool. * checking on Windows * cleaning up the addition of commandline arguments * cleaning up commandline argument code * Structure and style fixes * modify to ensure dotnet-tool ps works for each tool * finishing up details for commandline argument * Individual descriptions for each tool Co-authored-by: Aniruddha Achar B P --- diff --git a/THIRD-PARTY-NOTICES.TXT b/THIRD-PARTY-NOTICES.TXT index 51b3247c6..835970834 100644 --- a/THIRD-PARTY-NOTICES.TXT +++ b/THIRD-PARTY-NOTICES.TXT @@ -1,4 +1,4 @@ -.NET Core uses third-party libraries or other resources that may be +.NET Core uses third-party libraries or other resources that may be distributed under licenses different than the .NET Core software. Attributions and license notices for test cases originally authored by @@ -322,3 +322,183 @@ SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------------------------------- +License notice for code based on https://github.com/projectkudu + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestApp.sln b/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestApp.sln index c0bc422cb..7fe0b3121 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestApp.sln +++ b/src/SOS/SOS.UnitTests/Debuggees/SymbolTestApp/SymbolTestApp.sln @@ -1,11 +1,10 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29613.14 MinimumVisualStudioVersion = 15.0.26124.0 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymbolTestApp", "SymbolTestApp\SymbolTestApp.csproj", "{EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SymbolTestApp", "SymbolTestApp\SymbolTestApp.csproj", "{EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SymbolTestDll", "SymbolTestDll\SymbolTestDll.csproj", "{53E66227-71BB-4300-9BE9-56CE570B28F8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SymbolTestDll", "SymbolTestDll\SymbolTestDll.csproj", "{53E66227-71BB-4300-9BE9-56CE570B28F8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -16,33 +15,36 @@ Global Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Debug|x64.ActiveCfg = Debug|x64 - {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Debug|x64.Build.0 = Debug|x64 - {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Debug|x86.ActiveCfg = Debug|x86 - {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Debug|x86.Build.0 = Debug|x86 + {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Debug|x64.ActiveCfg = Debug|Any CPU + {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Debug|x64.Build.0 = Debug|Any CPU + {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Debug|x86.ActiveCfg = Debug|Any CPU + {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Debug|x86.Build.0 = Debug|Any CPU {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Release|Any CPU.ActiveCfg = Release|Any CPU {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Release|Any CPU.Build.0 = Release|Any CPU - {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Release|x64.ActiveCfg = Release|x64 - {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Release|x64.Build.0 = Release|x64 - {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Release|x86.ActiveCfg = Release|x86 - {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Release|x86.Build.0 = Release|x86 + {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Release|x64.ActiveCfg = Release|Any CPU + {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Release|x64.Build.0 = Release|Any CPU + {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Release|x86.ActiveCfg = Release|Any CPU + {EB291C94-C60E-4AE6-AEA0-B7EEF86F00AD}.Release|x86.Build.0 = Release|Any CPU {53E66227-71BB-4300-9BE9-56CE570B28F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {53E66227-71BB-4300-9BE9-56CE570B28F8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {53E66227-71BB-4300-9BE9-56CE570B28F8}.Debug|x64.ActiveCfg = Debug|x64 - {53E66227-71BB-4300-9BE9-56CE570B28F8}.Debug|x64.Build.0 = Debug|x64 - {53E66227-71BB-4300-9BE9-56CE570B28F8}.Debug|x86.ActiveCfg = Debug|x86 - {53E66227-71BB-4300-9BE9-56CE570B28F8}.Debug|x86.Build.0 = Debug|x86 + {53E66227-71BB-4300-9BE9-56CE570B28F8}.Debug|x64.ActiveCfg = Debug|Any CPU + {53E66227-71BB-4300-9BE9-56CE570B28F8}.Debug|x64.Build.0 = Debug|Any CPU + {53E66227-71BB-4300-9BE9-56CE570B28F8}.Debug|x86.ActiveCfg = Debug|Any CPU + {53E66227-71BB-4300-9BE9-56CE570B28F8}.Debug|x86.Build.0 = Debug|Any CPU {53E66227-71BB-4300-9BE9-56CE570B28F8}.Release|Any CPU.ActiveCfg = Release|Any CPU {53E66227-71BB-4300-9BE9-56CE570B28F8}.Release|Any CPU.Build.0 = Release|Any CPU - {53E66227-71BB-4300-9BE9-56CE570B28F8}.Release|x64.ActiveCfg = Release|x64 - {53E66227-71BB-4300-9BE9-56CE570B28F8}.Release|x64.Build.0 = Release|x64 - {53E66227-71BB-4300-9BE9-56CE570B28F8}.Release|x86.ActiveCfg = Release|x86 - {53E66227-71BB-4300-9BE9-56CE570B28F8}.Release|x86.Build.0 = Release|x86 + {53E66227-71BB-4300-9BE9-56CE570B28F8}.Release|x64.ActiveCfg = Release|Any CPU + {53E66227-71BB-4300-9BE9-56CE570B28F8}.Release|x64.Build.0 = Release|Any CPU + {53E66227-71BB-4300-9BE9-56CE570B28F8}.Release|x86.ActiveCfg = Release|Any CPU + {53E66227-71BB-4300-9BE9-56CE570B28F8}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {42F03860-BFB4-49ED-900B-0C32D06E0B53} EndGlobalSection EndGlobal diff --git a/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/TaskNestedException.sln b/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/TaskNestedException.sln index 414fb881f..ecca0ea02 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/TaskNestedException.sln +++ b/src/SOS/SOS.UnitTests/Debuggees/TaskNestedException/TaskNestedException.sln @@ -1,11 +1,10 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29613.14 MinimumVisualStudioVersion = 15.0.26124.0 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaskNestedException", "TaskNestedException\TaskNestedException.csproj", "{B9B58649-CEA6-4EF5-A25E-916AE8E77917}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TaskNestedException", "TaskNestedException\TaskNestedException.csproj", "{B9B58649-CEA6-4EF5-A25E-916AE8E77917}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RandomUserLibrary", "RandomUserLibrary\RandomUserLibrary.csproj", "{FADE7D7D-107F-42B0-ABD5-36A101CD8675}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RandomUserLibrary", "RandomUserLibrary\RandomUserLibrary.csproj", "{FADE7D7D-107F-42B0-ABD5-36A101CD8675}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -16,33 +15,36 @@ Global Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Debug|x64.ActiveCfg = Debug|x64 - {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Debug|x64.Build.0 = Debug|x64 - {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Debug|x86.ActiveCfg = Debug|x86 - {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Debug|x86.Build.0 = Debug|x86 + {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Debug|x64.ActiveCfg = Debug|Any CPU + {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Debug|x64.Build.0 = Debug|Any CPU + {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Debug|x86.ActiveCfg = Debug|Any CPU + {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Debug|x86.Build.0 = Debug|Any CPU {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Release|Any CPU.ActiveCfg = Release|Any CPU {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Release|Any CPU.Build.0 = Release|Any CPU - {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Release|x64.ActiveCfg = Release|x64 - {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Release|x64.Build.0 = Release|x64 - {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Release|x86.ActiveCfg = Release|x86 - {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Release|x86.Build.0 = Release|x86 + {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Release|x64.ActiveCfg = Release|Any CPU + {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Release|x64.Build.0 = Release|Any CPU + {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Release|x86.ActiveCfg = Release|Any CPU + {B9B58649-CEA6-4EF5-A25E-916AE8E77917}.Release|x86.Build.0 = Release|Any CPU {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Debug|x64.ActiveCfg = Debug|x64 - {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Debug|x64.Build.0 = Debug|x64 - {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Debug|x86.ActiveCfg = Debug|x86 - {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Debug|x86.Build.0 = Debug|x86 + {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Debug|x64.ActiveCfg = Debug|Any CPU + {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Debug|x64.Build.0 = Debug|Any CPU + {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Debug|x86.ActiveCfg = Debug|Any CPU + {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Debug|x86.Build.0 = Debug|Any CPU {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Release|Any CPU.ActiveCfg = Release|Any CPU {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Release|Any CPU.Build.0 = Release|Any CPU - {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Release|x64.ActiveCfg = Release|x64 - {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Release|x64.Build.0 = Release|x64 - {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Release|x86.ActiveCfg = Release|x86 - {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Release|x86.Build.0 = Release|x86 + {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Release|x64.ActiveCfg = Release|Any CPU + {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Release|x64.Build.0 = Release|Any CPU + {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Release|x86.ActiveCfg = Release|Any CPU + {FADE7D7D-107F-42B0-ABD5-36A101CD8675}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {53DA7C95-F7D2-4F8F-AD21-15CB94158C77} EndGlobalSection EndGlobal diff --git a/src/Tools/Common/Commands/ProcessStatus.cs b/src/Tools/Common/Commands/ProcessStatus.cs index 26ecda6d3..18614de4a 100644 --- a/src/Tools/Common/Commands/ProcessStatus.cs +++ b/src/Tools/Common/Commands/ProcessStatus.cs @@ -3,30 +3,108 @@ // See the LICENSE file in the project root for more information. using Microsoft.Diagnostics.NETCore.Client; +using Microsoft.Tools.Common; using System; using System.CommandLine; using System.CommandLine.Invocation; using System.CommandLine.IO; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using Process = System.Diagnostics.Process; +using System.IO; +using System.ComponentModel; +using System.Threading.Tasks; +using System.CommandLine.Binding; +using Microsoft.Internal.Common.Utils; namespace Microsoft.Internal.Common.Commands -{ +{ public class ProcessStatusCommandHandler { public static Command ProcessStatusCommand(string description) => new Command(name: "ps", description) { - Handler = CommandHandler.Create(PrintProcessStatus) + HandlerDescriptor.FromDelegate((ProcessStatusDelegate)ProcessStatus).GetCommandHandler() }; + delegate void ProcessStatusDelegate(IConsole console); + static void MakeFixedWidth(string text, int width, StringBuilder sb, bool leftPad = false, bool truncateFront = false) + { + int textLength = text.Length; + sb.Append(" "); + if(textLength == width) + { + sb.Append(text); + } + else if(textLength > width) + { + if(truncateFront) + { + sb.Append(text.Substring(textLength - width, width)); + } + else + { + sb.Append(text.Substring(0, width)); + } + } + else + { + if (leftPad) + { + sb.Append(' ', width - textLength); + sb.Append(text); + } + else + { + sb.Append(text); + sb.Append(' ', width - text.Length); + } + + } + sb.Append(" "); + } + struct ProcessDetails + { + public int ProcessId; + public string ProcessName; + public string FileName; + public string CmdLineArgs; + } + /// - /// Print the current list of available .NET core processes for diagnosis and their statuses + /// Print the current list of available .NET core processes for diagnosis, their statuses and the command line arguments that are passed to them. /// - public static void PrintProcessStatus(IConsole console) + public static void ProcessStatus(IConsole console) { + int GetColumnWidth(IEnumerable fieldWidths) + { + int largeLength = Console.WindowWidth / 2 - 16; + return Math.Min(fieldWidths.Max(), largeLength); + } + + void FormatTableRows(List rows, StringBuilder tableText) + { + var processIDs = rows.Select(i => i.ProcessId.ToString().Length); + var processNames = rows.Select(i => i.ProcessName.Length); + var fileNames = rows.Select(i => i.FileName.Length); + var commandLineArgs = rows.Select(i => i.CmdLineArgs.Length); + int iDLength = GetColumnWidth(processIDs); + int nameLength = GetColumnWidth(processNames); + int fileLength = GetColumnWidth(fileNames); + int cmdLength = GetColumnWidth(commandLineArgs); + + foreach(var info in rows) + { + MakeFixedWidth(info.ProcessId.ToString(), iDLength, tableText, true, true); + MakeFixedWidth(info.ProcessName, nameLength, tableText, false, true); + MakeFixedWidth(info.FileName, fileLength, tableText, false, true); + MakeFixedWidth(info.CmdLineArgs, cmdLength, tableText, false, true); + tableText.Append("\n"); + } + } try { StringBuilder sb = new StringBuilder(); @@ -37,23 +115,58 @@ namespace Microsoft.Internal.Common.Commands .ThenBy(process => process.Id); var currentPid = Process.GetCurrentProcess().Id; - + List printInfo = new (); foreach (var process in processes) { if (process.Id == currentPid) { continue; } - try { - sb.Append($"{process.Id, 10} {process.ProcessName, -10} {process.MainModule.FileName}\n"); + String cmdLineArgs = GetArgs(process); + cmdLineArgs = cmdLineArgs == process.MainModule?.FileName ? string.Empty : cmdLineArgs; + string fileName = process.MainModule?.FileName ?? string.Empty; + string[] cmdList = cmdLineArgs.Split(" "); + char separator = Path.DirectorySeparatorChar; + foreach(string str in cmdList) + { + if (str == string.Empty) + { + break; + } + + if (str.Contains(separator)) + { + //Assume the first string to contain the directory separation character is the filepath + fileName = str; + //remove the filepath from the command line arguments + cmdLineArgs = string.Join(" ", cmdList.Skip(1)); + } + break; + + } + var commandInfo = new ProcessDetails() + { + ProcessId = process.Id, + ProcessName = process.ProcessName, + FileName = fileName, + CmdLineArgs = cmdLineArgs + }; + printInfo.Add(commandInfo); } - catch (Exception ex) + catch (Exception ex) { - if (ex is System.ComponentModel.Win32Exception || ex is NullReferenceException) + if (ex is Win32Exception || ex is InvalidOperationException) { - sb.Append($"{process.Id, 10} {process.ProcessName, -10} [Elevated process - cannot determine path]\n"); + var commandInfo = new ProcessDetails() + { + ProcessId = process.Id, + ProcessName = process.ProcessName, + FileName = "[Elevated process - cannot determine path]", + CmdLineArgs = "" + }; + printInfo.Add(commandInfo); } else { @@ -61,6 +174,7 @@ namespace Microsoft.Internal.Common.Commands } } } + FormatTableRows(printInfo, sb); console.Out.WriteLine(sb.ToString()); } catch (InvalidOperationException ex) @@ -80,5 +194,53 @@ namespace Microsoft.Internal.Common.Commands return null; } } + + private static string GetArgs(Process process) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + try + { + string commandLine = WindowsProcessExtension.GetCommandLine(process); + if (!String.IsNullOrWhiteSpace(commandLine)) + { + string[] commandLineSplit = commandLine.Split(' '); + if (commandLineSplit.FirstOrDefault() == process.ProcessName) + { + return String.Join(" ", commandLineSplit.Skip(1)); + } + return commandLine; + } + } + catch (Exception ex) when (ex is Win32Exception || ex is InvalidOperationException) + { + return "[Elevated process - cannot determine command line arguments]"; + } + + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + try + { + string commandLine = File.ReadAllText($"/proc/{process.Id}/cmdline"); + if(!String.IsNullOrWhiteSpace(commandLine)) + { + //The command line may be modified and the first part of the command line may not be /path/to/exe. If that is the case, return the command line as is.Else remove the path to module as we are already displaying that. + string[] commandLineSplit = commandLine.Split('\0'); + if (commandLineSplit.FirstOrDefault() == process.MainModule?.FileName) + { + return String.Join(" ", commandLineSplit.Skip(1)); + } + return commandLine.Replace("\0", " "); + } + return ""; + } + catch (IOException) + { + return "[cannot determine command line arguments]"; + } + } + return ""; + } } } diff --git a/src/Tools/Common/ProcessNativeMethods/ProcessNativeMethods.cs b/src/Tools/Common/ProcessNativeMethods/ProcessNativeMethods.cs new file mode 100644 index 000000000..cdf0128c4 --- /dev/null +++ b/src/Tools/Common/ProcessNativeMethods/ProcessNativeMethods.cs @@ -0,0 +1,113 @@ +using System; +using System.Runtime.InteropServices; + +namespace Microsoft.Internal.Common.Utils +{ + //This code was copied from: + //https://github.com/projectkudu/kudu/blob/787c893a9336beb498252bb2f90a06a95763f9e9/Kudu.Core/Infrastructure/ProcessExtensions.cs + internal static class ProcessNativeMethods + { + public const int ProcessBasicInformation = 0; + public const int ProcessWow64Information = 26; + + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ReadProcessMemory( + IntPtr hProcess, + IntPtr lpBaseAddress, + [Out] byte[] lpBuffer, + IntPtr dwSize, + ref IntPtr lpNumberOfBytesRead); + + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ReadProcessMemory( + IntPtr hProcess, + IntPtr lpBaseAddress, + [Out] byte[] lpBuffer, + IntPtr dwSize, + IntPtr lpNumberOfBytesRead); + + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ReadProcessMemory( + IntPtr hProcess, + IntPtr lpBaseAddress, + out IntPtr lpPtr, + IntPtr dwSize, + ref IntPtr lpNumberOfBytesRead); + + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ReadProcessMemory( + IntPtr hProcess, + IntPtr lpBaseAddress, + ref UNICODE_STRING lpBuffer, + IntPtr dwSize, + IntPtr lpNumberOfBytesRead); + + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ReadProcessMemory( + IntPtr hProcess, + IntPtr lpBaseAddress, + ref UNICODE_STRING_32 lpBuffer, + IntPtr dwSize, + IntPtr lpNumberOfBytesRead); + + [DllImport("advapi32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool OpenProcessToken( + IntPtr hProcess, + UInt32 dwDesiredAccess, + out IntPtr processToken); + + [StructLayout(LayoutKind.Sequential)] + public struct UNICODE_STRING + { + public ushort Length; + public ushort MaximumLength; + public IntPtr Buffer; + } + + [StructLayout(LayoutKind.Sequential)] + public struct UNICODE_STRING_32 + { + public ushort Length; + public ushort MaximumLength; + public int Buffer; + } + + [DllImport("kernel32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool IsWow64Process(IntPtr hProcess, [MarshalAs(UnmanagedType.Bool)]out bool wow64Process); + + [StructLayout(LayoutKind.Sequential)] + public struct ProcessInformation + { + // These members must match PROCESS_BASIC_INFORMATION + internal IntPtr Reserved1; + internal IntPtr PebBaseAddress; + internal IntPtr Reserved2_0; + internal IntPtr Reserved2_1; + internal IntPtr UniqueProcessId; + internal IntPtr InheritedFromUniqueProcessId; + } + + [DllImport("ntdll.dll")] + public static extern int NtQueryInformationProcess( + IntPtr processHandle, + int processInformationClass, + ref ProcessInformation processInformation, + int processInformationLength, + out int returnLength); + + [DllImport("ntdll.dll", SetLastError = true)] + public static extern int NtQueryInformationProcess( + IntPtr processHandle, + int processInformationClass, + ref IntPtr processInformation, + int processInformationLength, + ref int returnLength); + } +} diff --git a/src/Tools/Common/WindowsProcessExtension/WindowsProcessExtension.cs b/src/Tools/Common/WindowsProcessExtension/WindowsProcessExtension.cs new file mode 100644 index 000000000..c65b8146c --- /dev/null +++ b/src/Tools/Common/WindowsProcessExtension/WindowsProcessExtension.cs @@ -0,0 +1,202 @@ +using System; +using System.Runtime.InteropServices; +using System.Diagnostics; +using System.Text; +using System.ComponentModel; + +namespace Microsoft.Internal.Common.Utils + +{ + internal static class WindowsProcessExtension + { + //This code was copied from: + //https://github.com/projectkudu/kudu/blob/787c893a9336beb498252bb2f90a06a95763f9e9/Kudu.Core/Infrastructure/ProcessExtensions.cs + //The error handling was modified to return a string instead of throw. + + static public string GetCommandLine(Process process) + { + IntPtr processHandle; + try + { + processHandle = process.Handle; + } + catch (Exception ex) when (ex is InvalidOperationException || ex is NotSupportedException) + { + return "[cannot determine command line arguments]"; + } + + return GetCommandLineCore(processHandle); + } + + private static string GetCommandLineCore(IntPtr processHandle) + { + int commandLineLength; + IntPtr commandLineBuffer; + byte[] commandLine; + + int processBitness = GetProcessBitness(processHandle); + + if (processBitness == 64 && !System.Environment.Is64BitProcess) + { + return "[cannot determine command line arguments bitness mismatch]"; + } + + try + { + IntPtr pPeb = processBitness == 64 ? GetPeb64(processHandle) : GetPeb32(processHandle); + + int offset = processBitness == 64 ? 0x20 : 0x10; + + int unicodeStringOffset = processBitness == 64 ? 0x70 : 0x40; + + IntPtr ptr; + + if (!ReadIntPtr(processHandle, pPeb + offset, out ptr)) + { + return "[cannot determine command line arguments]"; + } + + if ((processBitness == 64 && System.Environment.Is64BitProcess)|| + (processBitness == 32 && !System.Environment.Is64BitProcess)) + { + //System and Process are both the same bitness. + + ProcessNativeMethods.UNICODE_STRING unicodeString = new ProcessNativeMethods.UNICODE_STRING(); + if(!ProcessNativeMethods.ReadProcessMemory(processHandle, ptr+unicodeStringOffset, ref unicodeString, new IntPtr(Marshal.SizeOf(unicodeString)), IntPtr.Zero)) + { + return "[cannot determine command line arguments]"; + } + + commandLineLength = unicodeString.Length; + + commandLineBuffer = unicodeString.Buffer; + } + + else + { + //System is 64 bit and the process is 32 bit + + ProcessNativeMethods.UNICODE_STRING_32 unicodeString32 = new ProcessNativeMethods.UNICODE_STRING_32(); + + if(!ProcessNativeMethods.ReadProcessMemory(processHandle, ptr+unicodeStringOffset, ref unicodeString32, new IntPtr(Marshal.SizeOf(unicodeString32)), IntPtr.Zero)) + { + return "[cannot determine command line arguments]"; + } + + commandLineLength = unicodeString32.Length; + commandLineBuffer = new IntPtr(unicodeString32.Buffer); + } + + commandLine = new byte[commandLineLength]; + + if (!ProcessNativeMethods.ReadProcessMemory(processHandle, commandLineBuffer, commandLine, new IntPtr(commandLineLength), IntPtr.Zero)) + { + return "[cannot determine command line arguments]"; + } + + return Encoding.Unicode.GetString(commandLine); + } + + catch(Win32Exception) + { + return "[cannot determine command line arguments]"; + } + + } + + private static bool ReadIntPtr(IntPtr hProcess, IntPtr ptr, out IntPtr readPtr) + { + var dataSize = new IntPtr(IntPtr.Size); + var res_len = IntPtr.Zero; + if (!ProcessNativeMethods.ReadProcessMemory( + hProcess, + ptr, + out readPtr, + dataSize, + ref res_len)) + { + throw new Win32Exception("Reading of the pointer failed. Error: "+Marshal.GetLastWin32Error()); + } + + // This is more like an assert + return res_len == dataSize; + } + + + private static IntPtr GetPebNative(IntPtr hProcess) + { + var pbi = new ProcessNativeMethods.ProcessInformation(); + int res_len = 0; + int pbiSize = Marshal.SizeOf(pbi); + ProcessNativeMethods.NtQueryInformationProcess( + hProcess, + ProcessNativeMethods.ProcessBasicInformation, + ref pbi, + pbiSize, + out res_len); + + if (res_len != pbiSize) + { + throw new Win32Exception("Query Information Process failed. Error: "+ Marshal.GetLastWin32Error()); + } + + return pbi.PebBaseAddress; + } + + private static IntPtr GetPeb64(IntPtr hProcess) + { + return GetPebNative(hProcess); + } + + private static IntPtr GetPeb32(IntPtr hProcess) + { + if (System.Environment.Is64BitProcess) + { + var ptr = IntPtr.Zero; + int res_len = 0; + int pbiSize = IntPtr.Size; + ProcessNativeMethods.NtQueryInformationProcess( + hProcess, + ProcessNativeMethods.ProcessWow64Information, + ref ptr, + pbiSize, + ref res_len); + + if (res_len != pbiSize) + { + throw new Win32Exception("Query Information Process failed. Error: " + Marshal.GetLastWin32Error()); + } + + return ptr; + } + else + { + return GetPebNative(hProcess); + } + } + + static private int GetProcessBitness(IntPtr hProcess) + { + if (System.Environment.Is64BitOperatingSystem) + { + bool wow64; + if (!ProcessNativeMethods.IsWow64Process(hProcess, out wow64)) + { + return 32; + } + + if (wow64) + { + return 32; + } + + return 64; + } + + else + { + return 32; + } + } + } +} diff --git a/src/Tools/dotnet-counters/Program.cs b/src/Tools/dotnet-counters/Program.cs index 75e425edf..50ae1b2e8 100644 --- a/src/Tools/dotnet-counters/Program.cs +++ b/src/Tools/dotnet-counters/Program.cs @@ -240,7 +240,7 @@ namespace Microsoft.Diagnostics.Tools.Counters .AddCommand(MonitorCommand()) .AddCommand(CollectCommand()) .AddCommand(ListCommand()) - .AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that can be monitored")) + .AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that can be monitored.")) .UseDefaults() .Build(); diff --git a/src/Tools/dotnet-counters/dotnet-counters.csproj b/src/Tools/dotnet-counters/dotnet-counters.csproj index fb74a948c..a4e6dbd68 100644 --- a/src/Tools/dotnet-counters/dotnet-counters.csproj +++ b/src/Tools/dotnet-counters/dotnet-counters.csproj @@ -16,7 +16,9 @@ - + + + diff --git a/src/Tools/dotnet-dump/Program.cs b/src/Tools/dotnet-dump/Program.cs index aed69c55b..45368c7d4 100644 --- a/src/Tools/dotnet-dump/Program.cs +++ b/src/Tools/dotnet-dump/Program.cs @@ -21,7 +21,7 @@ namespace Microsoft.Diagnostics.Tools.Dump var parser = new CommandLineBuilder() .AddCommand(CollectCommand()) .AddCommand(AnalyzeCommand()) - .AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that dumps can be collected")) + .AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that dumps can be collected from.")) .UseDefaults() .Build(); diff --git a/src/Tools/dotnet-dump/dotnet-dump.csproj b/src/Tools/dotnet-dump/dotnet-dump.csproj index 9f932d935..fedbe362a 100644 --- a/src/Tools/dotnet-dump/dotnet-dump.csproj +++ b/src/Tools/dotnet-dump/dotnet-dump.csproj @@ -25,6 +25,8 @@ + + diff --git a/src/Tools/dotnet-gcdump/Program.cs b/src/Tools/dotnet-gcdump/Program.cs index 893670e21..dd8b7646e 100644 --- a/src/Tools/dotnet-gcdump/Program.cs +++ b/src/Tools/dotnet-gcdump/Program.cs @@ -15,7 +15,7 @@ namespace Microsoft.Diagnostics.Tools.GCDump { var parser = new CommandLineBuilder() .AddCommand(CollectCommandHandler.CollectCommand()) - .AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that gcdumps can be collected from")) + .AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that gcdumps can be collected from.")) .AddCommand(ReportCommandHandler.ReportCommand()) .UseDefaults() .Build(); diff --git a/src/Tools/dotnet-gcdump/dotnet-gcdump.csproj b/src/Tools/dotnet-gcdump/dotnet-gcdump.csproj index 2830bf5d8..f60c1a44e 100644 --- a/src/Tools/dotnet-gcdump/dotnet-gcdump.csproj +++ b/src/Tools/dotnet-gcdump/dotnet-gcdump.csproj @@ -24,6 +24,8 @@ - + + + diff --git a/src/Tools/dotnet-stack/Program.cs b/src/Tools/dotnet-stack/Program.cs index f06f08c83..556ba286d 100644 --- a/src/Tools/dotnet-stack/Program.cs +++ b/src/Tools/dotnet-stack/Program.cs @@ -15,7 +15,7 @@ namespace Microsoft.Diagnostics.Tools.Stack { var parser = new CommandLineBuilder() .AddCommand(ReportCommandHandler.ReportCommand()) - .AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that traces can be collected")) + .AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that stack traces can be collected from.")) .AddCommand(SymbolicateHandler.SymbolicateCommand()) .UseDefaults() .Build(); diff --git a/src/Tools/dotnet-stack/dotnet-stack.csproj b/src/Tools/dotnet-stack/dotnet-stack.csproj index 5a10fafc9..4d21756bb 100644 --- a/src/Tools/dotnet-stack/dotnet-stack.csproj +++ b/src/Tools/dotnet-stack/dotnet-stack.csproj @@ -23,7 +23,9 @@ - + + + diff --git a/src/Tools/dotnet-trace/Program.cs b/src/Tools/dotnet-trace/Program.cs index d99260580..6b20a9b15 100644 --- a/src/Tools/dotnet-trace/Program.cs +++ b/src/Tools/dotnet-trace/Program.cs @@ -17,7 +17,7 @@ namespace Microsoft.Diagnostics.Tools.Trace { var parser = new CommandLineBuilder() .AddCommand(CollectCommandHandler.CollectCommand()) - .AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that traces can be collected")) + .AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that traces can be collected from.")) .AddCommand(ListProfilesCommandHandler.ListProfilesCommand()) .AddCommand(ConvertCommandHandler.ConvertCommand()) .AddCommand(ReportCommandHandler.ReportCommand()) diff --git a/src/Tools/dotnet-trace/dotnet-trace.csproj b/src/Tools/dotnet-trace/dotnet-trace.csproj index bab8a5e56..267812665 100644 --- a/src/Tools/dotnet-trace/dotnet-trace.csproj +++ b/src/Tools/dotnet-trace/dotnet-trace.csproj @@ -20,10 +20,7 @@ - - - - +