-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Enhance coreclr processing of event pipe configuration to be able to write the pid of the current process into the nettrace file #48537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2a20a9e
Enhance coreclr processing of event pipe configuration to be able to …
davidwrighton ac807eb
Address feedback
davidwrighton afc2071
Update to make {pid} behavior work for mono as well and add a test
davidwrighton 5a08a45
Fix unix printf validation error
davidwrighton 8e27c37
Address test concerns
davidwrighton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/tests/tracing/eventpipe/complus_config/name_config_with_pid.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Diagnostics; | ||
| using System.IO; | ||
| using System.Runtime.InteropServices; | ||
| using System.Threading; | ||
|
|
||
| class NameConfigWithPid | ||
| { | ||
| static int Main(string[] args) | ||
| { | ||
| if (args.Length > 0 && args[0] == "waitforinput") | ||
| { | ||
| Console.Error.WriteLine("WaitingForInput in ErrorStream"); | ||
| Console.WriteLine("WaitingForInput"); | ||
| Console.ReadLine(); | ||
| return 100; | ||
| } | ||
| else | ||
| { | ||
| Process process = null; | ||
| try | ||
| { | ||
| process = new Process(); | ||
| } | ||
| catch (PlatformNotSupportedException) | ||
| { | ||
| // For platforms that do not support launching child processes, simply succeed the test | ||
| return 100; | ||
| } | ||
|
|
||
| string corerun = Path.Combine(Environment.GetEnvironmentVariable("CORE_ROOT"), "corerun"); | ||
| if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
| corerun = corerun + ".exe"; | ||
|
|
||
| // Use dll directory as temp directory | ||
| string tempDir = Path.GetDirectoryName(typeof(NameConfigWithPid).Assembly.Location); | ||
| string outputPathBaseName = $"eventPipeStream{Thread.CurrentThread.ManagedThreadId}_{(ulong)Stopwatch.GetTimestamp()}"; | ||
| string outputPathPattern = Path.Combine(tempDir, outputPathBaseName + "_{pid}_{pid}.nettrace"); | ||
|
|
||
| process.StartInfo.FileName = corerun; | ||
| process.StartInfo.Arguments = typeof(NameConfigWithPid).Assembly.Location + " waitforinput"; | ||
| process.StartInfo.UseShellExecute = false; | ||
| process.StartInfo.RedirectStandardInput = true; | ||
| process.StartInfo.RedirectStandardError = true; | ||
|
|
||
| process.StartInfo.Environment.Add("COMPlus_EnableEventPipe", "1"); | ||
| process.StartInfo.Environment.Add("COMPlus_EventPipeConfig", "Microsoft-Windows-DotNETRuntime:4c14fccbd:4"); | ||
| process.StartInfo.Environment.Add("COMPlus_EventPipeOutputPath", outputPathPattern); | ||
|
|
||
| process.Start(); | ||
|
|
||
| process.StandardError.ReadLine(); | ||
| uint pid = (uint)process.Id; | ||
| string expectedPath = outputPathPattern.Replace("{pid}", pid.ToString()); | ||
|
|
||
| process.StandardInput.WriteLine("input"); | ||
| process.WaitForExit(); | ||
| if (!File.Exists(expectedPath)) | ||
| { | ||
| Console.WriteLine($"{expectedPath} not found"); | ||
| return 1; | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine($"{expectedPath} found"); | ||
| for (int i = 0; i < 20; i++) | ||
| { | ||
| try | ||
| { | ||
| if (File.Exists(expectedPath)) | ||
| File.Delete(expectedPath); | ||
| return 100; | ||
| } | ||
| catch { } | ||
| Thread.Sleep(1000); | ||
| } | ||
| Console.WriteLine($"Unable to delete {expectedPath}"); | ||
| return 2; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should wrap this in a try/finally that attempts to delete the file it potentially created. |
||
| } | ||
| } | ||
| } | ||
12 changes: 12 additions & 0 deletions
12
src/tests/tracing/eventpipe/complus_config/name_config_with_pid.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>exe</OutputType> | ||
| <CLRTestKind>BuildAndRun</CLRTestKind> | ||
| <CLRTestPriority>0</CLRTestPriority> | ||
| <UnloadabilityIncompatible>true</UnloadabilityIncompatible> | ||
| <GCStressIncompatible>true</GCStressIncompatible> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="$(MSBuildProjectName).cs" /> | ||
| </ItemGroup> | ||
| </Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.