Repository navigation
Closed
Description
diagnostics/src/Tools/dotnet-trace/CommandLine/PrintReportHelper.cs
Lines 28 to 54 in 79367ef
| private static string FormatFunction(string name) | |
| { | |
| string classMethod; | |
| Regex nameRx = new Regex(@"(.*\..*)(\(.*\))"); | |
| Match match = nameRx.Match(name); | |
| string functionList = match.Groups[1].Value; | |
| string arguments = match.Groups[2].Value; | |
| string[] usingStatement = functionList.Split("."); | |
| int length = usingStatement.Length; | |
| if (length < 2) | |
| { | |
| if (length == 1) | |
| { | |
| classMethod = usingStatement[length - 1]; | |
| } | |
| else | |
| { | |
| classMethod = usingStatement[length]; | |
| } | |
| } | |
| else | |
| { | |
| classMethod = usingStatement[length - 2] + "." + usingStatement[length - 1]; | |
| } | |
| return classMethod + arguments; | |
| } |
Notably, this code assumes all functions look like the regex, but functions in a trace could show up as ?!? if there aren't symbols available. This results in an empty line in the output.
dotnet trace report topN ./dotnet_20220407_033645.nettrace -v
Top 5 Functions (Exclusive) Inclusive Exclusive
1. 58.33% 58.33%
2. ManualResetEventSlim.Wait(int32,value class System.Threading.Cancellat 8.33% 8.33%
ionToken)
3. WaitHandle.WaitOneNoCheck(int32) 8.33% 8.33%
4. WaitHandle.WaitMultiple(value class System.ReadOnlySpan`1<class System 8.33% 8.33%
.Threading.WaitHandle>,bool,int32)
5. SemaphoreSlim.WaitUntilCountOrTimeout(int32,unsigned int32,value class 8.33% 8.33%
System.Threading.CancellationToken)
I added some logging to the above sample, and it showed that it was attempting to format ?!?. I still have the trace if you want it.
Activity
hoyosjs commentedon Apr 8, 2022
Doesn't perfview have an option to expose the address of the method? Printing that here could be useful instead of ?!?
mikelle-rogers commentedon Apr 8, 2022
Are there any other ways functions can show up as in a trace besides
?!?and the regex?josalem commentedon Apr 8, 2022
Theoretically, yes, but EventPipe traces only contain managed code for now.
If you wanted to generalize it, you'd need to also be able to handle native frame encoding which is typically
module!class::or::namespace::hierarchy::methodname(...), e.g.,coreclr!EventPipeAdapter::ep_enable(). That's where?!?comes from: unknown module and unknown symbol.I'm not sure that's worth the time right now, so it's better to just handle managed frames.
mikelle-rogers commentedon Apr 11, 2022
@hoyosjs @josalem would you please point me in the right direction of where to find perfview's option to expose the address of the method?